www.perl.com
Perl Programming
Regular Expressions
  • Perl has several regex operators
    • m just matches, providing boolean context
    • s/match/replacement/ substitutes
    • tr/class/replacement/ transliterates

        my $string = "Did the fox jump over the dogs?";
        $string =~ s/dog/cat/;              # substitute "cat" for "dog"
        $string =~ s(fox)(kangaroo);        # substitute "kangaroo" for "fox"
        print "$string\n";

        $string =~ tr/a-z/n-za-m/;          # Rot13
        print "$string\n";
      

        Did the kangaroo jump over the cats?
        Dvq gur xnatnebb whzc bire gur pngf?
      
http://stuff.mit.edu/iap/perl/