Mailing List Archive

directory equiv of -n?
How hard would it be to make a directory equivalent of the -n
command-line flag?

The reason I ask, is because I keep doing this:

perl5 -le '$/="";opendir(D,".");for$f(sort grep /^[^.]/,readdir D){open(F,$f);while(<F>){/war and peace/i && print("$f: $_")&& exit}}'

To get at files in a directory. Yes, I could do:

perl -lne ... *

But, I'm doing this in a news spool, and the shell returns: "Agument
list too long".... So, I do it all by hand. But what would be nice is
something like:

perl -directory . -lne '/war and peace/i && print && exit'

I know this is just a request for a workaround to an OS limitation,
but isn't that was perl *is*.... ;-)

-AJS

--
Aaron Sherman <ajs@ajs.com> This " " B4 f w+ c kv s+(--)v r p
I-Kinetics, Inc. for rent Pager: (508)545-0584
1 NE Executive Park Fax: (617)270-4979
Burlington, MA 01803-5005 Desk: (617)252-3489
ajs@ajs.com or ajs@openmarket.com WWW: http://ajs.com/~ajs/
Re: directory equiv of -n? [ In reply to ]
I know it's not a built-in, but this isn't nearly as painful as what you
were doing:

ls | perl -lne 'BEGIN{chomp(@ARGV=<>)} ; print "$ARGV:$_" if /pattern/i; '

-Eric


> From owner-perl5-porters@nicoh.com Mon Oct 30 12:41:18 1995
>
> How hard would it be to make a directory equivalent of the -n
> command-line flag?
>
> The reason I ask, is because I keep doing this:
>
> perl5 -le '$/="";opendir(D,".");for$f(sort grep /^[^.]/,readdir D){open(F,$f);while(<F>){/war and peace/i && print("$f: $_")&& exit}}'
>
> To get at files in a directory. Yes, I could do:
>
> perl -lne ... *
>
> But, I'm doing this in a news spool, and the shell returns: "Agument
> list too long".... So, I do it all by hand. But what would be nice is
> something like:
>
> perl -directory . -lne '/war and peace/i && print && exit'
>
> I know this is just a request for a workaround to an OS limitation,
> but isn't that was perl *is*.... ;-)
>
> -AJS
>
> --
> Aaron Sherman <ajs@ajs.com> This " " B4 f w+ c kv s+(--)v r p
> I-Kinetics, Inc. for rent Pager: (508)545-0584
> 1 NE Executive Park Fax: (617)270-4979
> Burlington, MA 01803-5005 Desk: (617)252-3489
> ajs@ajs.com or ajs@openmarket.com WWW: http://ajs.com/~ajs/
>
>