#!/bin/perl -w $ARGS = @ARGV; if (-t and $ARGS eq 0 ) { print "No input found\n"; exit 1; } $names++, shift if $ARGV[0] eq "-l"; $search = shift; $showname = @ARGV > 1; @ARGV = "-" unless @ARGV; @ARGV = grep { -T or $_ eq "-" } @ARGV; exit 0 unless @ARGV; while (<>) { next unless /$search/o; if ($names) { print "$ARGV\n"; close ARGV; } else { print "$ARGV: " if $showname; print; } }
In reply to Re: Re: Re: Test for standard input
by rowswell
in thread Test for standard input
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |