dsb has asked for the wisdom of the Perl Monks concerning the following question:
A coworker and I were trying to work out some of the code when tie'ing a hash to a Berkeley DB file. I noticed that one of the lines called for the return value from a tie() to be assigned to a scalar variable. So I tried assigning a regular old hash - not a reference to a hash - to a scalar. I didn't get what i expected.
dsb
This @ISA my( $cool ) %SIG
I half expected the code to bomb. Instead the assignment evaluated and when I printed the contents of the scalar, I got a weird result. See the code.
Anyone have an idea of what's going on here and why I get a fraction when I print the contents of $db?%db = ( one => 1, two => 2, three => 3 ); print %db, "\n"; # prints 'three3one1two2' $db = %db; print $db, "\n"; # prints '3/8'
dsb
This @ISA my( $cool ) %SIG
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Hash to Scalar Assignment Oddity
by philcrow (Priest) on Jan 26, 2006 at 15:34 UTC | |
Re: Hash to Scalar Assignment Oddity
by bunnyman (Hermit) on Jan 26, 2006 at 18:12 UTC | |
by revdiablo (Prior) on Jan 26, 2006 at 20:56 UTC | |
by dsb (Chaplain) on Jan 30, 2006 at 21:00 UTC | |
by bunnyman (Hermit) on Feb 08, 2006 at 19:06 UTC | |
Re: Hash to Scalar Assignment Oddity
by borisz (Canon) on Jan 26, 2006 at 15:47 UTC | |
Re: Hash to Scalar Assignment Oddity
by ikegami (Patriarch) on Jan 26, 2006 at 17:16 UTC |
Back to
Seekers of Perl Wisdom