in reply to Re: Odd behaviour with $. and <DATA>
in thread Odd behaviour with $. and <DATA>
OK -- so the difference is how foreach and while operate differently. Thanks -- that explains it all.
But (since I'm not allowed to use the phrase beg the question) I wonder why that is .. foreach suggests that, for each element in the list, it's going to do something. It doesn't suggest that it's going to slurp up the entire list at once.
Update Sorry, disregard this .. you've explained that one works in list context and the other works in scalar context .. my question is reduced to 'Why do they work in different contexts' and I guess the answer is, 'They do -- period'.
Update2 This is properly explained on p.34 (the first paragraph) of the Camel (3rd edition) -- if and while work in scalar context, and foreach works in list context.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Odd behaviour with $. and <DATA>
by ikegami (Patriarch) on Jan 16, 2006 at 21:22 UTC | |
|
Re^3: Odd behaviour with $. and <DATA>
by blazar (Canon) on Jan 17, 2006 at 08:54 UTC |