|Think about Loose Coupling|
Re: reading array elementsby Erez (Priest)
|on Nov 26, 2008 at 10:07 UTC||Need Help??|
I'd like to know why lines 9 & 10 in my script have to have $_ instead of $in
Because you wrote it that way?
The idiom while (<FH>) implicitely assign each line read to $_. In essence, what you were probably aiming for is
then use $in instead of $_ in your script. You also don't need next or last, unless you want to force flow control to act differently than it usually does, which brings me to:
Instead of traversing left to right until end of line, then processing the next line until the end of the file; the script processes the ith element of each line only, bypassing the other elements of each line.
No, it does exactly that, only you request it to pick only the 11th element (my $i = 11; then print $fields[$i]). If you want to print all the splitted parts of the line, just say print join "\n", @fields;
"A core tenant of the greater Perl philosophy is to trust that the developer knows enough to solve the problem" - Jay Shirley, A case for Catalyst.