Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Learning to use the hash effectively

by suaveant (Parson)
on Jun 25, 2001 at 03:26 UTC ( [id://91147]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    while (<TEST>) {
      my ($key,@fileData) = split /\|/;
    ...
      my ($key,@fileData) = split /\|/;
      $test{$key} = \@fileData;
    }
    
  2. or download this
    foreach my $key (keys %test) {
          push (@sorted, "$key|$test{$key}->[0]|$test{$key}->[1]|$test{$ke
    +y}->[2]|$test{$key}->[3]");
    ...
    foreach my $key (keys %test) {
          push @sorted, (join '|', ($key,@{$test{$key}});        
    }
    
  3. or download this
    open(TEST, ">test.txt") || die "File couldn't be opened for writing: $
    +!";
    foreach my $key (sort keys %test) {
    ...
      print TEST "\n";
    } 
    close(TEST);
    
  4. or download this
    foreach my $key (sort keys %test) {
    #to
    foreach my $key (sort { $test{$a}[-1] <=> $test{$b}[-1] } keys %test) 
    +{
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-04-25 08:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found