Code Comments
Programming Forum and web based access to our favorite programming groups.Hello, 1. I read on many Perl/CGI tutorial/articles that it is best to place and use CGI files in /cgi-bin/ directory than anywhere else, due to avoid many problems. Buy in our website, we have several subdomain and those are all use the same /cgi-bin/ directory, so now there are a lot of files populated there. So now what I have to do to reduce the management/maintanence problems. 2. I used "use strict", and I get error for the statement open(IN_FILE1, ">>test_records.txt"); Here the error is Bareword "IN_FILE1" not allowed while "strict subs" in use .... But if I remove "use strict", the program works well. So should I definately do not use "use strict" if the program want to handle I/O files? Thank you all. Greetings, R. Kumaran
Post Follow-up to this messageOn Wed, 30 Mar 2005 09:57:38 +0200, GR Kumaran wrote: > > 2. I used "use strict", and I get error for the statement > open(IN_FILE1, ">>test_records.txt"); > > Here the error is > Bareword "IN_FILE1" not allowed while "strict subs" in use .... > > But if I remove "use strict", the program works well. So should I > definately do not use "use strict" if the program want to handle I/O > files? > The line you gave is okay even under "use strict;", so the problem must be in some code before this line. One problem I saw in the past was that a module that was used overloaded the "open" function. To check if this is the case, change your line to: CORE::open(IN_FILE1, ">>test_records.txt"); Oh, and you should definitly "use strict; use warnings;" everywhere, in every script you write!!! -- Offer Kaye
Post Follow-up to this messageHi Kumaran, Use strict is used to enforce declaration of variables before we use them. Here IN_FILE1 is file pointer variable which u are using and which is not declared before , That is the reason it is working fine when u have removed the use strict construct. Thanks Arjun=0D Deserve before you desire =0D =0D -----Original Message----- From: grkumaran@sancharnet.in [mailto:grkumaran@sancharnet.in]=0D Sent: Wednesday, March 30, 2005 1:28 PM To: M.L. PERL BEG Subject: General questions Hello, 1. I read on many Perl/CGI tutorial/articles that it is best to place and use CGI files in /cgi-bin/ directory than anywhere else, due to avoid many problems. Buy in our website, we have several subdomain and those are all use the same /cgi-bin/ directory, so now there are a lot of files populated there. So now what I have to do to reduce the management/maintanence problems. 2. I used "use strict", and I get error for the statement open(IN_FILE1, ">>test_records.txt"); Here the error is Bareword "IN_FILE1" not allowed while "strict subs" in use .... But if I remove "use strict", the program works well. So should I definately do not use "use strict" if the program want to handle I/O files? Thank you all. Greetings, R. Kumaran --=0D To unsubscribe, e-mail: beginners-unsubscribe@perl.org For additional commands, e-mail: beginners-help@perl.org <http://learn.perl.org/> <http://learn.perl.org/first-response> Confidentiality Notice=0D The information contained in this electronic message and any attachments to= this message are intended for the exclusive use of the addressee(s) and may contain confidential or= privileged information. If you are not the intended recipient, please notify the sender at Wipro or= Mailadmin@wipro.com immediately and destroy all copies of this message and any attachments.
Post Follow-up to this messageOn Thu, 31 Mar 2005 11:28:04 +0530, arjun.mallik@wipro.com wrote:
>
> Use strict is used to enforce declaration of variables before we use
> them.
> Here IN_FILE1 is file pointer variable which u are using and which is
> not declared before ,
> That is the reason it is working fine when u have removed the use strict
> construct.
>
Not true. Save the following code in a file called "test.pl" and run
it with "perl -w test.pl":
######## begin code
use strict;
open(IN_FILE1,"test.pl");
while(<IN_FILE1> ) {print}
######## end code
As you can see, this code runs without any warnings or errors.
IN_FILE1 is a FILEHANDLE, not a "file pointer variable" (whatever the
heck that is). More to the point, it is not a variable at all, and so
is not affected by "use strict;".
--
Offer Kaye
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.