in reply to TMTOWTDI isn't best in this case

Depending on your SQL implementation and your performance requirements, you could consider doing something like:
  
SELECT * FROM table WHERE file_format LIKE 'p%$b%.zip'
   MeowChow                                   
               s aamecha.s a..a\u$&owag.print

Replies are listed 'Best First'.
Re: (MeowChow) Re: TMTOWTDI isn't best in this case
by princepawn (Parson) on Jul 24, 2001 at 03:22 UTC
    Your SELECT will miss this case:
    p${b}.zip
    which is one of the ones I listed.

    And while I'm replying to things, Ovid, the SELECT * was just an example of what I'm doing, I am being explicit about which rows I am getting.

      But p${b}.zip is the same as p$b.zip, thus interpolating $b and eliminating the braces. If you're unsure of this, you can do the following:

      my $b=7; print ${b};

      That prints 7, thus making MeowChow's solution a viable one. I know it looks odd, but it's valid Perl and it works with warnings and strict. I'm using 5.6.1. Does this fail on other versions of Perl?

      Cheers,
      Ovid

      Vote for paco!

      Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

      I originally had it as 'p%b%', but changed it after thinking (apparently incorrectly) that $b was an interpolated value. Implementation trivia notwithstanding, the principle is the same.
         MeowChow                                   
                     s aamecha.s a..a\u$&owag.print