"perl help"
Hi all,
How to select the first word from a scalar variable. ex: $a = "Hi all" :study: |
There's a million solutions to this problem, depending on what you're going to do afterwards - you may use split for example and put all words into an array or use a reg ex and just grab the first word ..
@allwords = split(' ', $yourscalar); <-- split at spaces print $allwords[0]; <-- just the first word ($firstword) = ($yourscalar =~ m/(\w+)/); <-- match first word, capture it and put it into $firstword Something like this... |
Thanks all i got the answer.....
|
:)Thanks all i got the answer.....
|
The mantra in Perl-land is "TMTOWTDI" = There's More Than One Way To Do It.
:rolleyes: |
All times are GMT -5. The time now is 05:35 PM. |