fork download
  1. #!/usr/bin/perl -w
  2. # coding: UTF-8
  3.  
  4. use strict;
  5. use warnings;
  6.  
  7. use Data::Dumper;
  8.  
  9. my @a = ( 0, undef, 2 );
  10. dump_array( @a );
  11. dump_array( 0, undef, 2 );
  12.  
  13. sub dump_array
  14. {
  15. my @in = @_ ;
  16. print Dumper(\@in);
  17.  
  18. for (my $i = 0; $i < @in; $i++) {
  19. print "item $i exists: ", exists $in[$i] ? 'yes' : 'NO', "\n";
  20. }
  21. print "\n";
  22. }
  23. 1;
  24.  
Success #stdin #stdout 0.01s 5164KB
stdin
Standard input is empty
stdout
$VAR1 = [
          0,
          undef,
          2
        ];
item 0 exists: yes
item 1 exists: yes
item 2 exists: yes

$VAR1 = [
          0,
          undef,
          2
        ];
item 0 exists: yes
item 1 exists: yes
item 2 exists: yes