Help for this page

Select Code to Download


  1. or download this
    $x = "There once was a girl\nWho programmed in Perl\n"; 
    $x =~ /^Who/; # doesn't match, "Who" not at start of string 
    $x =~ /^Who/s; # doesn't match, "Who" not at start of string 
    ...
    $x =~ /girl.Who/s; # matches, "." matches "\n" 
    $x =~ /girl.Who/m; # doesn't match, "." doesn't match "\n" 
    $x =~ /girl.Who/sm; # matches, "." matches "\n"
    
  2. or download this
    $x =~ /^Who/m;   # matches, "Who" at start of second line
    $x =~ /\AWho/m;  # doesn't match, "Who" is not at start of string
    ...
    $x =~ /girl\Z/m; # doesn't match, "girl" is not at end of string
    $x =~ /Perl\Z/m; # matches, "Perl" is at newline before end
    $x =~ /Perl\z/m; # doesn't match, "Perl" is not at end of string