use list to assign hash...

Discussion in 'Perl Misc' started by Sean, Jan 23, 2006.

  1. Sean

    Sean Guest

    After the following code, memory of hash is like
    {
    "fact"=>undef,
    "story"=>undef,
    }
    Is it true?
    ----------------------------
    #!/usr/bin/perl;
    use strict;
    my %hash;
    my @my_list = ("fact", "story");
    @hash{@my_list} =();
    -------------------------------
     
    Sean, Jan 23, 2006
    #1
    1. Advertising

  2. Sean

    Xicheng Guest

    Sean wrote:
    > After the following code, memory of hash is like
    > {
    > "fact"=>undef,
    > "story"=>undef,
    > }
    > Is it true?
    > ----------------------------
    > #!/usr/bin/perl;
    > use strict;
    > my %hash;
    > my @my_list = ("fact", "story");
    > @hash{@my_list} =();
    > -------------------------------

    you can help yourself by using "Data::Dumper", checkout
    perldoc Data::Dumper

    Xicheng
     
    Xicheng, Jan 23, 2006
    #2
    1. Advertising

  3. Sean <> wrote:
    > After the following code, memory of hash is like
    > {
    > "fact"=>undef,
    > "story"=>undef,
    > }
    > Is it true?



    Yes.


    > ----------------------------
    > #!/usr/bin/perl;
    > use strict;
    > my %hash;
    > my @my_list = ("fact", "story");
    > @hash{@my_list} =();
    > -------------------------------



    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Jan 23, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gnarlodious
    Replies:
    5
    Views:
    202
    Gnarlodious
    Nov 2, 2011
  2. rp
    Replies:
    1
    Views:
    539
    red floyd
    Nov 10, 2011
  3. Srijayanth Sridhar
    Replies:
    19
    Views:
    627
    David A. Black
    Jul 2, 2008
  4. Thomas W.
    Replies:
    12
    Views:
    204
    Mike Moore
    Mar 4, 2011
  5. Guest1
    Replies:
    4
    Views:
    168
    Tad McClellan
    Sep 3, 2003
Loading...

Share This Page