in reply to Regular Expression Question !!!

try this:

print map {"$_\n"} ($str=~/\w+=/g);

If you want to make sure that there is a "&" following the "=" sign, you can do this instead:

my $out=''; while ($str=~/(\w+=)\&/g){$out.=sprintf "%s\n",$1}; print $out;
print map {"$_\n"} ($str=~/(\w+=)\&/g); #Thanks nferraz

Hope this helps!

citromatik

Replies are listed 'Best First'.
Re^2: Regular Expression Question !!!
by nferraz (Monk) on Jun 20, 2007 at 10:46 UTC
    You don't have to iterate to get each variable; just put the returned values into an array:
    my @variables = $str =~ /(\w+\=)\&/g; print "$_\n" foreach @variables;