Professional Documents
Culture Documents
Perl Doc6
Perl Doc6
do
{
$line=readdir(D1);
if($line eq "my_nums")
{
print "file is found\n";
exit;
}
}while($line ne "");
closedir(D1);
Ex: create a new file in the specified directory
Unlink(): removes a file
remove(): removes a file
Ex: program to remove a file
rename(oldfile,newfile): renames a file
link(filename, linkname): creates hard links
symlink(filename,linkname): creates symbolic links
chmod(perms,filename): changes file permissions
Random access files
seek() and tell() helps us to access files randomly.
seek(filevariable, distance, relative_to): moves file pointer from
one place to another.
distance: specifies how many bytes to move
Relative_to: specifies from which location, the pointer has to be
moved.0 indicates from beginning, 1 indicates from current
position and 2 indicates the end of the file.
tell(filevariable): specifies where the file pointer is currently.
Subroutines
Invoking a subroutine
To call a subroutine, prefix the name of it with an “&” symbol.
Ex:
&subroutine_name([arguments]);