mrt has asked for the wisdom of the Perl Monks concerning the following question:
This is very simple but I am not able to make it work..I have
a string and I want to get only the fourth field which
is delimited by space (although the first field may or may not have space before it
before it starts..I want to get the fourth field as
fast as possible as I have to do it many times..
but I am not ablre to get it..$_="one two three four five six"; #it may be also be $abc=" one two three four five six" ($fieldfour)=/[^\s+]*\s+[^\s+]*\s+[^\s+]*\s+[^\s+]/; print "\n the fourth field is $fieldfour \n"; exit(0);
|
---|
Replies are listed 'Best First'. | |
---|---|
(ar0n: split methinks) Re: novice
by ar0n (Priest) on Sep 27, 2000 at 13:35 UTC | |
by mrt (Acolyte) on Sep 27, 2000 at 14:19 UTC | |
by ar0n (Priest) on Sep 27, 2000 at 14:36 UTC | |
by Jouke (Curate) on Sep 27, 2000 at 14:42 UTC | |
by dchetlin (Friar) on Sep 27, 2000 at 22:11 UTC | |
(Dermot) Re: novice
by Dermot (Scribe) on Sep 27, 2000 at 14:48 UTC |
Back to
Seekers of Perl Wisdom