On Aug 16, 2011 9:48 PM, "John W. Krahn" <jwkr...@shaw.ca> wrote:
>
> Joseph L. Casale wrote:
>>
>> What is the correct way to quickly assign the result of a regex against
>> a cmdline arg into a new variable:
>>
>> my $var = ($ARGV[0] =~ s/(.*)foo/$1/i);
>
>
> my ( $var ) = $ARGV[0] =~ /(.*)foo/i;

IIRC, that rederines $ARGV as well. I think (my $var = $ARGV) =~ /(.+)foo/;
might be better.

Reply via email to