jesuashok has asked for the wisdom of the Perl Monks concerning the following question:
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
What is the problem with the 3rd program ? am I missing something there ?# Program : 3 #!/usr/bin/perl use strict; my $match = 'A'; my @array = qq[Anthony Mark Alex A]; if ( grep( /^$match$/,@array ) ) { print "Matched\n"; }
Back to
Seekers of Perl Wisdom