in reply to Re^3: search of a string in another string with 1 wildcard
in thread search of a string in another string with 1 wildcard

How do you find this?

my @matches = ( qr/abcdef/, qr/abfdef/,#for simplicity, limited to 2 choices ); if ($line ~~ @matches){ ... }

Replies are listed 'Best First'.
Re^5: search of a string in another string with 1 wildcard
by AnomalousMonk (Archbishop) on Oct 12, 2014 at 20:48 UTC

    Perhaps:

    c:\@Work\Perl>perl -wMstrict -le "my @matches = (qr/abcdef/, qr/abfdef/); ;; for my $line (qw(xxxx abcd abcdef xabcdefx xabcdefxabfdefx)) { if ($line ~~ @matches){ print qq{match for '$line'}; } else { print qq{NO match: '$line'}; } } " NO match: 'xxxx' NO match: 'abcd' match for 'abcdef' match for 'xabcdefx' match for 'xabcdefxabfdefx'

    Please see docs on smart matching in perlsyn or perlop depending on your Perl version. (Please also note that there have been second thoughts about smart matching and it is now considered 'experimental': proceed at your own risk.