in reply to Re: Finding part of a file
in thread Finding part of a file

I don't know if this is any better, but just for variety (using an extra variable, but shorter match pattern):
if (my $status = /^$start$/ .. /^$end$/) { print unless $status =~ /^1$|E/; } # Or no extra variable, but getting more obfuscated :) print if (/^$start$/../^$end$/) !~ /^1?$|E/;

Replies are listed 'Best First'.
Re: Re: Re: Finding part of a file
by blakem (Monsignor) on Dec 05, 2001 at 03:53 UTC
    Nifty... I didn't know that the flip flop returned anything other than 1 or 0.
    % perl -lne 'printf "%-6s %s\n", $_, scalar(/^banana$/ .. /^grape$/) +' fruit.txt apple banana 1 pear 2 peach 3 grape 4E0 orange
    So, I can tweak my one-liner to exclude the endpoints like so:
    % perl -ne 'print unless (/^banana$/ .. /^grape$/) =~ /^1?$|E/' fruit +.txt pear peach
    Update:
    Doh!, runrigs second stanza was added while I was replying.... I guess obfuscated minds think alike. ;-)

    -Blake