codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  New to perl PLEASE HELP!!!!!!!  Delux at 00:57 on Monday, February 19, 2007
 

Hey, I am taking a class in perl, and my assignement was to make this form so i have the form all made and it works, now i have to take this form and have the data that is entered saved to a text file. how would i go about doing this. here is my perl file.


#!C:/Perl/bin/perl.exe
#juniper.cgi - creates a dynamic Web page that acknowledges
#the receipt of a registration form
print "Content-type: text/html\n\n";
use CGI qw(:standard);
use strict;

#declare variables (** change $ to @ in sysletter / add $key **)
my ($name, $serial, $modnum, @sysletter, $key);
my @models = ("Laser JX", "Laser PL", "ColorPrint XL");

# add hash declaration
my %systems = ("W", "Windows",
"M", "Macintosh",
"L", "Linux");

#assign input items to variables
$name = param('Name');
$serial = param('Serial');
$modnum = param('Model');
# (** change $ to @ in sysletter)
@sysletter = param('System');

#create Web page
print "<html><head><title>Juniper Printers</title></head>\n";
print "<BODY><H2>\n";
print "Thank you, $name, for completing \n";
print "the registration form.<br /><br />\n";
print "We have registered your Juniper $models[$modnum] printer, \n";
print "serial number, $serial. \n";

# (** modify hash references for multiple selections **)
print "You indicated that the printer will be used on the \n";
print "following systems: <br /> \n";
foreach $key (@sysletter) {
print "$systems{$key} <br />\n";
}

print "</h2></body></html>\n";


if you need me to post my form file i can do that as well. thanks

  Re: New to perl PLEASE HELP!!!!!!!  mimir at 20:07 on Thursday, February 22, 2007
 

A good way is to make a filehandle,
Look at 9.2.1.1 "Make a filehandle", here:
http://www.hermanningjaldsson.com/1/pdg/pdg.html


  Re: New to perl PLEASE HELP!!!!!!!  Delux at 18:37 on Friday, February 23, 2007
 

I tried using this and i understand how it works, but where do i place each section of the code?? i have tried a few places and it doesnt work. any help is great thanks.

  Re: New to perl PLEASE HELP!!!!!!!  mimir at 15:44 on Saturday, February 24, 2007
 

just put that filehandle thing at the end of the code.
And then you can print whatever vars you want into your new file.


  Re: New to perl PLEASE HELP!!!!!!!  Delux at 17:20 on Sunday, February 25, 2007
 

im still having trouble, i put the coe at the very bottom and it is still not writing to the text file here is my code:

#!C:/Perl/bin/perl.exe
#juniper.cgi - creates a dynamic Web page that acknowledges
#the receipt of a registration form
print "Content-type: text/html\n\n";
use CGI qw(:standard);
use strict;

#declare variables (** change $ to @ in sysletter / add $key **)
my ($name, $serial, $modnum, @sysletter, $key);
my @models = ("Laser JX", "Laser PL", "ColorPrint XL");

# add hash declaration
my %systems = ("W", "Windows",
"M", "Macintosh",
"L", "Linux");

#assign input items to variables
$name = param('Name');
$serial = param('Serial');
$modnum = param('Model');
# (** change $ to @ in sysletter)
@sysletter = param('System');

#create Web page
print "<html><head><title>Juniper Printers</title></head>\n";
print "<BODY><H2>\n";
print "Thank you, $name, for completing \n";
print "the registration form.<br /><br />\n";
print "We have registered your Juniper $models[$modnum] printer, \n";
print "serial number, $serial. \n";


# (** modify hash references for multiple selections **)
print "You indicated that the printer will be used on the \n";
print "following systems: <br /> \n";
foreach $key (@sysletter) {
print "$systems{$key} <br />\n";
}

print "</h2></body></html>\n";
open (W_FILE, "/forum/gtgtCInetpubwwwrootjunreg.txt");
print W_FILE "Hey, this text is going straight to the file.\n";
close W_FILE;

  Re: New to perl PLEASE HELP!!!!!!!  mimir at 17:24 on Sunday, February 25, 2007
 

Try writing straight into c:
Maybe its something with the folder structure, like folder not existing, syntax wrong or something.

So try changing it into the following:
open (W_FILE, "/forum/gtgtCjunreg.txt");
print W_FILE "Hey, this text is going straight to the file.\n";
close W_FILE;

//now junreg.txt should be in the C:\

  Re: New to perl PLEASE HELP!!!!!!!  mimir at 17:34 on Sunday, February 25, 2007
 

The file may be created in the folder in which you run the program.



  Re: New to perl PLEASE HELP!!!!!!!  Delux at 18:31 on Sunday, February 25, 2007
 

I finally got it to work, thanks for your help

  Re: New to perl PLEASE HELP!!!!!!!  mimir at 21:31 on Sunday, February 25, 2007
 

Your welcome, thanks for helping me make the guide better.

Mimir








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Date script issues
•  perl script help needed
•  onChange issue
•  perl remote execution
•  Chat application
•  How to send multiple perameters in SOAP request.
•  Java code for Insert picture on the table in spreadsheet
•  Re: Problem with concatenation
•  how to genrates the crystal report by sending a id at runtime


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007