i don't common with perl, i programm other language as c sharp, but i have had to write a
simple algorithm to a sub-project, so i'd like someone help me to fix this little code:
open(my $fh, ">", "run_example.bash"); $line = <$fh>; close($fh); my ($i, $j); for ($i=1; $i<(2/0.1); $i++) {mkdir("run_check_$j", 0777) || print $!; opendir(HU, "./run_check_$j") || print "Can't open... maybe try chmod 777"; @hu=readdir(HU); $j = $i+1; open(my $fh, ">", "run_example$j.bash") or die "Cann't open run_example$j.bash";; print $fh "#One of many runs...: " , "\n", $line , "\n"; $celldun_now = 16-(0.1*$j); $fh =~ s/celldm(1) =14/celldm(1) =$celldun_now; close($fh); closedir(HU); }
explanation: i work in a directory there is a file i want to open, and to make many directories in this directory whice
are contain the same file but i want to change a code "$fh =~ s/celldm(1) =14/celldm(1) =$celldun_now;" in each new file accordingly. i also didn't know if i write the variable $i in a string, in a right way.
thank you a lot shahar
Edited by Roger, 04 August 2011 - 07:02 AM.
added [CODE][/CODE] tags