in reply to Can't use string

It sounds like you want an array.
use strict; my @rows; $rows[1] = 10; my $val = 1; my $row = $rows[$val]; print("$row\n");

If you're indexes are sparsed or strings, a hash would be more appropriate.

use strict; my %rows; $rows{1} = 10; my $val = 1; my $row = $rows{$val}; print("$row\n");

Replies are listed 'Best First'.
Re^2: Can't use string
by plobsing (Friar) on Jan 31, 2008 at 23:14 UTC
    Technically the OP is using a hash. A realy ugly hackish hash.

      Are you referring to the fact that a symbol table is a sort of hash and that the code results in a lookup of the package's symbol table?

      If you start calling that a hash lookup, you must also call $_ in print("$_\n") a hash lookup — it's the same op — and the term becomes useless.

      No, the OP *isn't* using a hash.

        Yes. Sort of.

        I understand that stashes are special hashes, but my point was more that the OP was making use of a facility that gives the behaviour of a hash, not the underlying mechanism.

        However, I disagree with your argument. You only use what you are requiring to be exposed to you. A simple variable lookup does not necessarily imply hash use from a user perspective. There's a layer of abstraction present. This abstraction can be done independent of the hash implementation. Just look at how lexicals work.

        Only when you the user takes away the layer of abstraction shielding the hash lookup does it become use from the users perspective. That is what has occurred here, therefore it is using a stash as a hash.