[Omaha.pm] Fwd: weird perl bug

Jay Hannah jhannah at mutationgrid.com
Thu Nov 18 13:09:27 PST 2010


Forwarding w/ Trey's permission.

Jay Hannah
Software Architect
jhannah at mutationgrid.com | http://mutationgrid.com | 1-402-598-7782



From: "Trey Bianchini" <wbia... at omnihotels.com>
Date: November 10, 2010 2:31:32 PM CST
To: <jhannah at mutationgrid.com>
Subject: weird perl bug


Jay, I know you like things like this so


======================================================
use strict;

my $nc='JANE WELK';
my $tc='JANE WELK';

my $tmp_one_name='JANE';
my $tmp_two_name='WELK';


print "WELCOME\n" if ( ${nc} =~ /$tmp_two_name/g );
print "TO\n"      if ( ${tc} =~ /$tmp_one_name/g );

print "BIZZARO\n" if ( ${nc} =~ /$tmp_one_name/g );
print "LAND\n"    if ( ${nc} =~ /$tmp_two_name/g );


========================================================


It seems when I'm evaluating a scalar containing a string  I use scalars
for patterns in the regex, that when I match against the back of the
string and then try to use the same scalar and match against the front
of the string My match fails.

The first two print statements are my most unsatisfying workaround
The third  print statement illustrates the bug.

Here is the output
===================


omares-dev3>perl -v

This is perl, v5.10.0 built ...
...
Page.

omares-dev3>perl ./woah
WELCOME
TO
LAND



More information about the Omaha-pm mailing list