in reply to Re^3: Read from multiple files change the data with a script and the write the respective output files with a different extension
in thread Read from multiple files change the data with a script and the write the respective output files with a different extension
If you could help me with another problem I encountered in this program I would be very grateful. I want to enter the number of columns, only once for all the files, not for every file. My original code is:
while (my $line = <$original_fh>) { print "Enter the desired number of columns: "; my $nr = <STDIN>; chomp($nr); $line =~ s/((\w\w\t){$nr})/$1\n/g; $line =~ s/\t/,/g; $line =~ s/(\d{2})/$replace[$1]/g; print $final_fh $line; }
and I tried something like this unsuccessfully
while (my $line = <$original_fh>) { for my $file (@files) { print "Enter the desired number of columns: "; my $nr = <STDIN>; chomp($nr); $line =~ s/((\w\w\t){$nr})/$1\n/g; } $line =~ s/\t/,/g; $line =~ s/(\d{2})/$replace[$1]/g; print $final_fh $line; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Read from multiple files change the data with a script and the write the respective output files with a different extension
by hippo (Archbishop) on Oct 13, 2016 at 14:04 UTC | |
by Akatsuki (Novice) on Oct 14, 2016 at 06:21 UTC | |
|
Re^5: Read from multiple files change the data with a script and the write the respective output files with a different extension -- plain english
by Discipulus (Canon) on Oct 13, 2016 at 19:10 UTC | |
by Akatsuki (Novice) on Oct 14, 2016 at 06:53 UTC |