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

Re^2: regexp list return 5.6 vs 5.8

by Sixtease (Friar)
on Jan 24, 2008 at 07:50 UTC ( [id://663953]=note: print w/replies, xml ) Need Help??


in reply to Re: regexp list return 5.6 vs 5.8
in thread regexp list return 5.6 vs 5.8

It's not quite the same ^^. @rv is an array and in scalar context evaluates to the number of the emelents. Slicing turns it into a list and thus gives the last element instead.

use strict; use warnings; print "Just Another Perl Hacker\n";

Replies are listed 'Best First'.
Re^3: regexp list return 5.6 vs 5.8
by shmem (Chancellor) on Jan 24, 2008 at 08:31 UTC
    ETOOMUCHMAGIC. If that is what you want, state it:
    return wantarray ? @rv : pop @rv;

    Is the behavior of list slice subroutine return an intended feature, is it specced somewhere (or even documented)? Or is it just an implementation detail which might some day be considered a bug and be changed thereafter?

    Don't golf production code ;-)

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2024-04-25 02:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found