my $machine_class = ($str =~ /MACHINE_CLASS=\s*(\w*)/);
Perl sees you are setting a scalar, and so interprets the right hand side in that context. Since the right hand side is a list, it assigns the size of the list (1) to $machine_class. You can put the assignment in list context by wrapping your variable in parentheses:
my ($machine_class) = ($str =~ /MACHINE_CLASS=\s*(\w*)/);
See Extracting matches in perlretut. You can read more about context in Perl in Context in perldata or Context tutorial from the Tutorials.
In reply to Re: @ Regular Expression
by kennethk
in thread @ Regular Expression
by siddheshsawant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |