#!C:/Perl/bin/perl -w
my $string = "Hi, this is Rabindra Nayak! I work on Perl Scripting on UNIX platform.";
my $searchText = getText( $string, 'on', 'on' );
print $searchText;
sub getText
{
return $1 if ( $_[0] =~ /$_[1] (.*?) $_[2]/ );
}
Output : Perl Scripting
my $string = "Hi, this is Rabindra Nayak! I work on Perl Scripting on UNIX platform.";
my $searchText = getText( $string, 'on', 'on' );
print $searchText;
sub getText
{
return $1 if ( $_[0] =~ /$_[1] (.*?) $_[2]/ );
}
Output : Perl Scripting