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.
  • @sizes = grep {length $_ -> [1]} @sizes; Specifically, what is {length $_ -> [1]} doing?

    From the docs:

    Evaluates the BLOCK or EXPR for each element of LIST (locally setting $_ to each element) and returns the list value consist- ing of those elements for which the expression evaluated to true. In scalar context, returns the number of times the expression was true.

    The most basic example is something like:

    perl -e '@foo = grep { $_ } (1,0,undef); print "@foo\n"'

    This goes though the list (1,

    --

    --
    "Cake or Death!" .... "Cake please"
    • Oh. Ow. Ouch! @size is not an array of file names but rather a line with file name, file size, etc. I might plead that I am a windows programmer but geez, even so, I should have realized that. My stumbling block was [1]. I couldn't see the relationship even knowing what -> was. Density^3. Thank you.