Help for this page

Select Code to Download


  1. or download this
    {
        my $counter = 0;
        sub inc_counter { $counter++ };    # $counter is visible here
        sub get_counter { $counter };      # and here
    }
    
  2. or download this
    $/ = "\n";
    my $line = <STDIN>;     # <> operator reads just one line
    ...
    }
    
    $line = <STDIN>;        # reads just one line again, since $/ returns 
    +to "\n"
    
  3. or download this
    for (0 .. 100) {
      next unless $_ % 2;     # skip multiples of 2
      next unless $_ % 5;     # skip multiples of 5
      print "$_\n";
    }