in reply to Execute regexp on directory tree
Your problem lies here: my $substitute = qq{throw \("$1"\)};
Using qq makes Perl interpolate variables which means that the current value of $1 (at this place undef) is inserted.
Update:
Well, typical, sorry, didn't double check what I wrote (and deleted now :). You have to use the following trick to achieve what you want:
The reason for this is that perl is not automatically doing an interpolation on the substitution string you insert. You have to force that by evalutating before substitution.my $substitute = q{qq{throw ("$1")}}; # and later substitute like this $line =~ s/$regex/$substitute/ee;
-- Hofmator
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Execute regexp on directory tree
by karmas (Sexton) on Dec 12, 2001 at 16:02 UTC |