in reply to Re: extracting columns
in thread extracting columns
its cleaner and easier to read
Why? It's not cleaner because it introduces an extra layer of array handling. Your rendition is not easier to read (for me at least) because the indentation is bad.
You have also missed strictures which the OP++ had and you don't use lexical file handles which the OP++ also had. You should use the three parameter version of open and it is good to have the die mention the name of the file being opened or created as well as showing the system error message.
print "@lines[0]\t@lines[1]\n\n"; should be written print "$lines[0]\t$lines[1]\n\n";.
Your code does not actually do what the OP wants to achieve. The OP wants to extract selected fields from a data file and generate a new file. Your code reads pairs of lines from a file then prints them out as pairs of lines with two blank lines between them and a tab prepended to the second line of each pair.
Don't just invent stuff and expect it to work!
|
|---|