in reply to Re^4: 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
You say: "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; }
If you translate this in plain english it sounds like: while is true that I can read a line from this file, for each file I have, ask me how many column I must consider. It does make no big sense.
You want firstly ask how many column to consider, then for each file obtain the output filename, open it and foreach line do some transformation. Right?
Now in plain english (if my english can be plain..) your overall program must resemble to something like this TODO list:
Notice also that a practical way to ask user for something can be accomplished in a cleaner and less verbose way giving your program the ability to parse command line arguments: two core module are devoted to such tasks: Getopt::Std that is basic and the more developped Getopt::Long
HtH
L*
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Read from multiple files change the data with a script and the write the respective output files with a different extension -- plain english
by Akatsuki (Novice) on Oct 14, 2016 at 06:53 UTC |