in reply to returning variable from within regex

You can do this using $1..$n variables.
elsif($var1=~/($var2[a-z]{1})/){ $var3 = $1; }

NOTE: You also had a syntax error in the elsif statement. You were missing right paren.

Replies are listed 'Best First'.
Re: Re: returning variable from within regex
by diotalevi (Canon) on Aug 29, 2003 at 19:15 UTC

    That {1} is not needed and the variable names need to be descriptive - @var2 and $var1 are not meaningful.