Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Test regex compile

by TomDLux (Vicar)
on May 13, 2004 at 18:10 UTC ( #353166=note: print w/replies, xml ) Need Help??


in reply to Test regex compile

Let's re-phrase the question to: Is there a way that I can test prior to running a progrgam whether or not a regular expression will compile.

The answer is Yes, use the -c flag when invoking perl. You can use: Perl -c myprogram, or you might make the program read in the regex from an external file ... possibly specifying which file on the command line. Then you only have to test the regex file: Perl -c regexfile.

--
TTTATCGGTCGTTATATAGATGTTTGCA

Replies are listed 'Best First'.
Re: Re: Test regex compile
by flyingmoose (Priest) on May 13, 2004 at 19:28 UTC
    That doesn't work if the regex is passed in as a parameter, say if you are doing something screwy like loading it from a database. The way to do that is probably to check at startup, or otherwise write another program, to run eval-block type tests on each of the many regexes that can be imported.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://353166]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2023-02-07 14:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (40 votes). Check out past polls.

    Notices?