#!/usr/local/bin/perl -w #In each case, predict what the output will be. #Then uncomment each line that's commented out #and comment the previous line. What will the #output be now? #Example 1 $string = "Perl is superlative to other languages"; @matches= $string =~ /Perl/g; #@matches = $string =~ /Perl/ig; print "@matches\n"; #Example 2 $phrase = "Do not go gently into that dark night\nRage, Rage\nAgainst the dying of the light"; @firsts = $phrase =~ /^(\w+)/g; #@firsts = $phrase =~ /^(\w+)/gm; print "@firsts\n"; @lasts = $phrase =~ /(\w+)$/g; #@lasts = $phrase =~ /(\w+)$/gm; print "@lasts\n"; #Example 3 $longline = "123\nHello\n432\nGoodbye\n"; @nums = $longline =~ /(\d+)./g; #@nums = $longline =~ /(\d+)./sg; print "@nums\n"; #Example 4 $string = "ab de fd ac rd ad"; $var = "aa"; for (1..10){ print "$var: "; print "$1 found in $string" if $string =~ /($var)/; # print "$1 found in $string" if $string =~ /($var)/o; print "\n"; $var++; }