Smashed_Crab
Smashed_Crab

Reputation: 1

Pass variables from HTML form to Perl script

I'm having some difficulty creating an HTML front-end for a Perl script we use in-house for config generation. We've moved from a Linux system to a Windows server instance and I've tested CGI/Perl are working as expected. The script itself uses the following format:

my $unitname; #name of device
my $clientid; #name of client
my $version;  #version of device firmware

These variables are called via command line, which prints the config to the cli:

./confgen.pl -u "unitname" -c "clientid" -v "version"

What I am trying to acheive is to use the existing variables in an HTML Form, but am not having any luck. So far I have this:

<form action confgen.pl method "get">
    <input type="text" name="unitname">
    <input type="text" name="clientid">
    <input type="text" name="version">
    <input type="submit" Value="generate"
</form>

Any advice or examples? I should add that CGI and Perl aren't my first languages, but I've been trying my best.

Upvotes: 0

Views: 2373

Answers (1)

martriay
martriay

Reputation: 5742

Your HTML should be like this

<form action="confgen.pl" method="get">
    <input type="text" name="unitname">
    <input type="text" name="clientid">
    <input type="text" name="version">
    <input type="submit" value="generate">
</form>

are you using any Perl library to receive the HTTP request? Consider using CGI http://perldoc.perl.org/CGI.html

Upvotes: 1

Related Questions