On Thu, 10 Feb 2005, Jos Backus wrote:

> Given Perl's
> 
>     $_ = "123 foo";
> 
>     s/^(\d+)\s+//;
>     $pid = $1;
> 
>     print "$_\n$pid\n";
> 
> all I can come up with is
> 
>     line = "123 foo"
> 
>     pid = nil
>     line.sub!(/^(\d+)\s+/) {pid = $1; ''}
> 
>     puts line, pid
> 
> Is there a better way perhaps?
 
irb(main):001:0> $_='123 foo'
=> "123 foo"
irb(main):002:0> puts (sub(/(\d+)\s*/,'')),$1
foo
123
=> nil


-- 
Wybo