Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I'm trying to upgrade some code to run correctly in Perl 5.14. However, I still need it to work in older version of perl.

I would like to have certain code execute only if Perl 5.14 is detected. Essentially I'm looking for something similar to the #if MACRO #endif construct in C.

My specific use case is that I need use re '/d/'; in order for some existing regular expressions to want with 5.14 but earlier Perl versions will give a compile error if I add this pragma.

Considering that /d is the default, why even bother? If you aren't using use re '/l'; or use re '/u'; in an outer scope, there's no need to do use re '/d'; in an inner. Quoting from perlre:
If none of the above apply, for backwards compatibility reasons, the "/d" modifier is the one in effect by default. As this can lead to unexpected results, it is best to specify which other rule set should be used.

In reply to Re: Conditionally executing different code based on Perl Version by JavaFan
in thread Conditionally executing different code based on Perl Version by dlarochelle

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-04-24 09:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found