CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: there is just a difference of /i in regular expression assigned to $a and it is producing different outputs.Why?: Edit Log



shreyas_007
New User

Jan 30, 2018, 8:57 PM


Views: 4254
there is just a difference of /i in regular expression assigned to $a and it is producing different outputs.Why?

#first case
$string = "Cats go Catatonic\nWhen given Catnip";
$a = ($string =~ /when/igm );
($b) = ($string =~ /when/igm );
print "$a and $b \n";

#output for above is
1 and

#second case
$string = "Cats go Catatonic\nWhen given Catnip";
$a = ($string =~ /when/gm ); #here is the only difference
($b) = ($string =~ /when/igm );
print "$a and $b \n";

#output for this is
and When

#the first program does not print the value of $b where as the second #program does.


(This post was edited by shreyas_007 on Jan 30, 2018, 8:59 PM)


Edit Log:
Post edited by shreyas_007 (New User) on Jan 30, 2018, 8:59 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives