Instead of using a regular expression you might prefer trying a grammar engine like:
I've given a snippet of a Parse::ResDescent answer before on SO. However Regexp::Grammars looks very interesting and is influenced by Perl6 rules & grammars.
So I thought I'd have a crack at Regexp::Grammars ;-)
use strict;
use warnings;
use 5.010;
my $text = q{
Name=Value1
Name = Value2
Name=Value3
};
my $grammar = do {
use Regexp::Grammars;
qr{
<[VariableDeclare]>*
<rule: VariableDeclare>
<Var> \= <Value>
<token: Var> Name
<rule: Value> <MATCH= ([\w]+) >
}xms;
};
if ( $text =~ $grammar ) {
my @Name_values = map { $_->{Value} } @{ $/{VariableDeclare} };
say "@Name_values";
}
The above outputs "Value1 Value2 Value3".
Very nice! The only caveat is that is needs Perl 5.10 and that it maybe an overkill for the example you provided ;-)
/I3az/