Form data as input into Perl code

Reply

Join Date: May 2006
Posts: 7
Reputation: brounemmanuel is an unknown quantity at this point 
Solved Threads: 0
brounemmanuel brounemmanuel is offline Offline
Newbie Poster

Form data as input into Perl code

 
0
  #1
May 25th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 36
Reputation: azimuth0 is an unknown quantity at this point 
Solved Threads: 5
azimuth0 azimuth0 is offline Offline
Light Poster

Re: Form data as input into Perl code

 
0
  #2
May 25th, 2006
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:
  1. perldoc CGI
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 898
Reputation: KevinADC has a spectacular aura about KevinADC has a spectacular aura about 
Solved Threads: 67
KevinADC's Avatar
KevinADC KevinADC is offline Offline
Practically a Posting Shark

Re: Form data as input into Perl code

 
0
  #3
May 25th, 2006
Yes, the CGI module is your friend:

http://perldoc.perl.org/CGI.html
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 18
Reputation: demo is an unknown quantity at this point 
Solved Threads: 2
demo demo is offline Offline
Newbie Poster

Re: Form data as input into Perl code

 
0
  #4
Jun 1st, 2006
A simple example... (note: more validation should be done, this is just an example...)

// a basic html form

  1. <form action='script.pl' method='post'>
  2. NAME: <input type='text' name='name' size'8' maxlength='8' />
  3. <br />
  4. <input type='submit' name='button' value='Folder Name' />
  5. </form>


// the perl script (script.pl)

  1. #! /usr/lib/perl
  2.  
  3. use CGI;
  4. use strict;
  5.  
  6. my $obj = new CGI;
  7.  
  8. my $name = $obj->param ( 'name' );
  9.  
  10. my $base = './docs/folders/';
  11.  
  12. print "Content-type: text/html\n\n";
  13.  
  14. if ( $name eq '' )
  15. {
  16. print "the directory name was not entered!\n";
  17. }
  18. elsif ( $name !~ m/^[a-z0-9]{1,8}$/i )
  19. {
  20. print "the directory name was not valid!\n";
  21. }
  22. else
  23. {
  24. if ( -e $base . $name )
  25. {
  26. print "can not create directory, directory already exists!\n";
  27. }
  28. elsif ( ! mkdir ( $base . $name, 0777 ) )
  29. {
  30. print "can not create directory\n";
  31. }
  32. else
  33. {
  34. print "new directory created\n";
  35. }
  36. }
  37.  
  38. exit(0);

me!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC