#!/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 the previous line { last; #Example 1 $string = "Perl is superlative to other languages"; #@matches= $string =~ /Perl/g; @matches = $string =~ /Perl/ig; print "@matches\n"; } { last; #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"; } { #last; #Example 3 $longline = "123\nHello\n432\nGoodbye\n"; #@nums = $longline =~ /(\d+)./g; @nums = $longline =~ /(\d+)\n/g; print "@nums\n"; } { last; #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++; } }