Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Help with files
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

Report this thread to moderator Post Follow-up to this message
Old Post
zRaze
09-19-04 01:59 PM


Re: Help with files
zRaze 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

Report this thread to moderator Post Follow-up to this message
Old Post
Gunnar Hjalmarsson
09-19-04 08:55 PM


Re: Help with files
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
<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.


Report this thread to moderator Post Follow-up to this message
Old Post
zRaze
09-20-04 08:57 PM


Re: Help with files
In 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!)

Report this thread to moderator Post Follow-up to this message
Old Post
Larry
09-25-04 08:59 AM


Re: Help with files
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...


Report this thread to moderator Post Follow-up to this message
Old Post
Dave Cross
09-25-04 08:59 AM


Re: Help with files
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" <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



Report this thread to moderator Post Follow-up to this message
Old Post
G. Harrison Chiles Jr.
01-14-06 12:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:20 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.