Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Searching through a hash

by hallikpapa (Scribe)
on Nov 05, 2007 at 22:25 UTC ( [id://649108]=note: print w/replies, xml ) Need Help??


in reply to Re: Searching through a hash
in thread Searching through a hash

Yeah that looks good, thanks! So with this %$cols, I have a question. When you put the % attached to $cols, is that telling perl that there's actually a hash stored in this variable, so let's treat it like that? I am going to do some XML manipulation when I figure out how to traverse the hash correctly. For testing right now, how would I iterate through the entire %$cols values, printing them out, and then jumping back up to the next $row when done. Thanks!

Replies are listed 'Best First'.
Re^3: Searching through a hash
by ikegami (Patriarch) on Nov 05, 2007 at 22:32 UTC

    $cols contains a reference to a hash. %$cols (short for %{$cols}) means to access the hash referenced by the reference in $cols. See perlref.

    my @sorted_col_names = sort { length($a) <=> length($b) || $a cmp $b } keys %$cols; foreach my $col_name (@sorted_col_names) { my $cell = $col->{$col_name}; print("$cell\t"); } print("\n");

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://649108]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-25 13:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found