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
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
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.
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
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.
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
$_ = "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