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

$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
  • Comment on Re: Re: Can't use string "1" as a HASH ref while "strict refs" in use
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re: Can't use string "1" as a HASH ref while "strict refs" in use
by Chmrr (Vicar) on Mar 04, 2002 at 21:26 UTC

    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'