Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Ambiguous last usage in Net::NNTP

by hurricup (Pilgrim)
on Jul 11, 2015 at 20:33 UTC ( [id://1134314]=perlquestion: print w/replies, xml ) Need Help??

hurricup has asked for the wisdom of the Perl Monks concerning the following question:

Another strange thing encountered. This time in Net::NNTP

foreach my $h (@{$hosts}) { $connect{PeerAddr} = $h; $obj = $type->SUPER::new(%connect) or next; ${*$obj}{'net_nntp_host'} = $h; ${*$obj}{'net_nntp_arg'} = \%arg; if ($arg{SSL}) { Net::NNTP::_SSL->start_SSL($obj,%arg) or next; } last: }
You may see last: in the end of the block. Is this a label here (never used though)? Or kinda seldom usage of last command?

Replies are listed 'Best First'.
Re: Ambiguous last usage in Net::NNTP
by kcott (Archbishop) on Jul 11, 2015 at 21:30 UTC

    G'day hurricup,

    That's part of the constructor (new()) code. From the Net::NNTP documentation, you can provide "... an array with hosts to try in turn.".

    Changing last: to last; will stop it trying after the first success (which is probably the intent).

    I'll take your word for it, that there's no label called 'last' referenced elsewhere in the code. I was trying to think of way you could actually do that without generating an error (e.g. 'next last;', 'last last;', etc.); however, Perl seems to handle it OK:

    $ perl -MO=Deparse -e 'next last;' next (last); -e syntax OK
    $ perl -MO=Deparse -e 'last last;' last (last); -e syntax OK

    Looks like you're going to be spending a fair bit of time on rt.cpan.org today. :-)

    -- Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1134314]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2024-04-18 05:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found