[Seattle-SAGE] Re: [SLL] Need perl help - regex issue

Ski Kacoroski kacoroski at comcast.net
Mon Oct 24 15:31:05 PDT 2005


Thanks to everyone for the help.  Sorry about the feeble attempt at 
explaining my problem.  I misunderstood how scope worked with the $1.. 
variables (thought they would be reset when a subroutine was called for 
some reason).  So what I need to do is what Jules and Ben suggested and 
check the return of the match to be sure something was matched, e.g.

sub test { $f = "first_in_sub"; if ($f =~ /(.*)\s.*$/) { print $1;}}

What I am doing is stripping out everything after the first space in a 
name ("Kacoroski Jr." -> "Kacoroski" or "Kacoroski III" -> "Kacoroski").

Thanks also to Tim for the pointer to spug-list at pm.org and to Tim and 
Ben on the idea of a stingy match.  My code will soon be updated.



"When we try to pick out anything by itself, we find it
  connected to the entire universe"            John Muir

Chris "Ski" Kacoroski, kacoroski at comcast.net, 206-501-9803

More information about the Members mailing list