use strict; my $input = <>; chomp $input; my @test_array = qw(1 2 3 4 5 6 7 8 9); if ( member($input, \@test_array) ) { print "Hey, there's one of those in there!\n\n"; } else { print "Better luck next time: it's not in there.\n\n"; } sub member { my $possible = $_[0]; my $array_ref = $_[1]; foreach my $member ( @{$array_ref} ) { if ( $member eq $possible ) { return "1"; } } return "0"; }