sub process { my $alert = shift; print "$_" for @$alert; # Or (since I'm not sure what you're doing with this) for my $line (@$alert) { # process $line of alert } } #### if (@alert) { process(@alert) }