Perl | Useful String functions Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report 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. Example: Perl # Perl program to demonstrate # string length function # string my $s = "geeksforgeeks"; # using length function & # displaying length print("Length: ", length($s)); # Converting to Uppercase print("\nTo Upper Case: "); print(uc($s), "\n"); Output: Length: 13 To Upper Case: GEEKSFORGEEKS Some string functions of Perl are as follows: Function Description 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 Comment More info A Abhinav96 Follow Improve Article Tags : Perl Perl-String Perl-function Perl-String-Functions Explore BasicsPerl Programming Language3 min readIntroduction to Perl9 min readPerl Installation and Environment Setup in Windows, Linux, and MacOS3 min readPerl | Basic Syntax of a Perl Program10 min readHello World Program in Perl3 min readFundamentalsPerl | Data Types3 min readPerl | Boolean Values3 min readPerl | Operators | Set - 112 min readPerl | Operators | Set - 27 min readPerl | Variables4 min readPerl | Modules3 min readPackages in Perl4 min readControl FlowPerl | Decision Making (if, if-else, Nestedâif, if-elsif ladder, unless, unless-else, unless-elsif)6 min readPerl | Loops (for, foreach, while, do...while, until, Nested loops)7 min readPerl | given-when Statement4 min readPerl | goto statement3 min readArrays & ListsPerl | Arrays6 min readPerl | Array Slices3 min readPerl | Arrays (push, pop, shift, unshift)3 min readPerl List and its Types4 min readHashPerl Hash4 min readPerl | Hash Operations8 min readPerl | Multidimensional Hashes6 min readScalarsPerl | Scalars2 min readPerl | Comparing Scalars6 min readPerl | scalar keyword2 min readStringsPerl | Quoted, Interpolated and Escaped Strings4 min readPerl | String Operators4 min readPerl | String functions (length, lc, uc, index, rindex)4 min readOOP ConceptsObject Oriented Programming (OOPs) in Perl7 min readPerl | Classes in OOP6 min readPerl | Objects in OOPs6 min readPerl | Methods in OOPs5 min readPerl | Constructors and Destructors4 min readPerl | Method Overriding in OOPs6 min readPerl | Inheritance in OOPs7 min readPerl | Polymorphism in OOPs4 min readPerl | Encapsulation in OOPs6 min readRegular ExpressionsPerl | Regular Expressions2 min readPerl | Operators in Regular Expression4 min readPerl | Regex Character Classes3 min readPerl | Quantifiers in Regular Expression4 min readFile HandlingPerl | File Handling Introduction7 min readPerl | Opening and Reading a File4 min readPerl | Writing to a File3 min readPerl | Useful File-handling functions2 min read Like