if ($LogLinePrefix =~ /[][^$_*?.|(){}\\]*/)
    {
        $LoglinePrefix =~ s/([][^$_*?.|(){}\\]*)/\\{$1}/g;
    }

Just a point - no need to do this twice.  Either:
        $LoglinePrefix =~ s/([][^$_*?.|(){}\\]*)/\\{$1}/g;

or, if you want to do something else if it matches:
if ($LogLinePrefix =~  s/([][^$_*?.|(){}\\]*)/\\{$1}/g ) {
  # do something as we've got a metachar
    }

You're going to end up w/:
$LogLinePrefix eq "hi_mom*";
becoming:
$LogLinePrefix eq "hi\{_}mom\{*}";

if that's what you want.  For tidiness sake, you probably should do:
        $LoglinePrefix =~ s/([][^$_*?.|(){}\\]+)/\\{$1}/g;

as '*', meaning 'zero or more' could match the empty string.  If nothing 
else, it'll be faster.  Now, this is an ugly list of chars, if what you 
really want to escape is 'anything beside letters and numbers' (are you 
sure you got them all ;-):
        $LoglinePrefix =~ s/([^a-zA-Z0-9]+)/\\{$1}/g;

a negative char class is the way to go.  That's the 'naive' version, in 
that it works only for ascii. Preference is to use POSIX classes:
        $LoglinePrefix =~ s/([[:^alnum:]]+)/\\{$1}/g;

as that'll handle locale and other issues (Unicode, for example).

a

Andy Bach, Sys. Mangler
Internet: [EMAIL PROTECTED] 
VOICE: (608) 261-5738  FAX 264-5932

In 1998 the pharmaceutical industry spent $5.7 billion on marketing 
directly to physicians -- that's $6,000 to $7,000 per doctor.

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to