use strict;
use warnings;
use Data::Dumper;
sub one {
return undef;
}
sub two {
my @a = @_;
print Dumper(\@a);
return;
}
two(1,2,one(), 3);
####
$VAR1 = [1,2,undef,3];
$VAR1 = [1,2,3];
####
sub read_file {
my $file = shift;
-f $file || return undef; #file doesn't exist!
#Continue reading file...
}
#and later...
if ( my @data = read_file($filename) ){
# if $filename doesn't exist,
# @data will be (undef),
# but I'll still be in here!
process(@data);
}
else{
# This is my error handling code.
# I probably want to be in here
# if $filname doesn't exist.
die "$filename not found";
}
####
sub read_file {
my $file = shift;
-f $file || return; #DWIM!
#Continue reading file...
}