Home / Interview / Perl :: General Questions

Interview :: Perl

51)

What is the difference between single (') and double (") quote in a string in Perl?

In the single quote, the value is printed as it is given inside the string without interpolation.

In the double quote, the value is printed with interpolation given inside the string.

52)

Explain substr function in Perl?

The substr function is used to truncate the string. The string will be truncated to offset value we provide.

53)

How to compare two strings in Perl?

To compare two strings in Perl eq is used instead of (==). It checks whether two strings are equal or not.

54)

How to determine strings length in Perl?

String length can be determined with length() function.

55)

How to print escaping characters inside a string in Perl?

Escaping characters are the special characters like @, \, /, &, $, ", etc. To print escaping characters put a backslash (\) before escaping characters.

56)

What is qq (double q)operator in Perl?

The qq operator replaces double quote surrounding a string by its parentheses. You can use qq instead of (").

57)

What is q (single q) operator in Perl?

The q operator replaces single quote surrounding a string by its parentheses. You can use q instead of (').

58)

What is STDIN in Perl?

The STDIN stands for standard input. Using this input, we can get input from the standard console. It can be abbreviated as .

59)

What is goto statement in Perl?

The Perl goto statement is the jump statement. It transfers control by jumping to another label inside a loop.

There are three goto forms:

  • goto LABEL
  • goto EXPR
  • goto &NAME

60)

How to do comment in Perl?

Like other languages, Perl also provides comment facility in its code. There are a single line and multi-line comment.

For single line comment: use # before the line you want to comment.

For multi-line comment: use =begin and =cut statement before and after the lines respectively you want to comment.