Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

perl to ansi C

by mbond (Beadle)
on Apr 16, 2001 at 19:06 UTC ( #72832=perlquestion: print w/replies, xml ) Need Help??

mbond has asked for the wisdom of the Perl Monks concerning the following question:

This may not be the forum in which to discuss this, but im not sure where to go for it.

Okay i wrote a script in PERL that i am being force to convert to ansi C by my employeer.

My problem is that i am reading a sub{} from a text file, because it chances fequently and its easier to do that than mess with the actual code. I use eval in perl to work with it.

Is there a simular ansi C function that will do the same thing. I search google for something, but came up blank.


Replies are listed 'Best First'.
Re: perl to ansi C
by AgentM (Curate) on Apr 16, 2001 at 19:42 UTC
    Well...for that, you need a C on-the-fly interpreter. While they do exist, you certainly don't need it for your project (and I won't link to one because of that). You say that you used a sub in another file and eval'ed it? I imagine that you open it, read it, and eval it. While this may work, it is not efficient and wholly unnecessary since Perl has built-in functionality to do exactly this- namely require, import, use, or some combination thereof. If you had done that, your solution would be now far more obvious. All you would have to do is compile your converted Perl to C function into an object file (or even a shared object! whoa!) and then link to it from your main script. While they may be interesting, C interpreters are at best sluggish and easily avoidable. Good luck!
    AgentM Systems nor Nasca Enterprises nor Bone::Easy nor Macperl is responsible for the comments made by AgentM. Remember, you can build any logical system with NOR.
Re (tilly) 1: perl to ansi C
by tilly (Archbishop) on Apr 16, 2001 at 19:35 UTC
    You could get Inline and convert the script to CPR. That is mostly ANSI C...


Re: perl to ansi C
by Cybercosis (Monk) on Apr 16, 2001 at 19:22 UTC
    Erm... well... heh, funny thing. Technically, no. Not in ANSI C. There *is* a language that can pull off something similar, and it's called C` (pronounced "C tick"). You can get it over at the MIT website, and it's even mostly ANSI compliant.... Good luck to you.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://72832]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2020-12-02 09:27 GMT
Find Nodes?
    Voting Booth?
    How often do you use taint mode?

    Results (35 votes). Check out past polls.