Perl 5 String Functions
Function Syntax Description
chomp chomp($scalar); Removes only a newline character from the end of a string
chop chop($scalar); Removes the last character of each element of the input list
chr chr(number); Translates a number into a character
index index(searchString, substring, beginningSearchPosition); Returns the first position of a substring
join join(delimiter, list); Creates a single delineated string from an input list
lc lc(expression); Changes all the characters in the expression to lowercase
lcfirst lcfirst(expression); Changes only the first character of the expression to lowercase
length length(expression); Returns the number of characters in a string
ord ord(expression); Converts ASCII characters into their numeric value
pack pack TEMPLATE, inputList; Takes one or more character codes and translates the corresponding character(s) to the format specified
rindex rindex (searchString, substring, startPosition); Returns the last position of a substring
split split(/pattern/,expression, maxSplit); Separates the expression into parts
s/(substitute) $searchString =~ s/oldPattern/newPattern/; Substitutes one string for another string
substr substr(expression,startingPosition,length); Returns or modifies a substring
tr (translate) $input =~ tr/searchString/replacementString/ Exchanges each occurrence of a character in the search string with its matching character in the replacement string
uc uc(expression); Changes all the characters in the expression to uppercase
ucfirst ucfirst(expression); Changes only the first character of the expression to uppercase
Related examples in the same category