473,699 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

tie::File 500 Internal Server Error???

35 New Member
Hi folks,

Perl is always killing me. I always do it on my computer first and then upload to the server in our lab. And oh my, never ever be correct to run on the lab. This time I got the internal error. I tried to add and delete multiple lines and found out that is possibly due to tie::File.

Could you please help me to solve the problem? I am dying for it :(

Here's the code.
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl 
  2.  
  3. #use CGI::Carp qw(fatalsToBrowser); 
  4.  
  5. #use strict; 
  6.  
  7. use CGI; 
  8.  
  9. use Tie::File; 
  10.  
  11. $query = new CGI; 
  12.  
  13. $data_file="nameList.cgi"; 
  14.  
  15. open(DAT, $data_file) || die("Could not open file!"); 
  16.  
  17. @raw_data=<DAT>; 
  18.  
  19. tie @line, 'Tie::File', $data_file or die("Could not open file!"); 
  20.  
  21. print $query->header(); 
  22.  
  23. print "Content-type: text/html\n\n"; 
  24.  
  25. print "<HTML><HEAD>\n"; 
  26. print "<TITLE>Thanks!</TITLE></HEAD>\n"; 
  27. print "<BODY>"; 
  28.  
  29. $first = $query->param("first"); 
  30. $last = $query->param("last"); 
  31. $email = $query->param("email"); 
  32.  
  33.  
  34.  
  35. print "<P>$first $last, thank you for signing up! Please click <a href=\"list.pl\">here</a> to see the signup table for confirmation and don't repeatly signing up.</P>\n"; 
  36.  
  37.  
  38.  
  39. $count = 0; 
  40.  
  41. @WS = $query->param("ws"); 
  42.  
  43. foreach $ws(@WS){ 
  44.  
  45. $line[$ws-1].="$first $last, $email|"; 
  46.  
  47.  
  48. close(DAT); 
  49.  
  50. print "</BODY>\n"; 
  51.  
  52. print "</HTML>\n"; 
  53.  
-------------------------------------------------------------------------------------------------------

And I've tried use warnings, add and remove -w.....doesn't work.........cr ying T-T

Cannot appreciate more.
Oct 25 '07 #1
20 2095
eWish
971 Recognized Expert Contributor
Welcome to TSDN Casybay!

You have posted code into the forum without using proper code tags. It is best practice here on TSDN to wrap all code posted into the forum in code tags.

Code tags start with [code] and end with [/code]. If you need an example other than this one, the please refer to the REPLY GUIDELINES (or POSTING GUIDELINES if you are starting a discussion) to the right of the Message window. You will find the examples and suggestions for posting there.

In addition, you can also add the language to your code tags. Here is an example:

[code=perl]
<some code>
[/code]

Please know that I have fixed your posts above to include the proper code tags. Please be sure and use code tags in all of your future posts here on TSDN.

- Moderator
Oct 25 '07 #2
eWish
971 Recognized Expert Contributor
What errors did you get? Did you check the error logs to see what was logged? I would uncomment the following lines and add use warnings; as well.
Expand|Select|Wrap|Line Numbers
  1. use CGI::Carp qw(fatalsToBrowser); 
  2. use strict;
Then I would declare the variables correctly using my. What OS are you using?
Oct 25 '07 #3
KevinADC
4,059 Recognized Expert Specialist
You're not actually using Tie::File to do anything in the code you posted. Are you just experimenting?
Oct 25 '07 #4
casybay
35 New Member
To eWish, sorry for that. I didn't notice that. I am using Windos XP in my computer and the lab's server OS is Linux, and for both of them, I am using Apache.
To KenvinADC, yes, I did. Please see line 44. I am going to write something to the file as my understand.
Thank you so much for you guys' replies.
Oct 25 '07 #5
KevinADC
4,059 Recognized Expert Specialist
Sorry, I missed those lines.

Untested code:

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl 
  2.  
  3. use CGI::Carp qw(fatalsToBrowser); 
  4. use strict; 
  5. use warnings;
  6. use CGI; 
  7. use Tie::File;
  8. use Fcntl; 
  9.  
  10. my $query = new CGI; 
  11. print $query->header,$query->start_html('Thanks!');
  12.  
  13. my $data_file = "nameList.cgi"; 
  14.  
  15. tie my @line, 'Tie::File', $data_file, mode => O_RDWR or die "$!";
  16.  
  17. my $first = $query->param("first"); 
  18. my $last  = $query->param("last"); 
  19. my $email = $query->param("email"); 
  20.  
  21. print $query->p(qq{$first $last, thank you for signing up! Please click
  22.                 <a href="list.pl">here</a> to see the signup table for
  23.                 confirmation and don't repeatly signing up.}); 
  24.  
  25. my @WS = $query->param("ws"); 
  26.  
  27. foreach my $ws (@WS){
  28.    $line[$ws-1].= "$first $last, $email|"; 
  29.  
  30. untie @line;
  31. print $query->end_html;
  32.  
Oct 25 '07 #6
casybay
35 New Member
KenvinADC, I will try it tomorrow when I go to the lab. Appreciate that :)
Oct 25 '07 #7
casybay
35 New Member
Hi KenvinADC, it seems like the code you modified for me still doesn't work.
Oct 25 '07 #8
KevinADC
4,059 Recognized Expert Specialist
Unless you can be more specific I can't help.
Oct 25 '07 #9
casybay
35 New Member
Sorry for that KevinADC, cuz I am waiting for my permission to access to the error log, so before that, I cannot tell you more specific about the error.
Since there's something wrong with tie::File, could anyone inspire me what could possibly cause error with this function? Or is there anyother way to read and write a line from and to a file using perl?
Appreciate :)
Oct 25 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1686
by: Jonathan Weekes | last post by:
Being utterly a non Perl IT guy, I have to write a Perl script for a web site to edit a line in a file. I have looked on Google and found Tie to be what I needed, but I am really lost in how to change the line. Can someone please edit the script below for me to show me how to do this? I have already looked in the documentation and still got lost... use CGI qw/:standard/; use CGI::Cookie; use Tie::File;
1
2546
by: SpecialK | last post by:
Does anyone know how to tie a large file to a hash without using shared memory? I know I can use Tie::File to tie the file to an array and from the array create a hash, but I need something that is much faster than that? thanks, gregk
2
1211
by: steventhrasher42 | last post by:
I very likely may be missing something here, but what stops a user from holding down the F5 key in their browser and generating hundreds of requests to IIS and thus tying up server resources? If session state is enabled (enableSessionState=true), all of these requests get queued and processed one after another. And if the user finds a particular page with poor enough performance, say one that takes a few seconds to render, by holding...
2
15991
by: kelly | last post by:
Hi, I don't have a code to show you, what I need are references or algorithms so that I'm in a right track. By the way, thanks for introducing me the array or arrays. Now I can continue my script. Now I want to delete a line from a file. Line being the strings I got/saved to/from array of arrays.
5
1494
by: mich dobelman | last post by:
I am developing a web crawler which collects info from more than 50,0000 pages. but i am afraid this is going to clog the rental web server if I run it every single day. Is it possible to stop the web hosting server because of my program? MD
1
1981
by: jonathan184 | last post by:
trying to rename filenames and extensions then add a header in line1 of each file if the header existed in line 1 to go to the next file. but i am getting error explciti errors Here is my code I am using #!/usr/bin/perl user warnings;
1
3095
by: J. J. Ramsey | last post by:
In Perl, there is a module called "Tie::File". What it does is tie a list to each line of a file. Change the list, and the file is automatically changed, and on top of this, only the bits of the file that need to be changed are written to disk. At least, that's the general idea. I was wondering if something roughly similar could be done in Python, or at the very least, if I can avoid doing what amounts to reading the whole file into...
2
12328
by: eMko | last post by:
Hello, In Perl, using a Tie::File module I can easily and comfortably delete a line from the middle of a text file: my @file; open(DATA, "+<:encoding(utf8):raw" , "file.txt") or return 0; tie @file, 'Tie::File', \*DATA or return 0; splice(@file, $_, 1); untie @file;
1
47462
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
0
8621
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9184
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8929
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8891
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4634
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3061
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2357
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.