Help for this page

Select Code to Download


  1. or download this
    
    use strict;
    ...
    
    # 5. Demonstrate the folly of breaking out of "map" with "last"
    @odds = map { ($_ % 2)? $_: last } @nums;
    
  2. or download this
    foreach (@nums) { ($_ % 2) and push @odds, $_ }
    
  3. or download this
    Can't "last" outside a loop block at last_test.pl line 27.