Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

C vs perl followup

by mandog (Curate)
on Apr 29, 2002 at 01:06 UTC ( [id://162733]=note: print w/replies, xml ) Need Help??


in reply to C vs perl

Thanks to everyone who replied. I'll post an update when I have final presentation notes

I'll be using corrections from Anonymous Monk and ovid to the perl version of the function and broquaint's version of the C function with corrections by dominus and abstracts

Time permitting, I'll do up a Flex and Bison version and a pcre (perl compatible regular expressions) version. Juerd makes the good point that it would be fairer to compare a C regex to a perl regex solution. However, my preliminary research and very small experience suggest C regexs have a fair amount of overhead that wouldn't be recovered in my toy project.

Juerd will no doubt produce elegant, working code and correct me if I er but...

To use the pcre library, I'll need to:
  • Allocate Memory
  • Compile the Regular Expression
  • Execute the regular expression
  • Play w/ a special substr function, a loop and maybe some strcat()
To use Flex/Bison I'll have to:
  • Build a .l file
  • Build a .y file (or write a concat loop in C ??)
  • Run Flex
  • Run Yacc
In Perl I just use:
 $fixme=~s|\n\r|</p><p>|g

Time permitting, I'll also do an "ugly" version in Perl (thanks belg4mit)

A couple other thoughts. It took me about 5 hours to write the C version of the function and about 50 minutes to write the Perl version of the function. At no time, during my perl coding did I dump core... My perl version was much closer to the more ideal perl version created by ovid than the more ideal C version created by broquaint

My guess is that as a average Perl & C programmer, I'm closer to being a great perl programmer than I am to being a great C programmer. (not that I'm especially close...)



email: mandog

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://162733]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2024-04-25 04:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found