There's no need at all to change the original string to extract the data you want. All you need is to match it.
or even simpler:if($line =~ /^(\S+\s+\S+)/) { $match = $1; }
Note that for the latter, the assignment must be in list context, not scalar context; that's what the parens around the variable on the left hand side are for.($match) = $line =~ /^(\S+\s+\S+)/;
In reply to Re^3: How regex works here?
by bart
in thread How regex works here?
by nagalenoj
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |