Please help me with how to use client inputs in a form as part of arguments in a CGI script following a button return. I want a client to specify a name which i can then use in perl script to create a folder for that client.

Recommended Answers

All 3 Replies

Try using the CGI module. It makes doing CGI development in Perl extremely easy (at least the CGI bits).

Try this at a command line:

perldoc CGI

A simple example... (note: more validation should be done, this is just an example...)

// a basic html form

<form action='' method='post'>
NAME: <input type='text' name='name' size'8' maxlength='8' />
<br />
<input type='submit' name='button' value='Folder Name' />

// the perl script (

#! /usr/lib/perl

use CGI;
use strict;

my $obj = new CGI;

my $name = $obj->param ( 'name' );

my $base = './docs/folders/';

print "Content-type: text/html\n\n"; 

if ( $name eq '' )
	print "the directory name was not entered!\n";
elsif ( $name !~ m/^[a-z0-9]{1,8}$/i )
	print "the directory name was not valid!\n";	
	if ( -e $base . $name )
		print "can not create directory, directory already exists!\n";
	elsif ( ! mkdir ( $base . $name, 0777 ) )
		print "can not create directory\n";
		print "new directory created\n";



Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.