well, i don't see mention of why you couldn't pre-process the data (I also don't see code for that matter : ), but what you could do is strip off the starting space and trailing space first and then feed it to split. You may also want to note that you don't need the /g in the regex for split.
which then does:use strict; my $string = ' this that other '; $string =~ s/^\s+//; $string =~ s/\s+$//; my ($one, $two, $three) = split /\s+/, $string; print "$one\n$two\n$three\n\n";
/home/jptxs > perl -w stripNsplit this that other /home/jptxs >
"sometimes when you make a request for the head you don't
want the big, fat body...don't you go snickering."
-- Nathan Torkington UoP2K a.k.a gnat
In reply to Re: uses of split
by jptxs
in thread uses of split
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |