Thank you for your assistance with my previvous script but now I have a new problem. The create the files and prints to the them, but I want the format to be edit1.dat containing "$Blue Car Green" edit2.dat "Blue $Car Green" etc.., and the format I am getting is edit1.dat "$Blue Car Green" edit2.dat "$Blue $Car Green" etc... I thought it has something to do with the foreach loop, and after an hour of messing around with it I have gotten nowhere. Appreciate any help.
#!usr/bin/perl use File::Copy; print "What file would you like to edit? \n"; chomp($editfile = <>); copy($editfile, "edit.dat") || die "Cannot copy file: $!"; open(INFO,"edit.dat") || die "Can't open edit.dat: $!"; $header = <INFO>; undef $/; $sequence = <INFO>; my @twodarray = split(' ',$sequence); $list[0] = \@twodarray; $x=1; for ($j=0; $j<=$#{$list[0]}; $j++) { for ($k=0; $k<=$#list; $k++) { copy("edit.dat","edit$x.dat"); open(OTHER, ">edit$x.dat"); seek OTHER, 0 ,0; $position = $list[$k][$j]; $commentout = "\$"; $commentout = $commentout .= $position; #foreach $car(@twodarray){ $car =~ s/$position/$commentout/; print $car; print OTHER $car; } $x++; } print "\n"; } close INFO;
In reply to Script printing undesired format by theintern
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |