Skip to content

PerlTextManipulation

gad14 edited this page Sep 14, 2010 · 11 revisions

Basic Input/Output

STDIN, STDOUT, STDERR, ‘<> Diamond operator’

Reading and writing files

Filehandles

open(FILEHANDLE,"filename");

Open a file for reading

open(IN,"my_data.txt") or die "Can't find file:$!\n";

Open a file for writing

open(OUT,">my_output.txt") or die "Can't open output file"$!\n";

Close file

close(IN); close(OUT);

Get file name from STDIN from user and open

my $input_file = $ARGV[0];
open(IN,$input_file);

Parsing tab delimited files

Regular expressions

Clone this wiki locally