in reply to pointers == arrayrefs ?
This dies unpredictably (varying number of iterations and at different addresses), eg:#!/usr/bin/perl use warnings; use strict; my %seen; for (0...1000) { my $a = [0..sprintf("%d", 1 + rand(20))]; die "$_ iteratations: I've already seen $a" if exists $seen{$a}; $seen{$a} = 1; }
However, if I change the last line to8 iteratations: I've already seen ARRAY(0x180bc0c) at at1.pl line 9.
..then my program does run to completion.$seen{$a} = $a; # capture the reference
Addresses are unique when arrays are current. But they may become invalid and/be reused when arrays go out of scope.
|
|---|