Bug#611434: clarify $Data::Dumper::Sortkeys

Niko Tyni ntyni at debian.org
Sat Jan 29 11:23:09 UTC 2011


On Sat, Jan 29, 2011 at 05:12:17PM +0800, jidanni at jidanni.org wrote:
> Package: perl-doc
> Version: 5.10.1-17
> Severity: wishlist
> File: /usr/share/man/man3/Data::Dumper.3perl.gz
> 
> I recommend you add a clarification to
> 
>        o   $Data::Dumper::Sortkeys  or  $OBJ->Sortkeys([NEWVAL])
> 
>            Can be set to a boolean value to control whether hash keys
>            are dumped in sorted order. A true value will cause the keys
>            of all hashes to be dumped in Perl's default sort order.

> ALL hashes?

> print Dumper(%h);
> $Data::Dumper::Sortkeys = 1;
> print Dumper(%h);

You aren't dumping a hash, you're dumping a list of scalar values.
Quoting the BUGS section:

   Due to limitations of Perl subroutine call semantics, you cannot pass
   an array or hash.  Prepend it with a "\" to pass its reference instead.
   This will be remedied in time, now that Perl has subroutine prototypes.

$Data::Dumper::Sortkeys works fine when you pass it a hash reference.
-- 
Niko Tyni   ntyni at debian.org






More information about the Perl-maintainers mailing list