Learning to write programs is not easy. In the beginning there is too much information, making it difficult to distinguish what is important and difficult to know what to do. To overcome these difficulties, you should follow an introductory course in programming. If you are studying on your own, you can find recommendations in Getting Started with Perl (I suggest you start with Where and how to start learning Perl). Find a tutorial introduction and follow it step by step. Don't rush. Study each example carefully to ensure you understand it before moving on. Be patient and diligent.
It is particularly difficult to learn how to break a complex problem down into simpler problems that can be solved more easily. I think How to Design Programs gives a gentle introduction. It uses Scheme rather than Perl, but the programming skills it teaches can be applied to other languages, including Perl.
You have been given very good guidance in other responses to your posts here. I wonder if you have read the documentation referenced in those responses. You should read the documentation carefully. If there is anything you don't understand, you can ask questions here.
In the mean time, here is a program which matches the strings in your file. You should compare this to the other answers you have been given. It is quite consistent and you should try to understand how to progress from the recommendations in those other answers to a program like this, step by step.
use strict;
use warnings;
# Read the entire file contents into $content
my $file = 'test.txt';
open(my $fh, '<', $file) or die "$file: $!";
my $content = do { local $/; <$fh> };
close($fh);
# Remove newlines and "\\n" sequences
$content =~ s/\n|\\n//g;
# Match strings
my @matches = $content =~ m/saravanan/g;
print "@matches\n";
|