#!/usr/bin/perl use warnings; use strict; use diagnostics; my $infile = $ARGV[0]; my @regexes = (qr/§\s*[0-9]/, qr/Art\.\s*[0-9IVX]/, qr/Artikel\s*[0-9IVX]/, qr/Artikels\s*[0-9IVX]/, qr/Artikeln\s*[0-9IVX]/); open my $in, '<', $infile or die "Cannot open $infile for reading: $!"; my $xml; { local $/ = undef; $xml = <$in>; } my $tally; for my $i (0 .. $#regexes) { my $regex = $regexes[$i]; ++$tally[$i] while $xml =~ /$regex/g; } for my $i (0 .. $#regexes) { print "$regexes[$i]:\t$tally[$i]\n"; } close $in; #### Global symbol "@tally" requires explicit package name (did you forget to declare "my @tally"?) at monk2.pl line 24. Global symbol "@tally" requires explicit package name (did you forget to declare "my @tally"?) at monk2.pl line 28. Execution of monk2.pl aborted due to compilation errors (#1) (F) You've said "use strict" or "use strict vars", which indicates that all variables must either be lexically scoped (using "my" or "state"), declared beforehand using "our", or explicitly qualified to say which package the global variable is in (using "::"). Uncaught exception from user code: Global symbol "@tally" requires explicit package name (did you forget to declare "my @tally"?) at monk2.pl line 24. Global symbol "@tally" requires explicit package name (did you forget to declare "my @tally"?) at monk2.pl line 28. Execution of monk2.pl aborted due to compilation errors. #### (?^:§\s*[0-9]): 3 (?^:Art\.\s*[0-9IVX]): 2 (?^:Artikel\s*[0-9IVX]): 2 (?^:Artikels\s*[0-9IVX]): 2 (?^:Artikeln\s*[0-9IVX]): 2