Gunnar Hjalmarsson wrote:
obdulio santana wrote:
Please let me know if everything is Ok.

@l = <DATA>;
@nl = map /^\s*\n/?1:0,@l;
map { print $l[$_] if ("$nl[$_ - 1]$nl[$_]$nl[$_ + 1]" eq "101" ) } (0 ..
$#nl);

1. It's no longer a tiny version. ;-)
2. It generates a warning. Aren't you using strictures and warnings??
3. I'd use a foreach loop instead of map in void context.

    foreach ( 1 .. $#nl-1 ) {
        print $l[$_] if ("$nl[$_ - 1]$nl[$_]$nl[$_ + 1]" eq "101" );
    }

Or print the list returned from map:

print map "$nl[$_-1]$nl[$_]$nl[$_+1]" eq '101' ? $l[$_] : (), 0 .. $#nl;


John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to