in reply to Re: Re: Re: "foreach" is to "next" as "map" is to ???
in thread "foreach" is to "next" as "map" is to ???

Yeah, but my situation here was sort of like moving from middle-school straight to college.

I'm pretty comfortable with looping, scalars and arrays, simple sorting, that sort of thing, but all of a sudden Sort array according to a value in each element? I needed some really heavy code.

I have an aversion to using code that I don't understand, so I set out to understand the GRT, one chunk at a time.

I learned a lot fast. Next to study is "the empty list technique"...
  • Comment on Re: Re: Re: Re: "foreach" is to "next" as "map" is to ???

Replies are listed 'Best First'.
Empty list technique (was Re*: "foreach" is to "next" as "map" is to ???)
by Roy Johnson (Monsignor) on May 26, 2004 at 19:35 UTC
    To help understand the empty list technique, look at this code, guess what it will output, and then try it.
    my @a=((),(),()); printf "%d\n", scalar @a;
    List flattening is the key. A little more directly:
    printf "%d\n", scalar map {()} 1..3;

    The PerlMonk tr/// Advocate