use strict; use warnings; use Data::Dumper; use feature 'say'; my @array = qw( 1 2 3 ); my @secondary = qw ( 4 ); sub check { my ($arrayref) = @_; foreach my $element (@$arrayref){ say $element; return 'Found' if ($element eq 3); } return 'Not Found' } say check( \@array ); say check( \@secondary ); __END__ 1 2 3 Found 4 Not Found