Operator Function
-e Tests if OPERAND exists.
-f Tests if OPERAND is a regular file as opposed to a directory,symbolic link or other type of file
-l Tests if OPERAND is a symbolic link
-s Returns size of OPERAND in bytes
-d Tests if OPERAND is a directory.
-T Tests if OPERAND is a text file.
Example:
#!/usr/bin/perl
if(-e "/tmp/test.pl")
{
print "File/directory exists.";
}
if(-f "/tmp/test.pl")
{
print "File exists";
}
$size = -s "/tmp/test.pl";
print "Size of /tmp/test.pl is $size bytes";
-e Tests if OPERAND exists.
-f Tests if OPERAND is a regular file as opposed to a directory,symbolic link or other type of file
-l Tests if OPERAND is a symbolic link
-s Returns size of OPERAND in bytes
-d Tests if OPERAND is a directory.
-T Tests if OPERAND is a text file.
Example:
#!/usr/bin/perl
if(-e "/tmp/test.pl")
{
print "File/directory exists.";
}
if(-f "/tmp/test.pl")
{
print "File exists";
}
$size = -s "/tmp/test.pl";
print "Size of /tmp/test.pl is $size bytes";
No comments:
Post a Comment