in reply to using push

You have to make sure that @thescore is declared outside of the loop. Otherwise, Perl, and nearly any other programming language, will see @thescore as having a local scope inside the loop only. Also, repeat the typical PM manta of using warnings and strict to run your code.

#!/usr/bin/perl -w use strict; ... my @thescore = (); #declare and initialize the array if ( $score > 12 ) && ( $score < 100 ){ push @thescore, $_}; ... }

Also, in your code in the loop is looking for a variable called $thescore. The value you are trying to print will be in $_ instead. Here you can do two different things.

foreach (@thescore) { print "$_\n"; }

or

foreach my $thescore(@thescore) { print "$thescore\n"; }