in reply to Create Arrays On-the-Fly
You can have an array of hash refs instead.
@clients = ( { MAC => $mac, RSSI => $rssi, SNR => $snr }, /* 0 */ { MAC => $secondmac, RSSI => $secondrssi, SNR => $secondsnr }, /* +1 */ /* etc */ );
Then you can grab the bits like
%client_0 = %{$clients[0]};
etc.
To build it on the fly, you'd have code like:
my @clients; # The whole hash at once $clients[0] = { MAC => $mac, /* ... */ }; # Or setting individual bits $clients[0]->{MAC} = $mac;
This is pretty well covered in the documentation, such as in perlreftut and perldsc.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Create Arrays On-the-Fly
by spickles (Scribe) on Aug 26, 2009 at 15:27 UTC | |
by fullermd (Vicar) on Aug 27, 2009 at 04:39 UTC | |
by fullermd (Vicar) on Aug 27, 2009 at 04:37 UTC |