Fantasy monks,
Apologies If this has been discussed already,
# Program : 1
#!/usr/bin/perl
use strict;
my $match = 'A';
my @array = qq[Anthony Mark Alex A];
if ( grep( /^$match/,@array ) ) {
print "Matched\n";
}
Output :
Matched
# Program : 2
#!/usr/bin/perl
use strict;
my $match = 'A';
my @array = qq[Anthony Mark Alex A];
if ( grep( /$match$/,@array ) ) {
print "Matched\n";
}
<code>
Output :
Matched
# Program : 3
#!/usr/bin/perl
use strict;
my $match = 'A';
my @array = qq[Anthony Mark Alex A];
if ( grep( /^$match$/,@array ) ) {
print "Matched\n";
}
What is the problem with the 3rd program ? am I missing something there ?