Code Comments
Programming Forum and web based access to our favorite programming groups.Hi,
I'm having problems with files-
--------------------------------------------------------
open(xHandle, "<svr.txt");
$mylist = "";
while (<xHandle> )
{
chomp;
if ( $_ != "FF" )
{
$mylist = $mylist . $_ . "\n";
}
print $mylist;
}
close(xHandle);
--------------------------------------------------------
When I run the above code, $mylist never prints out (or it is empty),
however, if I take out the If statement, it works fine.
My file (svr.txt) has two lines in it -
DF
FF
Does anyone know what I'm doing wrong?
TIA
Post Follow-up to this messagezRaze wrote: > > if ( $_ != "FF" ) <snip> > Does anyone know what I'm doing wrong? You are posting a problem here, which Perl would have helped you solve if you had enabled strictures and warnings. Add use strict; use warnings; to the beginning of your program, and declare your variables using my(). Then Perl will provide the help you need to understand what you are doing wrong. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl
Post Follow-up to this messageCool. I didn't know about this (I'm still quite new to Perl) Cheers! On Sun, 19 Sep 2004 15:29:19 +0200, Gunnar Hjalmarsson <noreply@gunnar.cc> wrote: >zRaze wrote: > ><snip> > > >You are posting a problem here, which Perl would have helped you solve >if you had enabled strictures and warnings. > >Add > > use strict; > use warnings; > >to the beginning of your program, and declare your variables using >my(). Then Perl will provide the help you need to understand what you >are doing wrong.
Post Follow-up to this messageIn article <jf0uk0hjqovei80smta3l3ujk13p7heh1s@4ax.com>, zRaze <abuse@dead.com> wrote: > Cool. I didn't know about this (I'm still quite new to Perl) > > Cheers! > > and if you're running the code via web always keep this line at the top of your script: use CGI::Carp "fatalsToBrowser"; (now you can say goodbye to the hateful 500 web server error!)
Post Follow-up to this messageOn Sat, 25 Sep 2004 05:54:02 +0000, Larry wrote: > and if you're running the code via web always keep this line at the top > of your script: > > use CGI::Carp "fatalsToBrowser"; > > (now you can say goodbye to the hateful 500 web server error!) Er... no. Leave the "fatalsToBrowser" there whilst you're debugging the program but remove it before putting it live. If crackers get Perl error messages when your site breaks then they potentially get useful information on how to crack your server. The 500 error page is there for a reason. It gives the user all the information they need. The real error message is where it should be - in the error log file where only the site's maintainer can see it. If you really don't like the 500 error page then configure your web server to display a different one that in more in keeping with your site's look at feel. But don't be tempted to add any more "useful" information to it. Dave...
Post Follow-up to this messageI f you are working with strings I find that if you do if ($_ ne "FF") you should get the results you want. "Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message news:2r5fscF15s084U1@uni-berlin.de... > zRaze wrote: > > <snip> > > > You are posting a problem here, which Perl would have helped you solve if > you had enabled strictures and warnings. > > Add > > use strict; > use warnings; > > to the beginning of your program, and declare your variables using my(). > Then Perl will provide the help you need to understand what you are doing > wrong. > > -- > Gunnar Hjalmarsson > Email: http://www.gunnar.cc/cgi-bin/contact.pl
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.