From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
        Sent: 26 August 2005 13:26
        To: [email protected];
[EMAIL PROTECTED];
[email protected]
        Subject: Metacharacters
        
        

        Morning, 

Afternoon
        
        I am working on some code which will check for a line starting
with any Perl Metacharacters, and precede it with a '/'. 
        Here is what i have thus far: 
        
                                if ($LogLinePrefix =~
/[\^\$\+\*\?\.\|\(\)\{\}\\\[\]]/) 
                                        { 
                                                $LoglinePrefix =~
s/[\^\$\+\*\?\.\|\(\)\{\}\\\[\]]*/\\{$1}/g ; 
                                        } 
        
        Unfortunately, this isn't working.  Can anyone make a
suggestion?
        
Just to be different ...

If you intend interpolating your variable into a regex, then
/\Q$LogLinePrefix\E.../ should do the trick (see 'perldoc perlop', look
for quote like operators).

HTH

-- 
Brian Raven
 


-----------------------------------------------------------------------
The information contained in this e-mail is confidential and solely 
for the intended addressee(s). Unauthorised reproduction, disclosure, 
modification, and/or distribution of this email may be unlawful. If you 
have received this email in error, please notify the sender immediately 
and delete it from your system. The views expressed in this message 
do not necessarily reflect those of LIFFE Holdings Plc or any of its subsidiary 
companies.
-----------------------------------------------------------------------


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

Reply via email to