undefing a hash

Discussion in 'Perl' started by Jim, Sep 17, 2003.

  1. Jim

    Jim Guest

    Hello,

    when i undef a anonymous hash that contains other anonymous hashes and areas, e.g.

    $hashref = { a => 'a', b => { c => 'c' } };
    undef $hashref;

    will the undef also undef all data structures inside the tree of data?

    much thanks,
    Jim
     
    Jim, Sep 17, 2003
    #1
    1. Advertising

  2. Jim

    Ga Mu Guest

    Jim wrote:
    > Hello,
    >
    > when i undef a anonymous hash that contains other anonymous hashes and areas, e.g.
    >
    > $hashref = { a => 'a', b => { c => 'c' } };
    > undef $hashref;
    >
    > will the undef also undef all data structures inside the tree of data?
    >
    > much thanks,
    > Jim


    $hashref is a scalar that has nothing to do with anything you're doing.
    When referring to the entire hash, as in both lines above, you need to
    use %hashref. Yes, the entire hash is undef'd.

    Greg
     
    Ga Mu, Sep 18, 2003
    #2
    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. Red Orchid
    Replies:
    3
    Views:
    1,092
  2. Pieter Claassen
    Replies:
    1
    Views:
    1,151
    CBFalconer
    Aug 4, 2004
  3. Bo Peng
    Replies:
    4
    Views:
    817
  4. rp
    Replies:
    1
    Views:
    593
    red floyd
    Nov 10, 2011
  5. Srijayanth Sridhar
    Replies:
    19
    Views:
    674
    David A. Black
    Jul 2, 2008
Loading...

Share This Page