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

Re: [Omaha.pm] RE: wrong




On Aug 26, 2004, at 11:35 AM, Jay Hannah wrote:
my ($lname, $fname) = ($res->get_gst_name =~ /^(\w+)(,|\/)(\w+)$/);

what's wrong with this?


Ya. That's bad. The , or / will be stuck in $fname.

Perhaps:   #^(.*?)[,/](.*)$#

Whoops. I was told that doesn't work. Probably because if you choose to change // to ## you have to specify the s (substitute) or m (match) explicitly.

$ cat j.pl
#!/usr/bin/perl
$_ = "Hannah, Jay";
($lname, $fname) = m#^(.*?)[,/](.*)$#;
print "[$lname][$fname]\n";

$ ./j.pl
[Hannah][ Jay]

That's better. But still not right, since the leading space in $fname doesn't go away.

What this problem needs is Test::Simple and 50 tests. -grin-

j