Ignore:
Timestamp:
2015-01-09T11:57:42+13:00 (9 years ago)
Author:
Jeremy Symon
Message:

Should use 'exists', not 'defined' when checking if an element exists in a hash

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/package-kits/scripts/gs-servlet.pl

    r29673 r29674  
    5353            # Append the new data to the current data
    5454            for my $key (keys %$new) {
    55                 if ($key eq '.attr' and defined $hash->{'.attr'}) {
     55                if ($key eq '.attr' and exists $hash->{'.attr'}) {
    5656                    for my $attr ($new->{'.attr'}) {
    5757                        $hash->{'.attr'}->{$attr} = $new->{'.attr'}->{$attr};
    5858                    }
    59                 } elsif (defined $hash->{$key}) {
     59                } elsif (exists $hash->{$key}) {
    6060                    if (ref $hash->{$key} ne 'ARRAY') {
    6161                        $hash->{$key} = [ $hash->{$key} ];
     
    9494        sub {
    9595            my $count = 0;
    96             if (defined $hash->{servlet}) {
     96            if (exists $hash->{servlet}) {
    9797                $count = 1;
    9898                my $servlets = $hash->{servlet};
     
    107107        'Lists the servlets in the current internal state',
    108108        sub {
    109             if (defined $hash->{servlet}) {
     109            if (exists $hash->{servlet}) {
    110110                my $servlets = $hash->{servlet};
    111111                if (ref $servlets eq 'ARRAY') {
     
    125125        sub {
    126126            my $name = shift @ARGV;
    127             if (defined $hash->{servlet}) {
     127            if (exists $hash->{servlet}) {
    128128                my $servlets = $hash->{servlet};
    129129                if (ref $servlets eq 'ARRAY') {
     
    156156                };
    157157            }
    158             if (defined $hash->{servlet}) {
     158            if (exists $hash->{servlet}) {
    159159                unless (ref $hash->{servlet} eq 'ARRAY') {
    160160                    $hash->{servlet} = [ $hash->{servlet} ];
     
    180180        $argc --;
    181181    } elsif ($varargs) {
    182     } elsif (defined $commands{$cmd}) {
     182    } elsif (exists $commands{$cmd}) {
    183183        # get the argument count of a valid command
    184184        $argc = @{$commands{$cmd}}[2];
Note: See TracChangeset for help on using the changeset viewer.