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? Use split over a regex when you can: pid, line = "123 foo".split puts pid puts line Also keep in mind that 'pid' is currently still a string, not a number (if that matters to you). Regards, Dan