0: 12; @counts = (0) 1: 34; @counts = (0) 2: 56; @counts = (0) @main::counts = (6) #### #!/usr/bin/perl use strict; use warnings; use re qw/eval /; my $line = 'ab'; my $pattern = q/(.)(?{print ++$counts[0]})^/; for (0..2) { my @counts = (0); print "$_: "; $line =~ /$pattern/; print "; my \@counts = (@counts)\n"; } { no strict; no warnings; print "our \@counts = (".join(",",@counts).")\n"; #print "our \@counts = (@counts)\n"; } #### In string, @counts now must be written as \@counts at .\counts.pl line 22, near "our \@counts = (@counts" Execution of .\counts.pl aborted due to compilation errors.