while (<INPUT>) { chomp($_); # Look for title line if ($_ =~/Start -/) { my @sdk_line = split(/\t/, $_); push(@temp, substr($sdk_line[1], 18)); } } while (<INPUT>) { chomp($_); # find process time for that title if ($_ =~/Process/) { print split(/\t/, $_), "\n"; my @sdk_line = split(/\t/, $_); push(@temp , $sdk_line[2]); } }
The second while loop will never be executed, because the first one exhausts all line in the INPUT file.
Also please indent your code in a way that makes it obvious to see which loop ends where.
I have hardcoded my script to parse only 3 files. How do I do it for multiple/unknown number of files.
By iterating over the file names, open each, process it, and close it again. Something like this:
for my $fn (@file_names){ open my $handle, '<', $fn or die "Can't open `$fn' for reading: $! +"; # do something with the file here # and write to output file close $fn; }
In reply to Re: Parsing many files and output to one file. Pls HELP
by moritz
in thread Parsing many files and output to one file. Pls HELP
by hiradhu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |