Advertisement
Guest User

Untitled

a guest
Jul 19th, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Per 0.79 KB | None | 0 0
  1. #!/opt/local/bin/perl
  2.  
  3. use 5.12.0;
  4. use warnings;
  5.  
  6. my %hash_1 = ( a => 'qw', b => 'dd', c => 'ddd', d => '322', e => 'fj');
  7. my %hash_2 = (q => '23', w => '2234', r => 'djh', t => 'ddsd', y => 'sddssd') ;
  8.  
  9. {
  10.     my %hash_int; # HA-HA no one can`t touch it!
  11.    
  12.     sub limit_each {
  13.         my ($step) = @_;
  14.         say '+open loop';
  15.         while ( $step-- && (my ($key, $val) = each %hash_int )){
  16.             say $key,"\t",'--->',$val;
  17.         }
  18.         say '-exit loop';
  19.     }
  20.     sub set_hash{
  21.         %hash_int = @_;
  22.         say 'new hash!';
  23.         while ((my ($key, $val) = each %hash_int )){
  24.             say $key,"\t",'--->',$val;
  25.         }
  26.     }
  27.  
  28. }
  29. # first hash
  30. set_hash(%hash_1);
  31. limit_each(3);
  32. limit_each(2);
  33.  
  34. set_hash(%hash_342656);
  35. limit_each(2);
  36. limit_each(3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement