[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Omaha.pm] RE: wrong
I actually like your new way:
($lname, $fname) = m#^(.*?)[,/]\s+(.*)$#;
Somehow, it's much easier to read for me.....
>
> 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
>
> _______________________________________________
> Omaha-pm mailing list
> Omaha-pm@mail.pm.org
> http://www.pm.org/mailman/listinfo/omaha-pm
>
>
Patrick Baker
Programmer
(402) 952-6508
pbaker@omnihotels.com