Perl | rindex() Function Last Updated : 20 Nov, 2019 Comments Improve Suggest changes Like Article Like Report rindex() function in Perl operates similar to index() function, except it returns the position of the last occurrence of the substring (or pattern) in the string (or text). If the position is specified, returns the last occurrence at or before that position. Syntax: # Searches pat in text from given Position rindex text, pattern, Position # Searches pat in text rindex text, pattern Parameters: text: String in which substring is to be searched. pat: Substring to be searched. index: Starting index(set by the user or it takes zero by default). Returns: -1 on failure otherwise position of last occurrence. Example 1: Perl #!/usr/bin/perl -w $pos = rindex("WelcomeToGeeksforGeeksWorld", "eks"); print "Position of eks: $pos\n"; # Use the first position found as the offset # to the next search. # Note that the length of the target string is # subtracted from the offset to save time. $pos = rindex("WelcomeToGeeksforGeeksWorld", "eks", $pos - 3 ); print "Position of eks: $pos\n"; Output: Position of eks: 19 Position of eks: 11 Example 2: Perl #!/usr/bin/perl -w $pos = rindex("GeeksforGeeks", "eks"); print "Position of eek: $pos\n"; # Use the first position found as the # offset to the next search. # Note that the length of the target string is # subtracted from the offset to save time. $pos = rindex("GeeksForGeeks", "eks", $pos - 2); print "Position of eek: $pos\n"; Output: Position of eek: 10 Position of eek: 2 Comment More infoAdvertise with us Next Article Perl | rindex() Function C Code_Mech Follow Improve Article Tags : Perl Perl-function Perl-String-Functions Similar Reads Learn Free Programming Languages In this rapidly growing world, programming languages are also rapidly expanding, and it is very hard to determine the exact number of programming languages. Programming languages are an essential part of software development because they create a communication bridge between humans and computers. No 9 min read Perl Programming Language Perl is a general purpose, high level interpreted and dynamic programming language. Perl supports both the procedural and Object-Oriented programming. Perl is a lot similar to C syntactically and is easy for the users who have knowledge of C, C++. Since Perl is a lot similar to other widely used lan 3 min read Perl | Regex Cheat Sheet Regex or Regular Expressions are an important part of Perl Programming. It is used for searching the specified text pattern. In this, set of characters together form the search pattern. It is also known as regexp. When user learns regular expression then there might be a need for quick look of those 6 min read Perl | split() Function split() is a string function in Perl which is used to split or you can say to cut a string into smaller sections or pieces. There are different criteria to split a string, like on a single character, a regular expression(pattern), a group of characters or on undefined value etc.. The best thing abou 8 min read Perl Tutorial - Learn Perl With Examples How to Run a Perl Program? Let's consider a simple Hello World Program. perl #!/usr/bin/perl # Modules used use strict; use warnings; # Print function print("Hello World\n"); Generally, there are two ways to Run a Perl program- Using Online IDEs: You can use various online IDEs which can b 15+ min read Introduction to Perl Perl is a general-purpose, high level interpreted and dynamic programming language. It was developed by Larry Wall, in 1987. There is no official Full form of the Perl, but still, the most used expansion is "Practical Extraction and Reporting Language". Some of the programmers also refer Perl as the 9 min read Perl | Polymorphism in OOPs Polymorphism is the ability of any data to be processed in more than one form. The word itself indicates the meaning as poly means many and morphism means types. Polymorphism is one of the most important concepts of object-oriented programming languages. The most common use of polymorphism in object 4 min read Perl | Loops (for, foreach, while, do...while, until, Nested loops) Looping in programming languages is a feature which facilitates the execution of a set of instructions or functions repeatedly while some condition evaluates to true. Loops make the programmers task simpler. Perl provides the different types of loop to handle the condition based situation in the pro 7 min read Perl | Arrays In Perl, array is a special type of variable. The array is used to store the list of values and each object of the list is termed as an element. Elements can either be a number, string, or any type of scalar data including another variable. Example: @number = (50, 70, 46); @names = ("Geeks", "For", 6 min read Perl | substr() function substr() in Perl returns a substring out of the string passed to the function starting from a given index up to the length specified. This function by default returns the remaining part of the string starting from the given index if the length is not specified. A replacement string can also be passe 2 min read Like