> I've tried placing [ ] around each variable,

Stop, don't run and read "perlre" before you trying to use any special
regex characters.

When you put characters inside [] it means "any character" and it doesn't mean
"the whole word"
[abcd]  = "a or b or c or d" and not "abcd"

> using the || operator between

Did you mean the '|' operator ? ;)

C:\>perl -w
$line  = "Joe Doe 123 Main St. Sometown, USA";
$fname = "Joe";
$lname = "Doe";
$addr  = "123 Main St.";
$line  =~ s/$fname|$lname|$addr|\s//g;
print "[$line]\n";
^Z
[Sometown,USA]

C:\>

And, yeah, don't forget using \Q and \E around your variables.
( not around the whole regex - you'll disable the '|' by this )


Reply via email to