This outputs "size = 2". If I use the second way of clearing the contents of the array (commented out), then that works as expected "size = 0". This seems like a perl idiosyncrasy. Is there a simple explanation for this?sub clear_it { my($data) = @_; $data = []; #@$data = (); } my $data = ['a','b']; &clear_it($data); print "size = ",($#$data + 1),"\n";
In reply to Pass array, then clear by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |