Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 9th, 2012  |  syntax: None  |  size: 0.82 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. What Perl matching regexp nuances can cause headaches?
  2. if( $key =~ /upsf|free|ground|sla|pickup|usps/ )
  3.        
  4. if( $key eq 'upsf' || $key eq 'free'
  5.     || $key eq 'ground' || $key eq 'sla'
  6.     || $key eq 'pickup' || $key eq 'usps' )
  7.        
  8. $key = 'upsf';
  9. if( $key =~ /^(upsf|free|ground|sla|pickup|usps)$/ ) {
  10.     print 'ship it';
  11. } else {
  12.     print 'shelf it';
  13. }
  14.        
  15. $key = 'xxx';
  16. if( $key =~ /upsf|free|ground|sla|pickup|usps/ ) {
  17.     print 'ship it';
  18. } else {
  19.     print 'shelf it';
  20. }
  21.        
  22. if ($key =~ /^(?:upsf|free|ground|sla|pickup|usps)$/) {
  23.   # ...
  24. } else {
  25.   # ...
  26. }
  27.        
  28. $custom_script_code =~ s/`/'/gs;
  29. $custom_script_code =~ s/||/%7C%7C/g;
  30. $custom_script_code =~ s/|/ /gs;
  31. $custom_script_code =~ s/%7C%7C/||/g;
  32. $custom_script_code =~ s/system/System/gs;
  33. $custom_script_code =~ s/exec/Exec/gs;
  34. $custom_script_code =~ s/die/Die/gs;