for my $param (grep {defined} @_) { for my $val ( split /\n/, $param ) { print "The value is: $val\n"; # or whatever you want to do } }