For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > June 2007 > Re: Matching of filename regular expression (was:pr warn die question)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Matching of filename regular expression (was:pr warn die question)
Chas Owens

2007-06-01, 6:59 pm

On 6/1/07, Ben Edwards <funkytwig@gmail.com> wrote:
snip
> The variable $flist has something like '*.cvs' in it which I guess is
> almost but not quite a regular expresion.

snip

* in shell matching terms means .* in regex terms
.. in shell matching terms means \. in regex terms
cvs is the same

Where does the value in $flist come from? If you are originating it then say
my $flist = qr(^.*\.cvs$);

instead of

my $flist = "*.cvs";

If the user is supplying the value, well I think there is a module
that will turn a shell match into a regex. You might look at
Regex::Common.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com