Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Not Exactly a Hash Tutorial

by planetscape (Chancellor)
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
    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 
    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;
    close $FILEHANDLE;
  12. or download this
    boxwid:=1.5; boxht:=0.75
    boxwid:=1.5; boxht:=0.75
    B15: box with .n at B14.s
  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:

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perltutorial [id://471590]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2018-07-22 12:34 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (454 votes). Check out past polls.