#!usr/bin/perl -w use strict; my @array=(34,52,67,3,66); is_value_gt_min_array_element(5,\@array) ? print "yes, 5 is greater than @array\n" : print "no, 5 isn't greater than: @array\n"; is_value_gt_min_array_element(3,\@array) ? print "yes, 3 is greater than @array\n" : print "no, 3 isn't greater than: @array\n"; is_value_gt_min_array_element(2,\@array) ? print "yes, 2 is greater than @array\n" : print "no, 2 isn't greater than: @array\n"; sub is_value_gt_min_array_element { my ($value, $arrayref) = @_; foreach (@$arrayref) { return 1 if ($value > $_); #this is a "found it!" #stop searching for another one } return 0; } print "There are ", scalar(grep{$_>3}@array), " numbers ", "greater than 3 in: @array\n"; __END__ prints: yes, 5 is greater than 34 52 67 3 66 no, 3 isn't greater than: 34 52 67 3 66 no, 2 isn't greater than: 34 52 67 3 66 There are 4 numbers greater than 3 in: 34 52 67 3 66