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

What exactly are you trying to do? The expression 'lang' . $ARGS{lang} concatinates two strings and you end up with 'langLogin'. You're then trying to use that string as a hash. Why?

Replies are listed 'Best First'.
Re^2: Can't use string ("langLogin") as a HASH ref while "strict refs"
by Anonymous Monk on Jan 23, 2006 at 09:59 UTC
    maybe i should have been more descriptive... i have a language file for each of my modules I use in my program... so Login.pm calls the transelate sub like this: &translate(lang=>'Login'); and then basically the translate sub "loads" a hash %langLogin that's in a seperate file called en.pm... Hope this is more descriptive... Thank you for your prompt reply
      Oy. Symbolic references. You really should not do that. A much better strategy would be to use a hash of hashes instead.

      If you're absolutely intent on doing it with symrefs, though, you'll need to turn off strict mode. I reccomend confining the non-strict code to the smallest possible block. Something like this should work.

      my %lang; { no strict 'refs'; %lang = %{'lang' . $ARGS{lang}}; }
        That's the only way I can get it to work, with no strict 'refs'... i've modified my language file to be a hash of hashes, instead of a seperate hash for each module and it works much better and strict is turned on full... which makes me alot happier! Thank you so much for all you help! Have an awesome day or night depending where you are!