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

Creating a hash with key generated by a sub?

by smullis (Pilgrim)
on Nov 12, 2004 at 12:53 UTC ( [id://407342]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use Digest::MD5 qw(md5_hex);
    use strict; 
    use warnings;
    
    my $secret = "applepie";
    
  2. or download this
    sub get_md5 
    {
     md5_hex("$secret" . "$_")
    };
    
  3. or download this
    my @array          = qw(foo bar baz);
    my %md5_other_hash = (map {&get_md5, $_ } @array);
    
  4. or download this
    my %md5_hash       = ( &get_md5('foo')  => "foo",
                           &get_md5('bar')  => "bar",
                           &get_md5('bar')  => "baz",
    );
    
  5. or download this
    print &get_md5('foo');
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://407342]
Approved by pelagic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-18 18:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found