Help with files

Help with files

am 19.09.2004 14:06:16 von zRaze

Hi,

I'm having problems with files-
--------------------------------------------------------
open(xHandle, "
$mylist = "";

while ()
{
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

Re: Help with files

am 19.09.2004 15:29:19 von Gunnar Hjalmarsson

zRaze wrote:
>
> if ( $_ != "FF" )



> 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

Re: Help with files

am 20.09.2004 18:16:34 von zRaze

Cool. 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
wrote:

>zRaze wrote:
>>
>> if ( $_ != "FF" )
>
>
>
>> 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.

Re: Help with files

am 25.09.2004 07:54:02 von Larry

In article ,
zRaze 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!)

Re: Help with files

am 25.09.2004 09:50:25 von Dave Cross

On 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...

Re: Help with files

am 14.01.2006 05:43:14 von gharrison64

I f you are working with strings I find that if you do
if ($_ ne "FF") you should get the results you want.

"Gunnar Hjalmarsson" wrote in message
news:2r5fscF15s084U1@uni-berlin.de...
> zRaze wrote:
>>
>> if ( $_ != "FF" )
>
>
>
>> 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