
Untitled
By: a guest on
Aug 9th, 2012 | syntax:
None | size: 0.82 KB | hits: 9 | expires: Never
What Perl matching regexp nuances can cause headaches?
if( $key =~ /upsf|free|ground|sla|pickup|usps/ )
if( $key eq 'upsf' || $key eq 'free'
|| $key eq 'ground' || $key eq 'sla'
|| $key eq 'pickup' || $key eq 'usps' )
$key = 'upsf';
if( $key =~ /^(upsf|free|ground|sla|pickup|usps)$/ ) {
print 'ship it';
} else {
print 'shelf it';
}
$key = 'xxx';
if( $key =~ /upsf|free|ground|sla|pickup|usps/ ) {
print 'ship it';
} else {
print 'shelf it';
}
if ($key =~ /^(?:upsf|free|ground|sla|pickup|usps)$/) {
# ...
} else {
# ...
}
$custom_script_code =~ s/`/'/gs;
$custom_script_code =~ s/||/%7C%7C/g;
$custom_script_code =~ s/|/ /gs;
$custom_script_code =~ s/%7C%7C/||/g;
$custom_script_code =~ s/system/System/gs;
$custom_script_code =~ s/exec/Exec/gs;
$custom_script_code =~ s/die/Die/gs;