home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!eiffel!eiffel.com
- From: ram@eiffel.com (Raphael Manfredi)
- Newsgroups: comp.lang.perl
- Subject: Re: Why is this foreach loop exiting early?
- Message-ID: <123@eiffel.eiffel.com>
- Date: 27 Aug 92 01:26:31 GMT
- References: <BtM6E1.81z@well.sf.ca.us>
- Sender: ram@eiffel.com
- Organization: Interactive Software Engineering, Santa Barbara CA
- Lines: 37
-
- Quoting nlane@well.sf.ca.us (Nathan D. Lane) from comp.lang.perl:
- >chop(@farms = `cat $file`);
-
- That is your problem. That is a "shell" behaviour. What you want is more:
-
- @farms = split(/\n/, `cat $file`);
-
- If the file is really big, it might be better (for memory usage) to write:
-
- open(FARMS, $file) || die "Can't open $file: $!\n";
- @farms = <FARMS>; # Because $/ is "\n" and we are in array context
- close FARMS;
-
- >The program doesn't reach the second record, or at least doesn't process it.
- >Needless to say, it doesn't find the INDEX line either (which is why I
- >haven't gotten that part of the processing to function). Any help would be
- >appreciated, including suggestions on style. I do want to learn!
-
- So no wonder, it did not work, you were trying to process one big line,
- and $* is 0 by default so you did not match anything I guess.
-
- Your style is fine -- It looks like what I am writing :-)
-
- Oh, BTW, I've just spot what might be a typo... Further down in your script,
- you write:
-
- if ($farm =~ /INDEX/) {
- next until /\d+/;
- ($Seq, $rest) = split(' ', $farm);
- }
-
- Surely you meant 'unless' instead of 'until'.
- --
- Raphael Manfredi <ram@eiffel.com>
- Interactive Software Engineering Inc.
- 270 Storke Road, Suite #7 / Tel +1 (805) 685-1006 \
- Goleta, California 93117, USA \ Fax +1 (805) 685-6869 /
-