Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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 taking refuge in the Monastery: (10)
As of 2014-12-26 22:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls