1
0
mirror of https://github.com/PhasicFlow/phasicFlow.git synced 2025-07-08 03:07:03 +00:00
Files
.github
DEMSystems
benchmarks
cmake
doc
solvers
src
thirdParty
Zoltan
SampleCmakeScripts
SampleConfigurationScripts
cmake
config
ax_f90_module_case.m4
ax_f90_module_flag.m4
compile
config.guess
config.sub
depcomp
generate-makeoptions.pl
install-sh
missing
replace-install-prefix.pl
string-replace.pl
strip_dup_incl_paths.pl
strip_dup_libs.pl
tac_arg_check_mpi.m4
tac_arg_config_mpi.m4
tac_arg_enable_export-makefiles.m4
tac_arg_enable_feature.m4
tac_arg_enable_feature_sub.m4
tac_arg_enable_feature_sub_check.m4
tac_arg_enable_option.m4
tac_arg_with_3pl_sub.m4
tac_arg_with_ar.m4
tac_arg_with_flags.m4
tac_arg_with_incdirs.m4
tac_arg_with_libdirs.m4
tac_arg_with_libs.m4
tac_arg_with_package.m4
tac_arg_with_perl.m4
token-replace.pl
wk_fc_get_vendor.m4
zac_arg_config_mpi.m4
zac_arg_with_id.m4
doc
docs
example
siMPI
src
test
CMakeLists.txt
COPYRIGHT_AND_LICENSE
Disclaimer
Known_Problems
Makefile.am
Makefile.export.zoltan.in
Makefile.in
README
README.developer
README.md
ReleaseNotes.txt
VERSION
bootstrap-local
buildlib
configure
configure.ac
siMPI_README.txt
README.md
tutorials
utilities
.gitignore
CMakeLists.txt
LICENSE
README.md
phasicFlowConfig.H.in
phasicFlow/thirdParty/Zoltan/config/token-replace.pl
2025-05-15 21:58:43 +03:30

44 lines
1.2 KiB
Perl
Executable File

#!/usr/bin/perl -w
#
# This perl script replaces a string with another string
# on a token basis. Here it is allowed for file_in and
# file_out to be the same file.
#
use strict;
#
my $g_use_msg =
"Use: token-replace.pl find_token replacement_token file_in file_out\n";
if( scalar(@ARGV) < 4 ) {
print STDERR $g_use_msg;
exit(-1);
}
#
my $find_token = shift;
my $replacement_token = shift;
my $file_in_name = shift;
my $file_out_name = shift;
#
#print "file_in_name = $file_in_name\n";
if($file_in_name=~/CVS/) {
# print "Do not replace in CVS\n";
exit;
}
open FILE_IN, "<$file_in_name" || die "The file $file_in_name could not be opended for input\n";
my @file_in_array = <FILE_IN>;
close FILE_IN;
#
my $match_str = '([^\w\d_]|^)' . $find_token . '([^\w\d_]|$)';
#print $match_str . "\n";
#
my @file_out_array;
my $did_replacement = 0;
foreach(@file_in_array) {
$did_replacement = 1 if $_=~s/$match_str/$1$replacement_token$2/g;
push @file_out_array, $_;
}
if($did_replacement || $file_out_name ne $file_in_name) {
open FILE_OUT, ">$file_out_name" || die "The file $file_out_name could not be opended for output\n";
print FILE_OUT @file_out_array;
close FILE_OUT;
}