Advertisement
oylenshpeegul

Nikolay

Nov 2nd, 2011
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.68 KB | None | 0 0
  1. #!/usr/bin/env perl
  2.  
  3. use 5.010;
  4. use strict;
  5. use warnings;
  6. use Carp;
  7. use Data::Dumper;
  8.  
  9. my %filials = (boo => 200,
  10.                foo => 300,
  11.               );
  12.  
  13. my @test= qw/444 33a 2 d 300 ffd 22/;
  14.  
  15. for my $test_val (@test) {
  16.     $filials{foo} = $test_val;
  17.     test_var( \%filials );
  18. }
  19.  
  20. sub test_var {
  21.     my $r = shift;
  22.     croak( "Value \$r->{foo}**$r->{foo}** is not defined or not number."
  23.                . "\nDump \$r="
  24.                    . Dumper($r) )
  25.         if !defined $r->{foo}
  26.             || $r->{foo} !~ /^\d+$/;
  27.     say $r->{foo};
  28.     if ( $r->{foo} > 100 ) {
  29.         say '$r->{foo} > 100';
  30.     } else {
  31.         say '$r->{foo} <= 100';
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement