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

sacked,
Maybe I am just nit picking, but if you meant equivalent results you should not have said equivalent code.
for ( @lines ) { next if /^#/; # ... a dozen lines of code push @paragraph, $_; }
There is no sane way to do the equivalent of this in a map block. You can only choose not to provide the line to the paragraph at the last instruction.

L~R

Replies are listed 'Best First'.
Re: "foreach" is to "next" as "map" is to ???
by Abigail-II (Bishop) on May 26, 2004 at 16:53 UTC
    There is no sane way to do the equivalent of this in a map block.
    Of course there is.
    map { !/^#/ ? () : do { # ... a dozen lines of code } } @lines

    Abigail

Re: Re: Re: Re: Re: "foreach" is to "next" as "map" is to ???
by sacked (Hermit) on May 26, 2004 at 16:57 UTC
    You wrote:
    There is no sane way to do the equivalent of this in a map block.
    @paragraph= map { if( /^#/ ) { () } else { # ... a dozen lines of code $_ } } @lines;

    --sacked