beast wrote:
> Hi All,
> 
> 
> Why this following code has not working as expected?
> 
>     print "Number of element(s) : " . sprintf("%10d", keys(%hash) ) . "\n";

keys(%hash) returns the hash keys as a list, so

  sprintf("%10d", keys(%hash) )

is like

  sprintf("%10d", 'key3', 'key4', 'key1', 'key2', 'key5');

so the first key will be formatted as %10d and returned as a string.

I suggest you write

  printf "Number of element(s) : %10d\n", scalar keys %hash;

HTH,

Rob


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to