Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.
Obvious in retrospect, but it was annoying when I stumbled on it. This was fairly obscure in a much larger program.
use warnings;
use strict;
foo('bar');
my %hash = (bar => 'value');
sub foo { print $hash{+shift} }
Argh (Score:2)
Not that obvious (Score:1)
TIA
Re:Not that obvious (Score:1)
The function foo takes the name of a key and prints out the corresponding value from %hash.
You might expect it would print 'bar' but the call to foo is executed before the line that initialises %hash so instead Perl complains about an uninitialised value and exits.
Re:Not that obvious (Score:1)
I was actually getting hung up on the +shift part... didn't realize that the + was a unary operator.
I thought it would choke because it didn't have a left hand value...
Re:Not that obvious (Score:1)
Re:Not that obvious (Score:1)
Is this thing supposed to print out 'bar'?
Re:Not that obvious (Score:2)
One might think that it should print out 'value', but the crux of the problem, as noted by grantm, is that the hash is declared at compile time (so strict doesn't complain) but the line that assigns data to the hash is not executed by the time &foo is called. this means that the hash is empty, even though it's been declared. I can only remember being bitten by this twice, but both times it's confused the heck out of me.
Re:Not that obvious (Score:1)
Of course... I meant to say that.
Which reminds me.
If I reply to someone's comment, I see the message I'm replying to on the page I type my response in.
But, if I reply to a journal entry, I don't see the message and I'm basically "flying blind" and going from memory.
To make matters worse, replying to a comment involves clicking on a link. So, I can open the page in another tab and have easy access to the original comment. But, replying to a journal en
Re:Not that obvious (Score:2)
I'm not aware that it's changeable, but I've also not paid much attention to the customization features.