LA.pm: Quotes

Douglas Wilson dgwilson at gtemail.net
Thu Oct 18 15:59:55 CDT 2001


From: Arkadiy Sudarikov <asudarikov at xceed.com>

> Thanks, ya all. But what to do if my " is in regex (pattern-matching)?

Its *nix, right (Windows has much stranger command
line quoting requirements)??

# print lines containing single or double quotes
perl -n -e "print if /['"\""]/"

The first single quote is inside double quotes,
so its safe.

The first double quote terminates
the first part of the -e argument.

The second double quote is escaped, so
it becomes a literal part of the -e expression
(as long as there's no whitespace, the
argument continues).

The third double quote starts the next part
of the -e argument. And you know what the
last double quote does.

Another possible option is a here doc:

perl <<EOT
# Set filelist
@ARGV=qw(tmp.txt another_file.txt);
while(<>) {
 print if /['"]/;
}
EOT


-Doug
-- 

_______________________________________________
Talk More, Pay Less with Net2Phone Direct(R), up to 1500 minutes free! 
http://www.net2phone.com/cgi-bin/link.cgi?143 






More information about the Losangeles-pm mailing list