Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Problem with strict "refs"

by fletcher_the_dog (Friar)
on Sep 22, 2003 at 20:04 UTC ( [id://293266]=note: print w/replies, xml ) Need Help??


in reply to Problem with strict "refs"

Your main problem is that your are trying to create a hash by directly accessing the symbol table for hashes. This is not usually something you should do unless you know what you are doing and in fact is guarded against by using "use strict". You can do the same thing that you are trying to do by create a hash that holds your "LocalTran" types". Like This:
use strict; use warnings; my %LocalTrans; my (@unix_data,@nt_data); open LOG, "nt_data.txt" or die "Cannot open unix_data.txt $!"; while (<LOG>) { chomp; my $hashname; my @keysandvalues; my @field = split /,/, $_; foreach (@field) { my ($key, $value) = split /\s*=\s*/, $_; if ($key =~ /^(LocalTran)(\w*)(Number)$/) { $hashname=$value; } push @keysandvalues, $key; push @keysandvalues, $value; } %{$LocalTrans{$hashname}}=@keysandvalues; } foreach my $LT (keys %LocalTrans) { print "-+" x 90 . "\n"; foreach my $key (keys %{$LocalTrans{$LT}) { print "$key => $LocalTrans{$LT}{$key}\n"; } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://293266]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2024-04-16 11:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found