Interview :: Perl
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.
The opendir function is used to open a directory in Perl. It returns true on success or false on failure.
The mkdir function is used to create a directory in Perl. You need a require permission to create a directory.
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.
The rmdir function is used to remove a directory in Perl. The directory which you want to remove should be empty before removing it.
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.
The closedir function is used to close a directory in Perl. This function officially shut down the connection between directory handle and directory.
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
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.
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.