On Tue, Jun 17, 2003 at 04:34:04AM -0400, Steve Grazzini wrote:
> On Mon, Jun 16, 2003 at 10:33:28PM -0700, Bryan Harris wrote:
> > Pretty neat, Steve, thanks.

Well don't thank me too soon!

Finally occurred to me to try using ARGV in slurp mode, which does
indeed do the Right Thing:

>     #!/usr/bin/perl -l
>     use strict;
>     use warnings;
> 
>     die usage()  if (@ARGV == 0)
>                  or (@ARGV == 1 and -t STDIN);
> 
>     my $pattern = shift;
>     local $/;
> 
>     while (<>) {
>         my $pfx = @ARGV ? "$ARGV: " : '';
>         print $pfx, $1
>             while =~ /($pattern)/mgi;
>     }
> 
>     sub usage  { "Usage: $0 <PATTERN> [FILES]\n" }

Pretty neat :-)

-- 
Steve

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to