Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I thought it was common knowledge that there is no such thing as a list in scalar context. :-)

    The context issues are particularly important when you return things. my $foo = bar(); will produce a different result with a bar function that does return @arr; vs one that does return ( $baz1, $baz2, $baz3 ). This is even more insidious if you do something like return grep quux($_), @arr.

    Always mind your context.

    Your particular example, btw, besides all the issues already pointed out by others, should at least be written without that anonymous array in there:

    if ( $id_number == ( reverse sort @ids )[ 0 .. $#ids ] ) {
        # ...
    }

    which then leads to the further simplifications ziggy [perl.org] pointed out.