Sunday, August 31, 2014

Perl 의 loop statements

Perl 의 loop statements 예
     for (my $i = 10; $i >= 0; $i--) {  
       print "$i...\n";        # Countdown  
     }  
   
     foreach my $i (reverse 0..10) {  
       print "$i...\n";        # Same  
     }  
   
     %hash = (dog => "lazy", fox => "quick");  
     foreach my $key (keys %hash) {  
       print "The $key is $hash{$key}.\n"; # Print out hash pairs  
     }  

No comments:

Post a Comment