Do you know where your variables are? | |
PerlMonks |
Re^3: Strip specific html sequenceby AnomalousMonk (Archbishop) |
on Dec 10, 2017 at 18:15 UTC ( [id://1205265]=note: print w/replies, xml ) | Need Help?? |
my $remove = q{<div><div class="blue"></div></div>}; Don't use quoted string constructors to make regex patterns; use qr// (update: to make honest-to-goodness regex objects) (see perlop, perlre, perlretut, and perlrequick). Using ordinary quoted string constructors sets you up for future puzzling bugs. my $str = q{$line}; This is a meaningless statement; it just assigns a literal $line to a string:
my $str = qr{$line}; The problem here is that you seem to be trying to make the entire line you've just read from the file into a pattern. You then remove a piece of the pattern with a substitution: Do you see where the extraneous (?^: ... ) stuff comes from? Useless use of non-destructive substitution (s///r) in void context
You have to use a s///r substitution in a statement like Update: Changed variable names in last code example to (hopefully!) clarify the point being made. Give a man a fish: <%-{-{-{-<
In Section
Seekers of Perl Wisdom
|
|