A string in Perl is a scalar variable and start with a ($) sign and it can contain alphabets, numbers, special characters. The string can consist of a single word, a group of words or a multi-line paragraph. The String is defined by the user within a single quote (‘) or double quote (“).
Perl provides various functions to manipulate the string like any other programming language.
Length: 13 To Upper Case: GEEKSFORGEEKS
Some string functions of Perl are as follows:
|chomp()||Used to remove the last trailing newline from the input string|
|length()||Finds length (number of characters) of a given string, or $_ if not specified|
|substr()||Returns a substring out of the string passed to the function starting from a given index up to the length specified|
|uc()||Returns the string passed to it after converting it into uppercase|
|ucfirst()||Returns the string VAR or $_ after converting the First character to uppercase|
|lc()||Returns a lowercased version of VAR, or $_ if VAR is omitted|
|lcfirst()||Returns the string VAR or $_ after converting the First character to lowercase|
|chr()||Returns a string representing a character whose Unicode code point is an integer|
|chop()||Returns a string representing a character whose Unicode code point is an integer|
|index()||Returns the position of the first occurrence of given substring (or pattern) in a string (or text)|
|rindex()||Returns the position of the last occurrence of the substring (or pattern) in the string (or text)|
|sprintf()||Uses Format provided by the user to return the formatted string with the use of the values in the list|
|ord()||Returns the ASCII value of the first character of a string|
|quotemeta()||It escapes all meta-characters in the value passed to it as parameter|
|split()||Used to split or cut a string into smaller sections or pieces|
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.