in reply to what does main->{x} = 1 do?
$ perl -le 'main->{x} = 1; print $main->{x}'
But this does:
$ perl -lwe 'main->{x} = 1; print $main{x}' 1
The reason is that "main" is being treated as a symbolic reference to the global hash %main. Strict mode catches the error for you:
$ perl -Mstrict -lwe 'main->{x} = 1; print $main{x}' Can't use bareword ("main") as a HASH ref while "strict refs" in use a +t -e line 1.
-sam
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: what does main->{x} = 1 do?
by ganeshk (Monk) on May 14, 2008 at 00:40 UTC | |
by ikegami (Patriarch) on May 15, 2008 at 05:02 UTC | |
by blazar (Canon) on May 14, 2008 at 22:20 UTC | |
by Jenda (Abbot) on May 14, 2008 at 23:42 UTC |