SHARE
TWEET

Untitled

a guest Jul 19th, 2017 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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_2);
  35. limit_each(2);
  36. limit_each(3);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top