Re: avoid repitive code while sorting hash arrays

2003-09-19 Thread Rob Dixon
Ramprasad wrote: > > Rob Dixon wrote: > > > > > > Will this do? > > > > sort { > > my ($va, $vb) = map $$hash{$_}{$sortkey}, $direction eq 'a' ? ($a, $b) : ($b, > > $a); > > $sortkey eq 'uname' ? $va cmp $vb : $va <=> $vb; > > } keys %$hash; > > > > Cheers, > > > > Rob > > > > > > Gr8 Now the

Re: avoid repitive code while sorting hash arrays

2003-09-19 Thread Ramprasad A Padmanabhan
Rob Dixon wrote: Ramprasad wrote: suppose I have a hash like %users =( 'cvs' => { 'uname' => 'cvs', 'uid' => 582, 'gid' => 500 }, 'radvd' => { 'uname' => '

Re: avoid repitive code while sorting hash arrays

2003-09-19 Thread Chuck Fox
Rob and all the other perl wonder workers who contribute to this list, Awesome, While I have been reading and writing perl for a few years now, I am always amazed at the code reduction that can occur when you properly apply the power of perl. This is the most instructive forum that I have ever

Re: avoid repitive code while sorting hash arrays

2003-09-19 Thread Rob Dixon
Ramprasad wrote: > suppose I have a hash like > > %users =( >'cvs' => { > 'uname' => 'cvs', > 'uid' => 582, > 'gid' => 500 > }, > 'radvd' => { > 'un

avoid repitive code while sorting hash arrays

2003-09-19 Thread Ramprasad A Padmanabhan
suppose I have a hash like %users =( 'cvs' => { 'uname' => 'cvs', 'uid' => 582, 'gid' => 500 }, 'radvd' => { 'uname' => 'radvd', 'u