fork download
  1. #!/usr/bin/perl
  2.  
  3. # Idiom #264 Automated passing of array bounds
  4.  
  5. sub foo {
  6. my ($a) = @_;
  7. return scalar @{ $a }, scalar @{ $a->[0] };
  8. }
  9.  
  10. my $a = [[1,2,3], [4,5,6]];
  11. printf "%d %d\n", foo($a);
  12.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
2 3