[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ale] OT: interpolation and anchors in perl regex



Can someone explain why the last one doesn't match?

$ perl -e '$bar = "hello_world"; print "yes\n" if $bar =~ /^hello_world$/;'
yes

$ perl -e '$foo = "hello"; $bar = "hello"; print "yes\n" if $bar =~
/^$foo$/;'
yes

$ perl -e '$foo = "hello"; $bar = "hello_world"; print "yes\n" if $bar
=~ /$foo_world/;'
yes

brian at triangle:~$ perl -e '$foo = "hello"; $bar = "hello_world"; print
"yes\n" if $bar =~ /^$foo_world/;'
yes

$ perl -e '$foo = "hello"; $bar = "hello_world"; print "yes\n" if $bar
=~ /$foo_world$/;'
yes

$ perl -e '$foo = "hello"; $bar = "hello_world"; print "yes\n" if $bar
=~ /^$foo_world$/;'

Thanks,
Brian