in reply to Can't use string "1" as a HASH ref while "strict refs" in use

It's trying to tell you one of the following; either $sw_ctype_brkdown{$switchnum}{$calltype} = 1; or $sw_ctype_brkdown{$switchnum} = 1; It's impossible to tell which at this point. In any case, you're treating something as a hash reference which is really the number 1. Data::Dumper might be your friend in this case, to help track down what your data structure actually looks like.

perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'

Replies are listed 'Best First'.
Re: Re: Can't use string "1" as a HASH ref while "strict refs" in use
by GhodMode (Pilgrim) on Mar 04, 2002 at 20:54 UTC
    $sw_ctype_brkdown{$switchnum}{$calltype} does equal 1, it's an increme +nted count of how many lines in a file I'm parsing have that $switchn +um and that $calltype. The $switchnum and $calltype are defined right before the problem line + with a substr of a line in the file. I want to be able to get a count of how many lines there are with that + $switchnum $calltype using print "$sw_ctype_brkdown{$switchnum}{$calltype}\n"; and the number of seconds for that $switchnum and $calltype using print "$sw_ctype_brkdown{$switchnum}{$calltype}{seconds}\n" Should I give the value of the seconds to a completely separate hash w +hich will use the same first two indexes? Thanks, Vince

      You need to choose one or the other -- either it's a scalar, or it's a hash reference. It can't be both.

      That said, you're probalby better off with it as a hash reference. That is, make your c"ount of how many lines" be $sw_ctype_brkdown{$switchnum}{$calltype}{lines} and your count of the "nuber of seconds" be $sw_ctype_brkdown{$switchnum}{$calltype}{seconds} -- this way, you keep to one data structure, and it's a structure which explains itself. This is always a plus.

      perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'