in reply to search one instance
I'm not sure I understand your question, but why not the following?
#!/usr/bin/perl use strict; use warnings; my $string = 'data' x 20; if ($string =~ m/data/) { print "Matching '$&'", "\n"; } print 'from $string which has value of ', "$string\n"; #Output: #Matching 'data' #from $string which has value of datadatadatadatadatadatadatadatadatad +atadatadatadatadatadatadatadatadatadatadata
In Section
Seekers of Perl Wisdom