Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Not Exactly a Hash Tutorial

by planetscape (Canon)
on Jul 01, 2005 at 08:38 UTC ( #471590=perltutorial: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #! /usr/local/bin/perl -w
    # myHash.pl
    ...
    use warnings;
    
    use Data::Dumper;
    
  2. or download this
    # Hash Assignment
    # In this case, a 
    ...
    print "\n";
    
    
  3. or download this
    # hash element access
    my $State = 'SD';                  # planetscape's home state
    ...
    print "planetscape lives in " . $Name . "\.\n\n";
    
    
  4. or download this
    # exists ( $hash{$key} )
    $State = 'QC';               # Quebec, Canada
    ...
    }
    
    
  5. or download this
    # keys( %hash )
    my $count = keys %StateName;
    ...
    print "\n";
    
    
  6. or download this
    # delete ( $hash{key} )
    delete($StateName{DC});      # DC is not actually a state,
                                 # it's a postal abbreviation
    
    
  7. or download this
    # values( %hash )
    $count = values %StateName;  # $count is one less since we deleted DC
    ...
    print "\n";
    
    
  8. or download this
    # each( %hash )
    while (my($key,$value)=each(%StateName)) {     # there's lots more to 
    +know
    ...
    print "\n";
    
    
  9. or download this
    # make an inverse hash
    my %StateAbbreviation = reverse %StateName;
    ...
    print "\n";
    
    
  10. or download this
    # let's expand our real-world example from a hash of States
    # to a hash of postal abbreviations (not exhaustive)
    ...
        print "PostalCode for '$PostalCode{$pc}' is '$pc'\n";
    }
    
  11. or download this
    use strict;
    use warnings;
    ...
    
    $fake->draw($FILEHANDLE);
    close $FILEHANDLE;
    
  12. or download this
    .PS
    boxwid:=1.5; boxht:=0.75
    ...
    boxwid:=1.5; boxht:=0.75
    B15: box with .n at B14.s
    .PE
    
  13. or download this
    <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
    <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN"
    ...
    <rect x="0" y="-11.625" width="1.5" height="0.75" style="stroke-width:
    +0.010267;"/>
    </g>
    </svg>
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2015-07-06 04:02 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 (70 votes), past polls