PDA

View Full Version : Anyone Know Perl



n2ize
09-20-2013, 05:44 AM
Yes, I said Perl as in the interpreted programming language that was once the mainstay of web programming but was more or less aced out by PHP. In any event I still find Perl useful for running quick and dirty programs, usually quick calculations because it's done a lot like C, it's fast and can be done right on the command line. But today I write a simple program, basically a for...loop to increment a variable over an interval and plug it into a 2nd order equation and spit out a result so I can put points on a rough graph (parabola). But it spits out the wrong answers no matter how many adjustments I made to the code. Same exact method written in C and I get all correct results first time. If anyone knows Perl I'll post it here and maybe you'll see something I missed or forgot since I haven't used Perl in a while. Its very simple 3 line program.

Ooh.. just on a side not Common Lisp gives me the correct results as well but won;t post that here because of very different syntax/structure.

N2CHX
09-20-2013, 05:49 AM
Ummm. PHP can be run from the command line. Just sayin'. But anyway, post your code. It's been about 13 years since I really did anything with it, but prior to discovering PHP in the early 2000's I made a lot of money writing Perl code for websites.

n2ize
09-20-2013, 06:35 AM
Ummm. PHP can be run from the command line. Just sayin'. But anyway, post your code. It's been about 13 years since I really did anything with it, but prior to discovering PHP in the early 2000's I made a lot of money writing Perl code for websites.

Right, I forgot, PHP can also be run that way. I used to write a lot of Perl (and C/C++) years ago but these days I don't program much except for computational stuff and on my regular system I usually keep a Lisp machine running in the background for that. Let me dig it up (the code) and I'll copy paste it here with the output.

n2ize
09-24-2013, 07:09 PM
I figured out what was wrong. A variable wasn't being reinitialized to 0 prior to passing through the while() loop. It was a minor oversight on my part. I tend to use while() {...} and do {...} while; loops often as opposed to "for" loops. It's a throwback to my FORTRAN days. ;)

mw0uzo
10-02-2013, 05:02 AM
I figured out what was wrong. A variable wasn't being reinitialized to 0 prior to passing through the while() loop. It was a minor oversight on my part. I tend to use while() {...} and do {...} while; loops often as opposed to "for" loops. It's a throwback to my FORTRAN days. ;)

I've been learning PHP and webprogramming stuff recently too for the RadMon project. It's all so.... horrible. Scripts modifying other scripts and parsing files and generating javascript on the fly. Urgh. Common things you need to do need ugly hacks. Data being passed around all over the place, probably needing 100 times more memory than would otherwise be needed. Maybe I feel this way because i'm a noob to it all, but something really does seem wrong somewhere.