in reply to 'Transparent grep'

grep and the likes already do that.

Update:

perl -ne'$m|=/regex/?print&&1:0}exit!$m;{' 1234567890123456789012345678901234567 1 2 3

Replies are listed 'Best First'.
Re^2: 'Transparent grep'
by almut (Canon) on Feb 26, 2009 at 23:31 UTC
    $? = ...; doesn't set the exit code.

    Works for me:

    perl -e 'END{$?=1}' && echo foo # prints nothing perl -e 'END{$?=0}' && echo foo # prints "foo"

    You can manipulate $? in an END block.  From perlmod:

    Inside an "END" code block, $? contains the value that the program is going to pass to "exit()". You can modify $? to change the exit value of the program.

      doh, I tested it outside of END.

      And I now see he wants to print every line.

      Just ignore my post!