Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

If your noddy (a.k.a. "play") script works and the real script does not, then your noddy script isn't doing the same thing as your real program. In software there is an ocean of difference between "isn't much different" and "isn't different". When it comes to failing to find bugs, most of the reasons are swimming in that ocean.

The usual strategy for tracking down a bug like this is to start with the real code and strip it down bit by bit until you have nothing but the bare essentials but can reproduce the problem. In the process, you may find the reason for your bug, which is great. If not, you will have a nice focused example that you can post here. Without code that reproduces the bug, the most anyone can give you is general observations about what sometimes trips some people up when they work with regular expressions. That probably won't be very useful to you.

As you strip down your code one thing you might want to pay special attention to is failing regexen in previously executed lines. If a regex fails the variables normally set by the regex will retain their previous values. They won't be set to undefined. That sometimes trips people up. From perlre:

NOTE: Failed matches in Perl do not reset the match variables, which makes it easier to write code that tests for a series of more specific cases and remembers the best match.

GrandFather has some excellent tips for stripping down your code in his post I know what I mean. Why don't you?.

Best, beth


In reply to Re: Regular Expressions not matching by ELISHEVA
in thread Regular Expressions not matching by Mak3r

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    [hippo]: Make it an option?
    [Corion]: hippo: Yes, but I'm not sure that it's even worth the effort of implementing it at all...
    [Corion]: You'll only ever need that option if you have a long-running query whose results are not cached by your DB already, and in those cases I presume that the programmer will want to maintain the temporary tables themselves - I wouldn't know when to drop ...
    [Corion]: ... the temporary tables, and also don't have a good idea on how to create unique table names for them
    [hippo]: OIC. In that case leave it out but invite feature requests and see if any of the users suggest it. :-)
    [Corion]: Talking about this makes me realize that it's likely only a half useful idea. But it still would be convenient to have as an option...
    [Corion]: hippo: Hmmm - yeah, I could document it and wait for code implementing that option to show up ;-D

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (10)
    As of 2017-02-23 15:34 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Before electricity was invented, what was the Electric Eel called?






      Results (347 votes). Check out past polls.