Ask a Question related to PERL Miscellaneous, Design and Development.
-
qanda #1
variable file glob into grep without glob()
Hope I don't get shot for posting again, but I really need help with
this ...
I want to process lots (thousands) of files. I want to take a file
glob from the command line and pass it into a grep. If I could write
the file glob (file*.ext for example) directly I would do ...
local @ARGV = grep /file.*\.ext/, readir CURDIR;
However I need to take the glob from the command line. I can't use
the Perl glob as I am restricted to Perl 5.005 which dosen't work with
large argument strings and the only overhead I want for the user is to
possibly quote the glob, maybe myscript "file*.ext"; I do not want
them using find and/or xargs.
Thanks.
qanda Guest
-
File::Glob bug ?
The following script: use File::Glob ':glob'; my @test = ( '{random string}', '\\{random string\\}' ); for (@test) { -
File::Glob can't load module [cygwin], perl-5.8.4 9 (newbie)
I am playing with compiling Perl 5.8.4 under cygwin. Can anyone help me fix the error I seem not get past? ../perl harness Can't load module... -
pass cmd line file glob to grep for readdir
Hi all I want to process lots of files (too many for the shell to expand on one line) so I use readdir instead of glob. If I know the file glob... -
Variable instaed of GLOB REF
Howdy all! If you have a function that is expecting a FILEHANDLE as it's argument how could you supply it a variable instead? For instance: ... -
file name of file that reference to type glob points to
Hey all. This is probably a elementary question, but I can't seem to be able to find a builtin function or combination of functions that will let... -
Tassilo v. Parseval #2
Re: variable file glob into grep without glob()
Also sprach qanda:
In this case translate the glob pattern into a regular expression. You> Hope I don't get shot for posting again, but I really need help with
> this ...
>
> I want to process lots (thousands) of files. I want to take a file
> glob from the command line and pass it into a grep. If I could write
> the file glob (file*.ext for example) directly I would do ...
>
> local @ARGV = grep /file.*\.ext/, readir CURDIR;
>
> However I need to take the glob from the command line. I can't use
> the Perl glob as I am restricted to Perl 5.005 which dosen't work with
> large argument strings and the only overhead I want for the user is to
> possibly quote the glob, maybe myscript "file*.ext"; I do not want
> them using find and/or xargs.
don't have to do that yourself but let Text::Glob from the CPAN do this
work for you:
use Text::Glob qw(glob_to_regex);
...
my $pat = glob_to_regex(shift);
local @ARGV = grep /$pat/, readir CURDIR;
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus}) !JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexi ixesixeseg;y~\n~~dddd;eval
Tassilo v. Parseval Guest



Reply With Quote

