Noobish

Please support our Perl advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: May 2008
Posts: 3
Reputation: scuba183 is an unknown quantity at this point 
Solved Threads: 0
scuba183 scuba183 is offline Offline
Newbie Poster

Noobish

 
0
  #1
May 28th, 2008
So I'm having a bit of a problem with a CGI script. It runs fine, except for the little problem that param(x) doesn't work at all. It will either crash the program or return an undefined value.

  1. #!/usr/bin/perl
  2. use warnings;
  3. use CGI qw(:standard );
  4.  
  5. $temp=uc(param('class'));
  6. $class=chomp ($temp);
  7.  
  8. $temp=uc(param('type'));
  9. $type=chomp ($temp);
  10.  
  11. $temp=uc(param('first'));
  12. $first=chomp ($temp);
  13.  
  14. $temp=uc(param('last'));
  15. $last=chomp ($temp);
  16.  
  17. $temp=param('area');
  18. $areacode=chomp($temp);
  19.  
  20. $temp=param('firstnum');
  21. $first3=chomp($temp);
  22.  
  23. $temp=param('secondnum');
  24. $last4=chomp($temp);
  25.  
  26. $temp=uc(param('carrier'));
  27. $carrier=chomp($temp);
  28.  
  29. $num="$areacode$first3$last4";
  30. open (PER, ">../data/USERS/$type/$first.$last.dat");
  31. print (PER "$first $last\n$class\n$num\n$carrier");
  32. close (PER);
  33. print ("Content-Type:text/html\n\n");
  34. print "<html><body>";
  35. print '<h4>Thank you. Please email the Administrator at <a href="mailto:apcsci@gmail.com">xxxx@gmail.com</a> with any questions or comments</h4>';
  36. print "</body></html>";

Thanks
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: Noobish

 
0
  #2
May 28th, 2008
start with a simple script. Use a form with one text field: 'test'.

  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4. use CGI qw(:standard);
  5. print header;
  6. print start_html;
  7. print param('test');
  8. print end_html;

if that still crashes then your install of perl is bad or is maybe a non standard distribution.
Last edited by KevinADC; May 28th, 2008 at 5:54 pm.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 3
Reputation: scuba183 is an unknown quantity at this point 
Solved Threads: 0
scuba183 scuba183 is offline Offline
Newbie Poster

Re: Noobish

 
0
  #3
May 28th, 2008
somehow theres a problem in the
  1. $temp=uc(param('class'));
  2. $class=chomp ($temp);
part, and not regarding the param('x'); call. the simple form worked fine, and i modified my script so that it doesn't convert to uppercase or chomp, and now it's working

EDIT: Well now I feel really stupid. $first=chomp($temp); would return the number of spaces removed, not the string after the spaces had been removed. Oops haha
Last edited by scuba183; May 28th, 2008 at 10:11 pm.
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: Noobish

 
0
  #4
May 29th, 2008
ahh...my bad, I also missed that. You should not assign a return value from the chomp function, it should just be:

$var = "some value\n";
chomp($var);

Note: chomp() only removes the input record seperator from the end of a line or string, which is generally a newline, it does not remove spaces.
Reply With Quote Quick reply to this message  
Reply

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



Similar Threads
Other Threads in the Perl Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC