in reply to help needed on a foreach loop from hell!!!
You've got a bit of a mish-mosh. I think you're trying to read in the entire file into memory, in @file, judging from this: @file = <FILE>; However, when you combine that with $/=undef, you get one long string from the <FILE>, which gets put in the first element of the array. TheDamian once gave an excellent description of what $/ does: "it tells Perl where to stop reading".
Two common idioms are:
In the preceding node, Ineffectual has noted some strange things as well. The one I find most perplexing is that you're sub definition is in the middle of a loop. Also, it looks like the error message your die prints after not being able to open the file came from a monastery copy-and-paste: it's got a + in the middle of the $!.
HTH
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: help needed on a foreach loop from hell!!!
by Kentdn (Novice) on Jan 25, 2002 at 03:04 UTC |