Home / Interview / Perl :: General Questions

Interview :: Perl

81)

What does file test operators do in Perl?

File test operators check miscellaneous information about a file, for example, the type of file, file byte size, its UID or GID, etc.

82) How to open a directory in Perl?

The opendir function is used to open a directory in Perl. It returns true on success or false on failure.

83) How to create a directory in Perl?

The mkdir function is used to create a directory in Perl. You need a require permission to create a directory.

84) How to read a directory in Perl?

The readdir function is used to read a directory in Perl. In scalar context, it will return each item one by one. In list context, it will return all the content of the directory in one statement. So list context uses more memory than scalar context.

85) How to remove a directory in Perl?

The rmdir function is used to remove a directory in Perl. The directory which you want to remove should be empty before removing it.

86) How to change a directory in Perl?

The chdir function is used to change a directory in Perl. To change a directory and go inside a new directory you need required permission.

87) How to close a directory in Perl?

The closedir function is used to close a directory in Perl. This function officially shut down the connection between directory handle and directory.

88)

What is a chop() function in Perl?

Perl chop() function removes the last character from a string regardless of what that character is. It returns the chopped character

89)

What is a chomp() function in Perl?

Perl chomp() function removes any newline character from the end of the string. It returns the number of characters removed from the string.

90)

What does a die() function do in Perl?

Perl die() function gives us a proper error message. It immediately terminates the script on encountering an error.