Oops! This is a group match. Seeing nextthere, possibly in a loop. However, the best way to handle what you have is to use a conditional expression and test the regular expression:
if ( $line =~ /^(\d+)\s/ ) {
$paperAnnot{$1} = $line;
}
or even better, give $ 1 a name to make it self-documenting:
if ( $line =~ /^(\d+)\s/ ) {
my $index = $1;
$paperAnnot{$index} = $line;
}
In addition, you can find more about $1and his brothers at perldoc perlvar .
Perl 5.10 :
use 5.010;
...
if ( $line =~ /^(?<linenum>\d+)\s/ ) {
$paperAnnot{ $+{linenum} } = $line;
}
perldoc perlre.