Re: correctly rebuilding a whitespace-split string

2002-10-15 Thread Jasper McCrea
Bart Lateur wrote: > > On Tue, 15 Oct 2002 17:14:39 +0100, Jasper McCrea wrote: > > >Why not just: > > > >s/(\s+\S+){4}\s*$//; > > > >$1 for the chopped stuff. > > $1 contains the last "word" and preceding whitespace. For every match, > the captured value overwrites the previous one. You need p

Re: correctly rebuilding a whitespace-split string

2002-10-15 Thread Ronald J Kimball
On Tue, Oct 15, 2002 at 04:08:41AM +, Ton Hospel wrote: > In article <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] writes: > > En op 15 oktober 2002 sprak Aaron Mackey: > >> @d = splice(split, -4); # I always know that the last 4 fields > > > > This won't compile (first argument to splice mu

Re: correctly rebuilding a whitespace-split string

2002-10-15 Thread Bart Lateur
On Tue, 15 Oct 2002 17:14:39 +0100, Jasper McCrea wrote: >Why not just: > >s/(\s+\S+){4}\s*$//; > >$1 for the chopped stuff. $1 contains the last "word" and preceding whitespace. For every match, the captured value overwrites the previous one. You need parens around it all to capture the lot.

Re: correctly rebuilding a whitespace-split string

2002-10-15 Thread Jasper McCrea
Bart Lateur wrote: > > On Mon, 14 Oct 2002 20:19:10 -0400 (EDT), Aaron J Mackey wrote: > > >Someone have a more "perlish", elegant, or just plain faster way of doing > >something like this: split a string on white space, pop off the last 4 > >fields (perhaps to be used elsewhere), and then "rebu

Re: correctly rebuilding a whitespace-split string

2002-10-15 Thread Bart Lateur
On Tue, 15 Oct 2002 18:08:57 +0200, Bart Lateur wrote: >You mean with the same amount of whitespace as before? None of the >solutions I've seen does that. Oops. Some do. -- Bart.

Re: correctly rebuilding a whitespace-split string

2002-10-15 Thread Bart Lateur
On Mon, 14 Oct 2002 20:19:10 -0400 (EDT), Aaron J Mackey wrote: >Someone have a more "perlish", elegant, or just plain faster way of doing >something like this: split a string on white space, pop off the last 4 >fields (perhaps to be used elsewhere), and then "rebuild" the original >string with t

RE: correctly rebuilding a whitespace-split string

2002-10-15 Thread Patrick Connolly
$_ = "1 2 3 4 5 6 7 8 9 0"; /(.*)(\s.*){4}/; print "$1\n"; -Original Message- From: Aaron J Mackey [mailto:[EMAIL PROTECTED]] Sent: Monday, October 14, 2002 7:19 PM To: [EMAIL PROTECTED] Subject:correctly rebuilding a whitespace-split string Someone have a more "perlis