perlintro, Regexp::Wildcards, Modern Perl a loose description of how experienced and effective Perl 5 programmers work....You can learn this too.
#!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd /; Main( @ARGV ); exit( 0 ); sub Main { MainOne(); MainToo(); } sub MainOne { my @fields = ( 'I foo', 'foo who?', 'the foo and the moo' ); my @querys = qw/ foo% %foo% %f%o% /; for my $field ( @fields ) { for my $search ( @querys ) { my $re = WildcardRe( $search ); if( $field =~ m{$re}i ) { dd( { andthe => $field, has => $search, says => $re } +); } } } } ## end sub Main sub WildcardRe { ## todo update with Regexp::Wildcards my( $search ) = @_; my @parts = split /%/, $search; $_ = quotemeta( $_ ) for @parts; my $re = join '.+', @parts; $re = '^' . $re . '$'; return $re; } ## end sub WildcardRe sub MainToo { my @fields = ( 'I foo', 'foo who?', 'the foo and the moo' ); my @querys = qw/ foo% %foo% %f%o% /; @querys = map { [ $_, WildcardRe( $_ ) ]; } @querys; for my $field ( @fields ) { for my $query ( @querys ) { my( $search, $re ) = @$query; if( $field =~ m{$re}i ) { dd( { andthe => $field, has => $search, says => $re } +); } } } } ## end sub MainToo

ppi_dumper can tell you what manual to look up the basic perl syntax in ... like perlsyn ... example of this Re: use constant usage clarification (Deparse)


In reply to Re: Need to append and replace for % sign in a variable string ( Regexp::Wildcards->new( type => 'sql') by Anonymous Monk
in thread Need to append and replace for % sign in a variable string by jayd11

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.