On Jun 12, 12:15 am, [EMAIL PROTECTED] (Beast) wrote: > Why this following code has not working as expected? > > print "Number of element(s) : " . sprintf("%10d", keys(%hash) ) . "\n";
The keys() function does two different things, depending on context. In scalar context, it returns the number of key/value pairs in the hash. In list context, it returns a list of the keys. You probably knew that, but didn't realize that you're using it in a list context here. The arguments to a function are a list, and so Perl is expecting a list of values to be passed to sprintf(). Anywhere Perl expects a list, if it sees a function/subroutine, it calls that function/subroutine in list context. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/