in reply to Array Search

You're confusing grep() with UNIX's grep utility. check out perldoc -f grep, and you will see. You're also slurping <FILE>...

Here's another way to do it...

while( <FILE> ) { if( my $pos = index( $_, '--foo' ) ) { $pos += 5; print substr( $_, $pos, length($_) - $pos ); } }

Replies are listed 'Best First'.
Re: Re: Array Search
by rob_au (Abbot) on Nov 14, 2001 at 07:44 UTC
    A quick thing here ... if you omit the third parameter from substr, the length parameter, it will return everything up to the end of the line already for you. eg.

    print substr($_, $pos);

    See perlfunc:substr

     

    Ooohhh, Rob no beer function well without!