'cooking' regex's

Discussion in 'Perl Misc' started by Smitty, Nov 22, 2005.

  1. Smitty

    Smitty Guest

    I can't find any reference to 'cooking' regular expressions in any of
    my three perl books (Llama, Camel, Panther).

    Such such a thing exist, and if so, should I worry about 'raw' regex's
     
    Smitty, Nov 22, 2005
    #1
    1. Advertising

  2. Smitty

    Smitty Guest

    Smitty wrote:
    > Such such a thing exist, and if so, should I worry about 'raw' regex's


    Sorry:

    Does such a thing exist, and if so, should I worry about 'raw' regex's
    ?
     
    Smitty, Nov 22, 2005
    #2
    1. Advertising

  3. Smitty

    Paul Lalli Guest

    Smitty wrote:
    > I can't find any reference to 'cooking' regular expressions in any of
    > my three perl books (Llama, Camel, Panther).


    I have no idea what that means.

    if ($recipe =~ /bake/) { print "Bake this recipe\n" }

    ???

    > Such such a thing exist, and if so, should I worry about 'raw' regex's


    s/raw eggs/fried eggs/;

    ???

    What are you trying to ask?

    Paul Lalli
     
    Paul Lalli, Nov 22, 2005
    #3
  4. "Smitty" <> writes:

    > I can't find any reference to 'cooking' regular expressions in any of
    > my three perl books (Llama, Camel, Panther).
    >
    > Such such a thing exist, and if so, should I worry about 'raw' regex's


    Let's see if I follow you correctly first. In some languages (notably C),
    there's a separate regex library. In those languages you have to call a
    function that takes a regex pattern as a string (a "raw" regex), and returns
    a pointer to a structure containing the "cooked" (compiled) regex, which is
    essentially a representation of a finite state machine. Then you run that
    state machine against one or more strings to perform the matching operation.

    If that's what you're referring to, then no - In Perl, you don't need to
    worry about it, for the most part. The whole process of compiling regex
    string patterns into finite state machines is handled behind the scenes,
    so you rarely even need to be aware of it.

    This is, in fact, a standout feature of the language - some other languages
    are catching up recently, but Perl has had smooth integration of regular
    expressions into the core language from the beginning.

    If you're curious, have a look at "perldoc perlop", in the section "Gory
    details of parsing quoted constructs". It has some details about how "raw"
    regexes are handled, and how you can get a look at the "cooked" results.

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
     
    Sherm Pendley, Nov 22, 2005
    #4
  5. Smitty

    Guest

    "Smitty" <> wrote:
    > I can't find any reference to 'cooking' regular expressions in any of
    > my three perl books (Llama, Camel, Panther).


    Surely there an *infinite* number of things that you can't find a reference
    for in any of your three perl books. Are you going to ask us about all of
    them?

    > [Does] such a thing exist, and if so, should I worry about 'raw' regex's


    I assume that something referenced 'cooking' regex, or else why would you
    ask about it? Could you please give us some context by telling us what it
    was that did referenced this?

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Nov 22, 2005
    #5
  6. Smitty

    Smitty Guest

    wrote:
    > "Smitty" <> wrote:
    > > I can't find any reference to 'cooking' regular expressions in any of
    > > my three perl books (Llama, Camel, Panther).

    >
    > Surely there an *infinite* number of things that you can't find a reference
    > for in any of your three perl books. Are you going to ask us about all of
    > them?


    Dude, what is your problem. Were you born an ass, or is it something
    you have been perfecting since you started monitoring this newsgroup;
    or, is this some personal vendetta against me ?

    >
    > > [Does] such a thing exist, and if so, should I worry about 'raw' regex's

    >
    > I assume that something referenced 'cooking' regex, or else why would you
    > ask about it? Could you please give us some context by telling us what it
    > was that did referenced this?


    Since you asked, I am in the unenviable position of having to maintain
    some other (supposedly experienced) developers' perl code. In it there
    are several global variables which get assigned regex's as their
    values, with a comment that says "Make sure the regex's are
    pre-cooked". My question is very straight-forward, and clear. Does
    such a thing [as a 'cooked' regex] exist [in perl] ?

    I frequently ask very general questions to ensure I don't 'taint' any
    answers I might get. This is a subtle tactic; one that I wouldn't
    expect you to understand, so don't bother commenting.

    >
    > Xho
    >
    > --
    > -------------------- http://NewsReader.Com/ --------------------
    > Usenet Newsgroup Service $9.95/Month 30GB
     
    Smitty, Nov 22, 2005
    #6
  7. Smitty

    Smitty Guest

    Sherm Pendley wrote:
    > "Smitty" <> writes:
    >
    > > I can't find any reference to 'cooking' regular expressions in any of
    > > my three perl books (Llama, Camel, Panther).
    > >
    > > Such such a thing exist, and if so, should I worry about 'raw' regex's

    >
    > Let's see if I follow you correctly first. In some languages (notably C),
    > there's a separate regex library. In those languages you have to call a
    > function that takes a regex pattern as a string (a "raw" regex), and returns
    > a pointer to a structure containing the "cooked" (compiled) regex, which is
    > essentially a representation of a finite state machine. Then you run that
    > state machine against one or more strings to perform the matching operation.
    >
    > If that's what you're referring to, then no - In Perl, you don't need to
    > worry about it, for the most part. The whole process of compiling regex
    > string patterns into finite state machines is handled behind the scenes,
    > so you rarely even need to be aware of it.
    >
    > This is, in fact, a standout feature of the language - some other languages
    > are catching up recently, but Perl has had smooth integration of regular
    > expressions into the core language from the beginning.
    >
    > If you're curious, have a look at "perldoc perlop", in the section "Gory
    > details of parsing quoted constructs". It has some details about how "raw"
    > regexes are handled, and how you can get a look at the "cooked" results.
    >
    > sherm--


    Thanks, I believe that is exactly what I was looking for.
    >
    > --
    > Cocoa programming in Perl: http://camelbones.sourceforge.net
    > Hire me! My resume: http://www.dot-app.org
     
    Smitty, Nov 22, 2005
    #7
  8. Smitty

    Guest

    "Smitty" <> wrote:

    <pathetic whining snipped>

    > > > [Does] such a thing exist, and if so, should I worry about 'raw'
    > > > regex's

    > >
    > > I assume that something referenced 'cooking' regex, or else why would
    > > you ask about it? Could you please give us some context by telling us
    > > what it was that did referenced this?

    >
    > Since you asked, I am in the unenviable position of having to maintain
    > some other (supposedly experienced) developers' perl code. In it there
    > are several global variables which get assigned regex's as their
    > values, with a comment that says "Make sure the regex's are
    > pre-cooked". My question is very straight-forward, and clear. Does
    > such a thing [as a 'cooked' regex] exist [in perl] ?


    Is the /o switch being used on these regexes? That may be what the guy
    meant by "cooked".

    > I frequently ask very general questions to ensure I don't 'taint' any
    > answers I might get.


    If there is anything I hate, it is when answers are tainted with
    usefulness.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Nov 22, 2005
    #8
  9. wrote:
    > "Smitty" <> wrote:
    >
    > <pathetic whining snipped>
    >
    > > > > [Does] such a thing exist, and if so, should I worry about 'raw'
    > > > > regex's
    > > >
    > > > I assume that something referenced 'cooking' regex, or else why would
    > > > you ask about it? Could you please give us some context by telling us
    > > > what it was that did referenced this?

    > >
    > > Since you asked, I am in the unenviable position of having to maintain
    > > some other (supposedly experienced) developers' perl code. In it there
    > > are several global variables which get assigned regex's as their
    > > values, with a comment that says "Make sure the regex's are
    > > pre-cooked". My question is very straight-forward, and clear. Does
    > > such a thing [as a 'cooked' regex] exist [in perl] ?

    >
    > Is the /o switch being used on these regexes? That may be what the guy
    > meant by "cooked".
    >


    or maybe pre-compiling with qr.
     
    it_says_BALLS_on_your_forehead, Nov 22, 2005
    #9
  10. Smitty

    J. Gleixner Guest

    Smitty wrote:

    > Since you asked, I am in the unenviable position of having to maintain
    > some other (supposedly experienced) developers' perl code. In it there
    > are several global variables which get assigned regex's as their
    > values, with a comment that says "Make sure the regex's are
    > pre-cooked". My question is very straight-forward, and clear. Does
    > such a thing [as a 'cooked' regex] exist [in perl] ?


    For future reference, posting the lines of code in question, instead of
    what's in the comments, will get the most accurate and the most helpful
    response. Another way to go is to look up the function ,in the
    documentation, to see what it does.

    eat() if cooked( $turkey ); # Make sure turkey is cooked. :)
     
    J. Gleixner, Nov 22, 2005
    #10
  11. Smitty

    Smitty Guest

    wrote:
    > > I frequently ask very general questions to ensure I don't 'taint' any
    > > answers I might get.

    >
    > If there is anything I hate, it is when answers are tainted with
    > usefulness.
    >
    > Xho


    If there is anything I hate, it is when responders do not have the
    conviction to stand by their needlessly acerbic and sarcastic
    responses, rather they later try to pretend that their original
    response was a perfectly reasonable, and somehow enlightening answer.
     
    Smitty, Nov 22, 2005
    #11
  12. "Smitty" <> writes:

    > Since you asked, I am in the unenviable position of having to maintain
    > some other (supposedly experienced) developers' perl code. In it there
    > are several global variables which get assigned regex's as their
    > values, with a comment that says "Make sure the regex's are
    > pre-cooked". My question is very straight-forward, and clear. Does
    > such a thing [as a 'cooked' regex] exist [in perl] ?


    No, it's not clear at all. The term "cooked" is not one that I've ever
    heard used in connection to regexes in *any* language. I took what seemed
    to be a reasonable guess, based on how I've used regexes in other languages,
    but it might be entirely off base.

    It would have been better to post the code, including the comment, and ask
    what the comment might be referring to. He might have been referring to a
    construct that's more widely known by another name.

    > I frequently ask very general questions to ensure I don't 'taint' any
    > answers I might get. This is a subtle tactic; one that I wouldn't
    > expect you to understand, so don't bother commenting.


    If that's your attitude, you can bet I won't bother responding further.

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
     
    Sherm Pendley, Nov 22, 2005
    #12
  13. "Smitty" <> writes:

    > wrote:
    >> > I frequently ask very general questions to ensure I don't 'taint' any
    >> > answers I might get.

    >>
    >> If there is anything I hate, it is when answers are tainted with
    >> usefulness.

    >
    > If there is anything I hate, it is when responders do not have the
    > conviction to stand by their needlessly acerbic and sarcastic
    > responses, rather they later try to pretend that their original
    > response was a perfectly reasonable, and somehow enlightening answer.


    Xho's original response was:

    > I assume that something referenced 'cooking' regex, or else why would you
    > ask about it? Could you please give us some context by telling us what it
    > was that did referenced this?


    As you later told us, you did indeed have a reference to the term "cooking",
    in a comment attached to a piece of code. Xho's request for context *is*
    perfectly reasonable - had you posted both the comment and the code it is
    referring to, you would have gotten more than one blind guess and several
    requests for clarification.

    In short, your question was poorly written. Nothing wrong with that, if you
    simply clarify it as needed. There is a *lot* wrong with moaning, crying,
    and generally being a jerk towards the people who want to help.

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
     
    Sherm Pendley, Nov 22, 2005
    #13
  14. Smitty

    Guest

    "Smitty" <> wrote:
    > wrote:
    > > > I frequently ask very general questions to ensure I don't 'taint' any
    > > > answers I might get.

    > >
    > > If there is anything I hate, it is when answers are tainted with
    > > usefulness.
    > >
    > > Xho

    >
    > If there is anything I hate, it is when responders do not have the
    > conviction to stand by their needlessly acerbic and sarcastic
    > responses, rather they later try to pretend that their original
    > response was a perfectly reasonable, and somehow enlightening answer.


    I do stand by my acerbic and sarcastic response.
    I do think my response was perfectly reasonable.

    I don't pretend my original response was enlightening, at least not WRT the
    question asked. Ask an unenlightening question, get an unenlightening
    answer.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Nov 22, 2005
    #14
  15. Smitty

    Anno Siegel Guest

    Smitty <> wrote in comp.lang.perl.misc:
    >
    > wrote:
    > > "Smitty" <> wrote:
    > > > I can't find any reference to 'cooking' regular expressions in any of
    > > > my three perl books (Llama, Camel, Panther).

    > >
    > > Surely there an *infinite* number of things that you can't find a reference
    > > for in any of your three perl books. Are you going to ask us about all of
    > > them?

    >
    > Dude, what is your problem. Were you born an ass, or is it something
    > you have been perfecting since you started monitoring this newsgroup;
    > or, is this some personal vendetta against me ?
    >
    > >
    > > > [Does] such a thing exist, and if so, should I worry about 'raw' regex's

    > >
    > > I assume that something referenced 'cooking' regex, or else why would you
    > > ask about it? Could you please give us some context by telling us what it
    > > was that did referenced this?

    >
    > Since you asked, I am in the unenviable position of having to maintain
    > some other (supposedly experienced) developers' perl code. In it there
    > are several global variables which get assigned regex's as their
    > values, with a comment that says "Make sure the regex's are
    > pre-cooked". My question is very straight-forward, and clear. Does
    > such a thing [as a 'cooked' regex] exist [in perl] ?


    Your question was far from clear, and you knew it. Instead of giving
    the necessary background, you put quotes around "cooked", hoping your
    readers would figure out what you were too lazy to explain.

    Didn't work, rarely does.

    > I frequently ask very general questions to ensure I don't 'taint' any
    > answers I might get. This is a subtle tactic; one that I wouldn't
    > expect you to understand, so don't bother commenting.


    There's a fine line between "general" and "vague". You ended up on
    the vague side.

    Anno
    --
    If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers.
     
    Anno Siegel, Nov 22, 2005
    #15
  16. "Smitty" <> wrote:

    > I can't find any reference to 'cooking' regular expressions in any of
    > my three perl books (Llama, Camel, Panther).
    >
    > Such such a thing exist, and if so, should I worry about 'raw' regex's


    Everybody knows that regex is a dish best served cold!
     
    Euclid Uranium, Nov 22, 2005
    #16
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    834
    Reedick, Andrew
    Jul 1, 2008
  2. norseman
    Replies:
    2
    Views:
    496
    Ulrich Eckhardt
    Jul 7, 2008
  3. norseman
    Replies:
    2
    Views:
    401
    norseman
    Jul 7, 2008
  4. Replies:
    6
    Views:
    115
    John W. Kennedy
    Oct 8, 2006
  5. Xeno Campanoli
    Replies:
    1
    Views:
    91
    Martin Boese
    Jul 10, 2008
Loading...

Share This Page