Test in Perl
Test in Perl
AND TEXT IN
PERL
By
Vishnupriya v v
FileHandle
Associates a name to an external
file,
▸ can be used until the end of the
program or until the FileHandle is closed
Introduction It is like a connection to modify the contents of an
external file
Three basic FileHandles
STDIN- Standard Input device
STDOUT- Standard Output device
STDERR-Standard Error device
Basic File Handles
Reading the information from standard input file
and Output to Standard Output
Basic file
handles print “What is your name?\n”;
$name = <STDIN>;
print “Hello $name\n”;
open(FileHandle, Mode, FileName);
File
Handling Parameters:
open and FileHandle- The reference to the file, used within the
program.
close Mode- Mode in which a file is to be opened.
FileName- The name of the file to be opened.
Expression-Mode and FileName clubbed together.
“<” Open(DATA,
Read Only Mode
“<file.txt”);
Reads and Writes but
“+<“ open(DATA,
does NOT Create
“+<file.txt”);
Different Creates file (if
open(DATA,
modes in “>” necessary), Clears the
contents of the File and
“>file.txt”);
file “>>”
Writes to it
open(DATA,
“>>file.txt”);
handling Creates file (if
necessary), Appends to
open (DATA,
“+>” the File
“+>file.txt”);
Creates file (if
open(DATA,”+>
“+>>” necessary), Clears, >file.txt”);
Reads and Writes
CHOP() Sa = "AEIOU";chop
($a);print "Sa\n";
$a = "AEIOU";
$b = chop($a);
Example-
Another perl
test
operator
Perl THANKYOU