Help for this page

Select Code to Download


  1. or download this
    while (<INFILE>) {
      $word = <STDIN>;
    ...
    
    # Officiate is asked for input on every line of the file.
    # Officiate throttles monk; blacking out, you meditate on your error.
    
  2. or download this
    while (<INFILE>) {
      $line = $_;
    ...
    # $line only contains the last line of the file!
    # Officiate makes bad decision based on wrong output.
    # Monk goes hungry.
    
  3. or download this
    while (<INFILE>) {
      push @lines, $_;
    ...
    # File data is stored until $word is known.
    # Officiate gets correct output, is pleased while file is small.
    # Monk is thrashed when the disk thrashes on a large file.
    
  4. or download this
    $word = <STDIN>;
    while (<INFILE>) {
    ...
    
    # There is no need to store the file data.
    # Harmony is achieved.
    
  5. or download this
    #!/usr/bin/perl -W
    use warnings 'all';
    ...
    }
    my $key = pretty($type);
    print @{ $lines{$key} };