#!/usr/bin/perl use strict; use warnings; my $text = 'abcd@efgh@ijk@lmn@opq@rst'; my $str_index = length($text) -1 - index( reverse( $text ), '@', 0 ); print "str_index: $str_index\n";