On Tue, Jan 18, 2005 at 10:43:00PM -0700, Luke Palmer wrote:
> Oh, I thought I replied, but now that I look over the question I guess I
> didn't. The question was:
>
> Austin Hasting writes:
> > How do I concisely code a loop that reads in lines of a file, then
> > calls mysub() on each letter in each line?
> > Or each xml tag on the line?
>
> And I guess the answer is the same as in Perl 5. I don't understand
> what the problem is with Perl 5's approach:
>
> for <> {
> mysub($_) for .split: /<null>/;
> }
The only problem I have is that the $_ topic is reused and may cause
confusion. I'd probably have written it like so:
for <> -> $l {
mysub($_) for $l.split: /<null>/;
}
Except that I think the colon after C<split> isn't needed .... sure
enough, from A12 in the section entitled "The dot notation":
[Update: There is no colon disambiguator any more. Use parens if
there are arguments. (However, you can pass an adverbial block
using :{} notation with a null key. That does not count as an
ordinary argument.)]
So, I guess I'd write it as
for <> -> $l {
mysub($_) for $l.split(/<null>/);
}
-Scott
--
Jonathan Scott Duff
[EMAIL PROTECTED]