Dan Muey wrote:
> 
> IS there a better way to perhaps assign the value of $1 back to $var all in one 
>statement?

Yes.

> EG
> 
> $var = 'hello.domain.com';
> # Instead of this ::
> $var =~ m/((\w+)\.(\w+)$)/; # $1 then becomes 'domain.com'
> $var = $1; # then $var becomes 'domain.com'
> # Perhaps a one liner version?
> 
> I know there's a way but it's Monday :(


($var) = $string =~ /(\w+\.\w+)$/;

Note that you need the parenthesis around $var to force list context
because the result of a match in scalar context returns 'true' or
'false'.



John
-- 
use Perl;
program
fulfillment

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

Reply via email to