[Moscow.pm] warnings 'uninitialized'

Nikolay Mishin mi ya.ru
28 07:23:07 PDT 2011


 ( )


use 5.01;
use Carp;
my %filials;
$filials{foo} = 300;
my $ref_hash = \%filials;
my @test     = qw/444 33a 2 d 300 ffd 22/;

for $test_val (@test) {
    $filials{foo} = $test_val;
    test_var( \%filials );
    say $test_val;
}

sub test_var {
    my $r = shift;
    croak("Value ***$r->{foo}*** is not defined or not number")
      if !defined $r->{foo} || $r->{foo} !~ /^\d+$/;

    if ( $r->{foo} > 100 ) {
        say '$r->{foo} > 100';
    }

}


28.10.2011, 18:18, "Nikolay Mishin" <mi  ya.ru>:
>    
>
> use 5.01;
> use Carp;
> my %filials;
> $filials{foo} = 300;
>
> #$filials{boo} = 200;
> my $ref_hash = \%filials;
> my @test = qw/a 2 d 300 ffd 22/;
>
> #test_var($ref_hash);
>
> for $test_val (@test) {
> $filials{foo} = $test_val;
> test_var( \%filials );
> say $test_val;
> }
>
> sub test_var {
> my $r = shift;
> croak("Value ***$r->{foo}*** is not defined or not number")
> if !defined $r->{foo} || $r->{foo} != ~/^\d+$/;
>
> if ( $r->{foo} > 100 ) {
> say '$r->{foo} > 100';
> }
>
> }
>
>   ,   .      -     1000     ?
>
> 28.10.2011, 17:26, "Alexandr Gomoliako" <zzz  zzz.org.ua>:
>
>> On 10/28/11, Alexandr Gomoliako <zzz  zzz.org.ua> wrote:
>>> 
>>> if ($r->{foo} =~ /^\d+$/ && $r->{foo} > 100)
>>      ,  :
>> if (defined $r->{foo} && $r->{foo} =~ /^\d+$/ && $r->{foo} > 100)
>>
>> --
>> Moscow.pm mailing list
>> moscow-pm  pm.org | http://moscow.pm.org
>
> --
> Nikolay Mishin
>
> --
> Moscow.pm mailing list
> moscow-pm  pm.org | http://moscow.pm.org

--
Nikolay Mishin


Moscow-pm