Sponsored Content
Top Forums Shell Programming and Scripting Sorting values of hash in ascending order using Perl Post 302671989 by mregine on Sunday 15th of July 2012 01:38:59 PM
Old 07-15-2012
Sorting in Perl can be tricky, but this is a classic: google "perl sort hash by value".

Code:
foreach $key (sort {$records{$a} <=> $records{$b}}
              keys %records) {
    print "$key\t$records{$key}\n";
}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl-extract data from hash values

Hello, I have parsed an xml file using perl to get the hash values and the output looks like this $VAR1 = { 'RT' => { 'List' => { 'String' => ... (1 Reply)
Discussion started by: userscript
1 Replies

2. Shell Programming and Scripting

Perl Hash:Can not keep hash data in the same order that it was inserted

Can Someone explain me why even using Tie::IxHash I can not get the output data in the same order that it was inserted? See code below. #!/usr/bin/perl use warnings; use Tie::IxHash; use strict; tie (my %programs, "Tie::IxHash"); while (my $line = <DATA>) { chomp $line; my(... (1 Reply)
Discussion started by: jgfcoimbra
1 Replies

3. Shell Programming and Scripting

Sorting keys of a hash in perl

hi all, i have a small problem regarding sorting the keys in a hash. my %hash; for($i=0;$i<19;$i++) { $hash{$i}=$i; } foreach $c (sort keys %hash) { print "\n $hash{$c}"; } (1 Reply)
Discussion started by: niteesh_!7
1 Replies

4. Shell Programming and Scripting

Remove default data hash sorting in perl script?

Hi, I have a datahash with 'n' number of values in perl script. I am writing a xml file from the datahash. I am getting output with sorting(Field sorting). My question is that i don't want any default sorting.whatever i am inserting into datahash it should give same xml file. Any help? ... (0 Replies)
Discussion started by: solo123
0 Replies

5. Shell Programming and Scripting

Perl: Sorting a hash value that is a list.

Hi Folks I am very much a newbie at perl but picking it up and I'm hoping you can help. I have a file input that details all the /etc/group files in our enterprise in the following format: "<host>:<group>:<gid>:<users>" I want to parse this data display it as the following:... (9 Replies)
Discussion started by: g_string
9 Replies

6. UNIX for Dummies Questions & Answers

sorting sequences in ascending order

Hi, I have this single file with a number of sequence inside it of format >string1 data >string100 data >string10 ..... >string5 ... >string67 ...... the dots represent data. I wanted to get the sequences arranged in ascending order like >string1 data >string5 (5 Replies)
Discussion started by: sonia102
5 Replies

7. Shell Programming and Scripting

Compare values of hashes of hash for n number of hash in perl without sorting.

Hi, I have an hashes of hash, where hash is dynamic, it can be n number of hash. i need to compare data_count values of all . my %result ( $abc => { 'data_count' => '10', 'ID' => 'ABC122', } $def => { 'data_count' => '20', 'ID' => 'defASe', ... (1 Reply)
Discussion started by: asak
1 Replies

8. UNIX for Dummies Questions & Answers

Sorting a file in descending order when you have 10e- values

Hi, I am trying to sort the following file in descending order of its fourth column. 2 1 363828 -2.423225e-03 3 1 363828 4.132763e-03 3 2 363828 8.150133e-03 4 1 363828 4.126890e-03 I use sort -k4,4g -r input.txt > output.txt ... (1 Reply)
Discussion started by: evelibertine
1 Replies

9. Shell Programming and Scripting

Finding unique values in a hash (Perl)

Hi, I have a hash with unique keys associated with some data. my %FINALcontigs = ( 'mira_rep_c765:119reads**', 'ctctactggaagactgac', 'mira_rep_c7454:54reads**', 'atggatactgcgctgttgctaactactgga', 'mira_rep_c6803:12reads**', 'atcgactggatgcagggttgtggtttcta', ... (2 Replies)
Discussion started by: jdilts
2 Replies

10. Shell Programming and Scripting

Arrange values in ascending order

HI I have a file # vi assc values order fin 100 34 45 200 12 64 120 10 23 Here I need to check whether the values of second column"order" is arranged ascendingly Note: Always order column will be arranged either in ascending or descending order How to make it?... (1 Reply)
Discussion started by: Priya Amaresh
1 Replies
KEYMOD(1p)						User Contributed Perl Documentation						KEYMOD(1p)

NAME
keymod - Modifies key parameters in a DNSSEC-Tools keyrec file SYNOPSIS
keymod [options] keyrec1 ... keyrecN DESCRIPTION
keymod modifies the key parameters in a keyrec file that are used to generate cryptographics keys used to sign zones. The new parameters will be used by zonesigner when generating new keys. It has no effect on existing keys. zonesigner will use the new parameter for a zone the next time it generates a key that requires that parameter. This means that, for example, a new ZSK length will not be used during the next invocation of zonesigner if that invocation will be performing KSK-rollover actions. The following fields may be modified: kskcount - count of KSK keys ksklength - length of KSK keys ksklife - lifetime of KSK keys random - random number generator device file revperiod - revocation period for KSK keys zskcount - count of ZSK keys zsklength - length of ZSK keys zsklife - lifetime of ZSK keys New key/value fields will be added to a zone keyrec file to inform zonesigner that new values should be used. The key portion of the added fields will begin with "new_". For example, a new KSK length of 2048 will be written to the keyrec file as: new_ksklength 2048 All zone records in the specified keyrec file will be modified, unless the -zone option is given. In that case, only the named zone will be modified. If a zone keyrec already contains a new key/value field, then the value will be modified on subsequent runs of keymod. OPTIONS
keymod recognizes the following options. Multiple options may be combined in a single keymod execution. All numeric values must be positive or zero. If a new key/value field should be deleted from a zone keyrec, then a zero or empty string value should be specified for the appropriate option. -zone zonename The zone keyrec whose name matches zonename is selected as the only keyrec that will be modified. If this name is not given, then all zone keyrec records will be modified. -ksklength ksklength The ksklength field will be modified in the selected keyrec records to the given value. This is a numeric field whose values depend on the cryptographic algorithm to be used to generate keys for the zone. -kskcount kskcount The kskcount field will be modified in the selected keyrec records to the given value. This is a numeric field. -ksklife ksklife The ksklife field will be modified in the selected keyrec records to the given value. This is a numeric field. -random random The random field will be modified in the selected keyrec records to the given value. This is a text field that will be passed to the key generator. -revperiod revperiod The revperiod field will be modified in the selected keyrec records to the given value. This is a numeric field. -zskcount zskcount The zskcount field will be modified in the selected keyrec records to the given value. This is a numeric field. -zsklength zsklength The zsklength field will be modified in the selected keyrec records to the given value. This is a numeric field whose values depend on the cryptographic algorithm to be used to generate keys for the zone. -zsklife zsklife The zsklife field will be modified in the selected keyrec records to the given value. This is a numeric field. -nocheck If this option is given, the krfcheck command will not be run on the modified keyrec file. -verbose Display information about every modification made to the keyrec file. -Version Displays the version information for keymod and the DNSSEC-Tools package. -help Display a usage message. COPYRIGHT
Copyright 2012 SPARTA, Inc. All rights reserved. See the COPYING file included with the DNSSEC-Tools package for details. AUTHOR
Wayne Morrison, tewok@tislabs.com SEE ALSO
zonesigner(8), krfcheck(8) Net::DNS::SEC::Tools::keyrec.pm(3) file-keyrec(5) perl v5.14.2 2012-06-21 KEYMOD(1p)
All times are GMT -4. The time now is 04:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy