Jenda Krynicky wrote:
If we name the subroutine the code would look like this:

sub read_from_stdin {
 return <STDIN>;
}

...

$next = non_blank(\&read_from_stdin);

that is again the non_blank() would receive a reference to a subroutine that reads one line from STDIN whenever called. (actually this is not entirely true, the behaviour of the subroutine in both cases depends on the context. In scalar context it reads just one line, in list context it reads all remaining lines.)

Excellent!!! this is very clear... (I mean I am sure article was very clear to regular readers.. i am just bit slow but this is great!!)

I am not fully understanding the difference in anonymous sub vs just having regular <STDIN> in there

2)in non_blank sub, my *guess is &{ $scanner }() is trying to dereference the anonymous sub routine... is () necessary there?

We need to dereference and thus call the subroutine, but you are right that the () is not necessary there. I like this syntax better though:

   $scanner->()

but it means the same.
thank you for the confirmation!!

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to