"R. Joseph Newton" wrote: > > Dan Muey wrote: > > > IS there a better way to perhaps assign the value of $1 back to $var all in one >statement? > > 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? > > Wouldn't the substitution operator do what you are trying to do here? > $var =~ s/.*((\w+)\.(\w+)$)/$1/;
No that won't work because the .* at the beginning is greedy. $ perl -le' $string = "-=-=-=-=-abc.def"; ($var) = $string =~ /(\w+\.\w+)$/; print $var; ( $var = $string ) =~ s/.*((\w+)\.(\w+)$)/$1/; print $var; ' abc.def c.def John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]