help needed: passing arguments to a test a perl script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sh33p1985
Forum Commoner
Posts: 78
Joined: Thu Mar 11, 2004 9:22 am

help needed: passing arguments to a test a perl script

Post by sh33p1985 »

im quite new to php and i have no idea how to do this.

in the context of my problem, i have basic calculator written in perl with 4 operators + - * /. 2 txt fields (first number seocnd number) and a drop down menu (with the 4 operators as options) are displayed on a webpage and when the user clicks calculate it will bring up a new page with the answer(assuming the the input is valid).

i need to write a peice of code in php the will test the perl script (i.e each operator using valid input) to see if it functions. im guessing i will need to pass arguments to the script in order to do this but i really am stuck on how to do this.

any help to get me started or more would be much appreciated.
thanks
TheBentinel.com
Forum Contributor
Posts: 282
Joined: Wed Mar 10, 2004 1:52 pm
Location: Columbus, Ohio

Re: help needed: passing arguments to a test a perl script

Post by TheBentinel.com »

sh33p1985 wrote: i need to write a peice of code in php the will test the perl script (i.e each operator using valid input) to see if it functions. im guessing i will need to pass arguments to the script in order to do this but i really am stuck on how to do this.
How about using file_get_contents?

$output = file_get_contents("http://yourserver.com/calc.pl?operator= ... perand2=20");
print ($output); // should print 35

You could randomize the operands or just have a series of these to run your tests.

Is that the kind of thing you're looking for, or have I missed your point?
sh33p1985
Forum Commoner
Posts: 78
Joined: Thu Mar 11, 2004 9:22 am

Post by sh33p1985 »

no, actually that makes sense, seeing as the php will be testing lots of similar scripts just have to force the scripts,textfields,and operator selection to have specific names.thanks ill give it a go today and see what i come up with!
Post Reply