use warnings; use strict; my $string = "Viood_ram_shiva_RVCT22"; if ($string =~ /(\w+)_RVCT/) { print "The file name is $1. "; }