
August 29th, 2000, 05:24 PM
|
|
Contributing User
|
|
Join Date: Aug 2000
Posts: 81
Time spent in forums: < 1 sec
Reputation Power: 13
|
|
|
Your regexp is wrong. You escape the $ on the var when you want the variable to be interpolated. Also, when writing stuff with /'s in it, it's best to choose a different delimiter for the regexp -- it makes things a little less cluttered. Try this regexp:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
$_ =~ s!</?$ARGV[1][^>]*>!!gm;
[/code]
You'll also be wanting to ensure that you're slurping the entire file into $_ as a tag could potentially break over multiple lines, and the regexp wouldn't be matching on that. To slurp the file, do something like:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
{
local $/;
undef $/;
$_ = <FILEHANDLE>;
}
[/code]
The { and } are important(ish) to make the $/ local only to that code block. That way your old $/ (probably the default of n, unless you've been playing) will be restored.
Oh, also note that I changed the s (single line) switch on your regexp to an m (multiline) as well, as that'll make sure breaks over lines behave nicely. Not that you really need to, but it means if you start sticking in $'s and ^'s at some later date it'll probably behave more how you expect.
|