Hi, all --

So I have this mp3 database script idea and I'm starting to move into it
(it feels good to think perlishly again, and I'm going to want to be able
to ignore case or not and search on substrings or not in my code.  That's
always been a problem for me: how can I modify my behavior based on
conditions?

Clearly I could do something like (but probably not exactly like; I have
no idea whether or not this would parse but instead just want to set the
example)

  if ( $WholeMatchOnly )
  {
    if ( $IgnoreCase )
      { /^\($pattern\)$/i }
    else
      { /^\($pattern\)$/ }
  }
  else
  {
    if ( $IgnoreCase )
      { /\($pattern\)/i }
    else
      { /\($pattern\)/ }
  }

but that, even sucked up like it is, is long, drawn-out, and a stinker to
maintain.  Is there a way to do something like

  if ( $WholeMatchOnly )
    { $ABeg = '^' ; $AEnd = '\$' }
  if ( $IgnoreCase )
    { $MOpts =. 'i' }

  /$ABeg$pattern$AEnd/$MOpts

so that the match is configured dynamically based on the conditions
going into it?


TIA & HAND

:-D
-- 
David T-G                      * It's easier to fight for one's principles
(play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie
(work) [EMAIL PROTECTED]
http://www.justpickone.org/davidtg/    Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

Attachment: msg25599/pgp00000.pgp
Description: PGP signature

Reply via email to