On Tue, 13 Nov 2001, A. Rivera wrote:

> I need help find the most effecient way to do this..
>
> I have a variable...
> $data="this is a test";
>
> What is the quickest way to get $data to equal just the first two words of
> the original variable....

This splits the string up, extracts the first two words, and joins them
again and re-assigns to $data:

$data = join(" ", (split(/\s/, $data))[0..1]);

-- Brett
                                          http://www.chapelperilous.net/
------------------------------------------------------------------------
Everything should be built top-down, except this time.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to