Google News
logo
Perl - Quiz(MCQ)
For extracting a substring, ____ function is used.
A)
index
B)
substr
C)
string
D)
length

Correct Answer :   substr


Explanation :

The substr function extracts a particular substring from a string based on the value of specified indices. For example,
$x= “abcdefghijklm”
$y= substr( $x, -3,2);   // extracts two characters from the third position on the right side
print “$y”;             // prints kl

Advertisement