Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: Embperl

Sort Keys of Hash Printed via dump

 

 

ModPerl embperl RSS feed   Index | Next | Previous | View Threaded


jthomp at midwestern

Sep 2, 2009, 1:07 PM

Post #1 of 4 (824 views)
Permalink
Sort Keys of Hash Printed via dump

Is there any variable that I can set that would tell dump to sort the
keys of a hash alphabetically (Like Data::Dumper)?



John Thompson

Administrative Systems Integration Specialist

Midwestern University

19555 N 59th Avenue

Glendale, AZ 85308

T 623-572-3303

F 623-572-3292


andrewo at oriel

Sep 2, 2009, 8:21 PM

Post #2 of 4 (771 views)
Permalink
RE: Sort Keys of Hash Printed via dump [In reply to]

> -----Original Message-----
> From: Thompson, John [mailto:jthomp[at]midwestern.edu]
> Sent: Thursday, 3 September 2009 6:07 AM
>
> Is there any variable that I can set that would tell dump to
> sort the keys of a hash alphabetically (Like Data::Dumper)?

Not as far as I can see from the docs.

But, then again, it's a trivial thing to write your own sub that does
this. A completely untested example to simulate the default behavior :-

[!
use Data::Dumper;
!]
[$ sub sorted_dump $]
<pre>
[+ do { local $Data::Dumper::Sortkeys=1; Dumper( @_ ); } +]
</pre>
[$ endsub $]

Cheers,

Andrew

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe[at]perl.apache.org
For additional commands, e-mail: embperl-help[at]perl.apache.org


gerald.richter at ecos

Sep 17, 2009, 4:41 AM

Post #3 of 4 (657 views)
Permalink
RE: Sort Keys of Hash Printed via dump [In reply to]

Hi,

Since [$ dump $] uses data::dumper, it should be enougth to set

$Data::Dumper::Sortkeys=1;

But I haven't tested it

Gerald


> -----Original Message-----
> From: Andrew O'Brien [mailto:andrewo[at]oriel.com.au]
> Sent: Thursday, September 03, 2009 5:22 AM
> To: Thompson, John; embperl[at]perl.apache.org
> Subject: RE: Sort Keys of Hash Printed via dump
>
>
> > -----Original Message-----
> > From: Thompson, John [mailto:jthomp[at]midwestern.edu]
> > Sent: Thursday, 3 September 2009 6:07 AM
> >
> > Is there any variable that I can set that would tell dump
> to sort the
> > keys of a hash alphabetically (Like Data::Dumper)?
>
> Not as far as I can see from the docs.
>
> But, then again, it's a trivial thing to write your own sub
> that does this. A completely untested example to simulate the
> default behavior :-
>
> [!
> use Data::Dumper;
> !]
> [$ sub sorted_dump $]
> <pre>
> [+ do { local $Data::Dumper::Sortkeys=1; Dumper( @_ ); } +]
> </pre> [$ endsub $]
>
> Cheers,
>
> Andrew
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe[at]perl.apache.org
> For additional commands, e-mail: embperl-help[at]perl.apache.org
>
>
> !DSPAM:416,4a9f37f8255959825358016!
>

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe[at]perl.apache.org
For additional commands, e-mail: embperl-help[at]perl.apache.org


jthomp at midwestern

Sep 17, 2009, 8:20 AM

Post #4 of 4 (656 views)
Permalink
RE: Sort Keys of Hash Printed via dump [In reply to]

It worked. Thanks.

-----Original Message-----
From: Gerald Richter [mailto:gerald.richter[at]ecos.de]
Sent: Thursday, September 17, 2009 4:41 AM
To: Andrew O'Brien; Thompson, John; embperl[at]perl.apache.org
Subject: RE: Sort Keys of Hash Printed via dump

Hi,

Since [$ dump $] uses data::dumper, it should be enougth to set

$Data::Dumper::Sortkeys=1;

But I haven't tested it

Gerald


> -----Original Message-----
> From: Andrew O'Brien [mailto:andrewo[at]oriel.com.au]
> Sent: Thursday, September 03, 2009 5:22 AM
> To: Thompson, John; embperl[at]perl.apache.org
> Subject: RE: Sort Keys of Hash Printed via dump
>
>
> > -----Original Message-----
> > From: Thompson, John [mailto:jthomp[at]midwestern.edu]
> > Sent: Thursday, 3 September 2009 6:07 AM
> >
> > Is there any variable that I can set that would tell dump
> to sort the
> > keys of a hash alphabetically (Like Data::Dumper)?
>
> Not as far as I can see from the docs.
>
> But, then again, it's a trivial thing to write your own sub
> that does this. A completely untested example to simulate the
> default behavior :-
>
> [!
> use Data::Dumper;
> !]
> [$ sub sorted_dump $]
> <pre>
> [+ do { local $Data::Dumper::Sortkeys=1; Dumper( @_ ); } +]
> </pre> [$ endsub $]
>
> Cheers,
>
> Andrew
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe[at]perl.apache.org
> For additional commands, e-mail: embperl-help[at]perl.apache.org
>
>
> !DSPAM:416,4a9f37f8255959825358016!
>

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe[at]perl.apache.org
For additional commands, e-mail: embperl-help[at]perl.apache.org

ModPerl embperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.