Balazs Wellisch wrote:
Hi all,

I'm using a regular expression to rename some files I'm working with.
It works well and does exactly what I need.

$name =~ s/(\S+)_(\d+)\.(\S*)$/$2\/videos\/$1\.$3/i;

However, I would like to read this pattern from an ini file instead of
having it hard coded into the program. So, the code would be modified
something like this:

$pattern = 's/(\S+)_(\d+)\.(\S*)$/$2\/videos\/$1\.$3/i';
$name =~ $pattern;

But this doesn't work. How do I get perl to evaluate $pattern in this context?
                                             *^^^^*

perldoc -f eval


I also tried...

$name =~ qr/$pattern/;

...but that doesn't seem to work either.

Any ideas would be much appreciated!


John
--
Those people who think they know everything are a great
annoyance to those of us who do.        -- Isaac Asimov

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to