Help for this page

Select Code to Download


  1. or download this
    #declare all filenames
    $filename1 = 'one.txt';
    $filename2 = 'two.txt';
    $filename3 = 'three.txt';
    
  2. or download this
    #open text file 1
    
    open (FILE1, $filename1) or die "Unable to open $filename1 because $!\
    +n";
    
  3. or download this
    # Store the contents of the first file into $hash{col1_col2}
    
    ...
        $hash{$key1}++;
    };
    close FILE1;
    
  4. or download this
    while ($line = <FILE2>) {
        chomp ($line);
    ...
        $hash{key2}++
    }
    };
    
  5. or download this
    while ($line = <FILE2>) {
        chomp ($line);
    ...
            $hash{key2}++
        }
    };
    
  6. or download this
    open (FILE2, $filename2) or die "Unable to open $filename2 because $!\
    +n";
    
    ...
    }
    };
    close FILE2;
    
  7. or download this
    sub process_file {
        my $filename = shift or die "Missing filename!";
    ...
        }
        close FILE;
    }
    
  8. or download this
    process_file($filename2);
    process_file($filename3);