in reply to Re: Anon Struct Instance
in thread Anon Struct Instance

Ah, so basically, you're trying to assign the DEVICE to a symbolically referenced scalar, whose name is coming from $entry[3]. I would recommend against doing this, and for using a hash instead, to store these DEVICEs. Like this:
$devices{$sn} = new DEVICE; $devices{$sn}->datetime{$datetime}; # etc.
If you rearranged your data slightly, you could get rid of one hash.
# I've snipped out what I consider to be the important bits... # Warning: This is untested code! # First, store the sn count inside the DEVICE, since we have one DEVIC +E per $sn struct ( DEVICE => { datetime => '$', devicetype => '$', zip => '$', v +ersion => '$', sn_count => '$'}); # Get the $sn and other fields here # If this is the first time we see $sn, populate the DEVICE if (!exists $SNs{$sn}) { $SNs{$sn} = new DEVICE; $SNs{$sn}->datetime('$datetime'); # etc. } # update the sn_count for this $sn. $SNs{$sn}->sn_count($SNs{$sn}->sn_count + 1); foreach my $key (keys %SNs) { print "$key\n"; }
What is your motivation for storing things in symbolically referenced scalars instead of hash elements?

Alan