Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > 'cooking' regex's

Reply
Thread Tools

'cooking' regex's

 
 
Smitty
Guest
Posts: n/a
 
      11-22-2005
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

 
Reply With Quote
 
 
 
 
Smitty
Guest
Posts: n/a
 
      11-22-2005

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
?

 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      11-22-2005
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

 
Reply With Quote
 
Sherm Pendley
Guest
Posts: n/a
 
      11-22-2005
"Smitty" <(E-Mail Removed)> 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
 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      11-22-2005
"Smitty" <(E-Mail Removed)> 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
 
Reply With Quote
 
Smitty
Guest
Posts: n/a
 
      11-22-2005

http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> "Smitty" <(E-Mail Removed)> 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


 
Reply With Quote
 
Smitty
Guest
Posts: n/a
 
      11-22-2005

Sherm Pendley wrote:
> "Smitty" <(E-Mail Removed)> 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


 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      11-22-2005
"Smitty" <(E-Mail Removed)> 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
 
Reply With Quote
 
it_says_BALLS_on_your_forehead
Guest
Posts: n/a
 
      11-22-2005

(E-Mail Removed) wrote:
> "Smitty" <(E-Mail Removed)> 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.

 
Reply With Quote
 
J. Gleixner
Guest
Posts: n/a
 
      11-22-2005
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments