[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] OT: interpolation and anchors in perl regex
- Subject: [ale] OT: interpolation and anchors in perl regex
- From: brian at polibyte.com (Brian Pitts)
- Date: Sat, 18 Oct 2008 18:52:32 -0400
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