Help for this page

Select Code to Download


  1. or download this
        while (CONDITION) { BLOCK }
    
  2. or download this
        STATEMENT while CONDITION;
    
  3. or download this
        while (my $line = <FILE>) {
            # Do something with the $line
        }
    
  4. or download this
        while (defined(my $line = <FILE>)) {
            # Do something with the $line
        }
    
  5. or download this
    $ perl -MO=Deparse -e 'while(my $line=<FILE>) { print; }'
    while (defined(my $line = <FILE>)) {
        print $_;
    }
    -e syntax OK
    
  6. or download this
        while (my $module = glob("*.pm")) {
            print "Found a module: $module\n";
        }
    
  7. or download this
        my $ok=0;
        $ok=1 while my $zero = glob("0");
        print $ok ? "ok\n" : "not ok\n"
    
  8. or download this
        $foo = $bar || $baz
    
  9. or download this
        my $x = 1;
        die("Oh dear!") while my $foo = $x && 0;
    
  10. or download this
        my $x = 1;
        die("Oh dear!") while defined(my $foo = $x && 0);