Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: why use a hash instead of an array

by 5mi11er (Deacon)
on Jun 11, 2013 at 21:18 UTC ( #1038342=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    while(<DATA>){
    chomp;
      $hash{$_}++ for split;  
    }
    
  2. or download this
    while(<DATA>){  #get a line of text from the DATA area, put it in spec
    +ial variable $_
        chomp;      #remove the "new line" character from the $_ variable
    ...
            $hash{$word}++;  #increment the value pointed to by the $hash{
    +$word} "key"
        }  
    }
    
  3. or download this
    board => 1
    chalk => 1
    ...
    students => 2
    table => 1
    teacher => 3
    
  4. or download this
    foreach $word (sort keys %hash) {
        print "$word\n";
    ...
            print "$word\n";
        }
    }
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (12)
As of 2014-08-29 16:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (282 votes), past polls