Keys can be used as an lvalue. $ perldoc -f keys ... As an lvalue "keys" allows you to increase the number of hash buckets allocated for the given hash. This can gain you a measure of efficiency if you know the hash is going to get big. (This is similar to pre-extending an array by assigning a larger number to $#array.) If you say
keys %hash = 200; ... That said, using it as an lvalue does not magically create random keys in the hash. It just gives the interpreter a hint on how much memory should be allocated for it. --Tobias > -----Original Message----- > From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl- > win32-users-boun...@listserv.activestate.com] On Behalf Of Aaron > Hawryluk > Sent: Thursday, May 03, 2012 10:23 AM > To: Rothenmaier, Deane; perl-win32-users@listserv.ActiveState.com > Subject: Re: Hash Key function puzzlement -- a point of information query > > What Leo said. keys(%hash) returns the keys from the hash as an array, you > can't assign to it AFAIK. > > On Thu, May 3, 2012 at 10:18 AM, Leo Susanto <leosusa...@gmail.com> > wrote: > > keys is a function, it doesn't take in value > > > > On Thu, May 3, 2012 at 9:08 AM, Rothenmaier, Deane > > <deane.rothenma...@walgreens.com> wrote: > >> Gurus, > >> > >> > >> > >> Given something like this: > >> > >> > >> > >> #!Perl > >> > >> use strict; > >> > >> use warnings; > >> > >> > >> > >> my %hash; keys(%hash) = 128; > >> > >> > >> > >> print “hash has “ . scalar(keys(%hash)) . “ keys\n”; > >> > >> > >> > >> I should see a printed value of 128, wouldn’t you think? But no, it prints: > >> “hash has 0 keys”. What’s up wit dat? What obvious thing am I missing? > >> > >> > >> > >> Thanks, > >> > >> > >> > >> Deane Rothenmaier > >> > >> Programmer/Analyst – IT-StdCfg > >> > >> Walgreens Corp. > >> > >> 2 Overlook Point #N51022D > >> > >> MS 6515 > >> > >> Lincolnshire, IL 60069 > >> > >> 224-542-5150 > >> > >> > >> > >> The more corrupt the republic, the more numerous the laws. -- Tacitus > >> > >> > >> > >> > >> _______________________________________________ > >> Perl-Win32-Users mailing list > >> Perl-Win32-Users@listserv.ActiveState.com > >> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > >> > > _______________________________________________ > > Perl-Win32-Users mailing list > > Perl-Win32-Users@listserv.ActiveState.com > > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > _______________________________________________ > Perl-Win32-Users mailing list > Perl-Win32-Users@listserv.ActiveState.com > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs