> 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 :-)
Yep, except that the last file that's processed doesn't print the filename.
Almost, though, and that -t STDIN thing is cool, I haven't seen that
before...
- B
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]