Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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 lurking in the Monastery: (14)
As of 2015-07-07 18:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls