User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Perl section within the Software Development category of DaniWeb, a massive community of 425,765 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,399 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Perl advertiser: Programming Forums
Views: 380 | Replies: 3
Reply
Join Date: May 2008
Posts: 3
Reputation: scuba183 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
scuba183 scuba183 is offline Offline
Newbie Poster

Noobish

  #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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2006
Posts: 620
Reputation: KevinADC is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 33
KevinADC's Avatar
KevinADC KevinADC is offline Offline
Practically a Master Poster

Re: Noobish

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

#!/usr/bin/perl
use warnings;
use strict;
use CGI qw(:standard);
print header;
print start_html; 
print param('test');
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 4:54 pm.
Reply With Quote  
Join Date: May 2008
Posts: 3
Reputation: scuba183 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
scuba183 scuba183 is offline Offline
Newbie Poster

Re: Noobish

  #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 9:11 pm.
Reply With Quote  
Join Date: Mar 2006
Posts: 620
Reputation: KevinADC is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 33
KevinADC's Avatar
KevinADC KevinADC is offline Offline
Practically a Master Poster

Re: Noobish

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Perl Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Perl Forum

All times are GMT -4. The time now is 2:33 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC