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

[Omaha.pm] Fwd: weird perl bug



Forwarding w/ Trey's permission.

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



From: "Trey Bianchini" <wbia...@omnihotels.com>
Date: November 10, 2010 2:31:32 PM CST
To: <jhannah@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