04-10-2009
Quote:
Originally Posted by
KevinADC
I was assuming you wanted the output in order by state, but after looking at your hash I may have been mistaken. If that is the order then the hash of arrays should work, although you may not have your head around such a concept if you are still unfamiliar with a regular old hash.
You were right. I wanted the output to be in the ordered (by the state) of the hash. The output I provided in post #1 was what I got (unordered), not what I wanted.
I tried your code, and the output wasn't in order also. So I guess you were right that hash are unordered list.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a little problem. To keep a configuration simple, I've exceeded my perl knowledge. :-) I've worked with multi-dimentional arrays before, but this one has me beat:
@info = (
{
'defval' => 'abc'
'stats' = (
{ 'name' => 'a', },
{ 'name' =>... (1 Reply)
Discussion started by: jsmoriss
1 Replies
2. Shell Programming and Scripting
Hi,i have a code fragment below.
%tag = (); #line 1
$tag{'info'} = $datastring; #line 2
$resp = $ua->request( #$ua is a user agent
POST 'http://10.2.3.0' ,
Content_Type => application/x-www-form-urlencoded
Content => #line 3 I am not sure of what the code... (3 Replies)
Discussion started by: new2ss
3 Replies
3. Shell Programming and Scripting
Hi all experts,
May I know how to read a csv file and read the content in a hash in PERL?
Currently, I hard-coded and defined it in my code. I wanna know how to make up the %mymap hash thru reading the cfg.txt
====
csv file(cfg.txt):
888,444
999,333
===
#!/usr/bin/perl
my... (1 Reply)
Discussion started by: kinmak
1 Replies
4. Shell Programming and Scripting
I have a script with dynamic hash of hashes , and I want to print the entire hash (with all other hashes).
Itried to do it recursively by checking if the current key is a hash and if yes call the current function again with refference to the sub hash.
Most of the printing seems to be OK but in... (1 Reply)
Discussion started by: Alalush
1 Replies
5. Shell Programming and Scripting
Hi ,
I have an input.txt file that i read
node: id= c1, class=nb, cx=100, cy=100, r=10
node: id=c2, class=b, cx=150, cy=130, r=10
node: id=c3, class=nb, cx=50, cy=80, r=10
node: id=c4, class=nb, cx=120, cy=200, r=10
i split over , and = to create a global array and then passed it to a... (6 Replies)
Discussion started by: rsanjay
6 Replies
6. UNIX for Dummies Questions & Answers
Hello dear unix command line friends !
I'm looking for a simple combinaison of ls & awk (maybe grep) to print:
list of folders of a directory
|_ ordered by size
like what I have with
$ du -sk ./* | sort -rn
printing that result:
8651520 ./New Virtual Machine_1
8389120 ./Redhat
... (1 Reply)
Discussion started by: holister
1 Replies
7. Web Development
Hi,
A piece of script from Perl-cookbook I do not understand, and post here for explanation.
The purpose is to find the element in either array (union), and in both array (intersection). Thank you in advance.
@a=qw(1 3 5 6 7 8);
@b=qw(2 3 5 7 9);
foreach $e (@a, @b) {$union{$e}++ &&... (3 Replies)
Discussion started by: yifangt
3 Replies
8. Shell Programming and Scripting
How do I get the unique hashes from an array of hashes?
@ar1 = ( {a=>1,b=>2}, {c=>3,d=>4},{a=>1,b=>2});I need :
@ar2 = ( {a=>1,b=>2}, {c=>3,d=>4});Thanks. (2 Replies)
Discussion started by: shellwell
2 Replies
9. Programming
Hi All
I have been using a curl code to output an hash that looks like this
$VAR1 = {
'data'... (5 Replies)
Discussion started by: ab52
5 Replies
10. Shell Programming and Scripting
Hi, I have a hash of hash where it has
name, activities and count
i have data like this -
$result->{$name}->{$activities} = $value;
content of that are -
name - robert tom cat peter
activities - running, eating, sleeping , drinking, work
i need to print output as below
... (3 Replies)
Discussion started by: asak
3 Replies