in reply to An interesting Perl problem to extract file content
Another way:
1) Slurp the whole file:
$/ = undef; my $whole_file = <$INFILE>;
2) Split the file into two chunks:
split />firsta\n/, $whole_file;3) Split each chunk into an array of lines.
4) Split the corresponding lines into characters:
my @letters = split //, $line;5) Use a for loop to examine each character in the second line. If the second line contains a '-' get the character at the same index position in the first line.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: An interesting Perl problem to extract file content
by Anonymous Monk on Dec 09, 2010 at 07:12 UTC |