restrict the population of elements in a data structure.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • babp
    New Member
    • Sep 2009
    • 10

    restrict the population of elements in a data structure.

    Hi All,
    Please help me to restrict the population of this hash structure.I don't want to exit from the program if var not defined on this example.

    Code:
    #!/usr/bin/perl
    my %a;
    if (defined $a{'abd'}->[0] ){
    print "yes \n";
    
    }
    use Data::Dumper;
    print Dumper \%a;
    RESULT
    ======
    
    $VAR1 = {
              'abd' => []
            };


    Objective is to restrict automatic creation of this structure on validation.
    Last edited by Meetee; Dec 14 '11, 11:40 AM. Reason: code tags added
  • RonB
    Recognized Expert Contributor
    • Jun 2009
    • 589

    #2
    First check to see if the hash key exists, then, if needed, test if it's defined.

    Comment

    Working...