Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Trouble getting size of list returned from sub

by 2teez (Priest)
on Nov 26, 2012 at 09:04 UTC ( #1005596=note: print w/replies, xml ) Need Help??


in reply to Trouble getting size of list returned from sub

this can also work:

my $n = () = bad(); print $n; #print 4 sub bad { return qw/foo bar baz timon/; }

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me

Replies are listed 'Best First'.
Re^2: Trouble getting size of list returned from sub
by TomDLux (Vicar) on Nov 30, 2012 at 02:31 UTC

    You can also fold the variable into the same line as the print:

    say ( my $mp =()= bad() );

    But I wouldn't say that's an improvement. In fact, I would tuck all this away into a routine, to hide details and leave only the high-level purpose.

    To learn more about this ( the goatse operator ) and other fun, little-known operators, check out secret perl operators

    As Occam said: Entia non sunt multiplicanda praeter necessitatem.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1005596]
help
Chatterbox?
[Corion]: marioroy: Oh, that's always cool, having API-compatible modules. This makes testing and comparing things much easier
[marioroy]: IPC in MCE::Shared can handle 400k (sends) per second. That's seems a lot for being a pure-Perl module. After making the release, will come back and post a solution for a node by a fellow wanting faster logging.
[Corion]: While working on WWW::Mechanize:: Chrome, I had the suspicion that AnyEvent was doing something wrong, but I was able to swap it out for Mojolicious and the error persisted.
[Corion]: Of course, the error was in my own code ;)
[marioroy]: Corion, start and start_child in MCE::Hobo::Manager return a MCE::Hobo object, whereas P::FM returns the PID. I can have it return the PID though. I tried Hobo::Manager with several P::FM modules, just changed P::FM to MCE::Hobo::Manager and it works.
[marioroy]: I also have a Hobo driver for Forklift allowing folks to use in multiple classes, no conflicts with one another. That's not possible for P::FM.
[Discipulus]: congrats marioroy!

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2017-05-26 08:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?