'cooking' regex's

S

Smitty

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
 
S

Smitty

Smitty said:
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
?
 
P

Paul Lalli

Smitty said:
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
 
S

Sherm Pendley

Smitty said:
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--
 
X

xhoster

Smitty said:
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
 
S

Smitty

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.
 
S

Smitty

Sherm said:
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.
 
X

xhoster

[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
 
I

it_says_BALLS_on_your_forehead

[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.
 
J

J. Gleixner

Smitty said:
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. :)
 
S

Smitty

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.
 
S

Sherm Pendley

Smitty said:
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--
 
S

Sherm Pendley

Smitty said:
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--
 
X

xhoster

Smitty said:
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
 
A

Anno Siegel

Smitty said:
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
 
E

Euclid Uranium

Smitty said:
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!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top