Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

#!/usr/bin/perl -w

by reyjrar (Hermit)
on Oct 04, 2000 at 00:04 UTC ( [id://35178]=perlquestion: print w/replies, xml ) Need Help??

reyjrar has asked for the wisdom of the Perl Monks concerning the following question:

ok, so I'm at wits end here, I've been using strict since the begining, but this is the first time I've tried anything using -w and I'm not liking it much :)
Use of uninitialized value at /www/cgi-bin/beta.cgi line 277.
line 277: print <<"HTML";
another "heredoc" print does the same thing, but three other in the code don't, and they all use the same format and the same end tag name.
Use of uninitialized value at /www/cgi-bin/beta.cgi line 147
line 147 is just a print and I've check variables and stuff..

oh yeah, and previous to the 277 are two lines of comments, and the function declaration..
I'm totally lost :)

thanks, -brad.

Replies are listed 'Best First'.
Re: #!/usr/bin/perl -w
by tye (Sage) on Oct 04, 2000 at 00:08 UTC
    #!/usr/bin/perl -w use strict; my $good= "OK"; my $bad; print <<"HTML"; This block is $good. HTML print <<"HTML"; This block is $bad. HTML

    The first print won't give you a warning and the second one will. The line number reported in the warning is the line number of the statement. If the statement covers more than one line, then warnings on different lines but in the same statement will report the same line number.

    So it is some undefined value in the body of your heredoc that is causing the warning.

            - tye (but my friends call me "Tye")
(jcwren) Re: #!/usr/bin/perl -w
by jcwren (Prior) on Oct 04, 2000 at 00:09 UTC
    You'll get this error if you have a $variable in the heredoc text, that's not initialized. Since you're using "HTML" instead of 'HTML', any variable looking thingies will attempt to be interpolated.

    And Perl reports the error at the usage, rather than then actual line where the variable is, which can be a little frusterating at times (like, *all* the time...)

    --Chris

    e-mail jcwren
RE: #!/usr/bin/perl -w
by reyjrar (Hermit) on Oct 04, 2000 at 01:42 UTC
    cool, thanks all! :)
    seems kinda weird though, that I'd have to have the variable set to something.. but that's ok..figured out a way to get it working!

    perlmonks rocks as always..
    -brad..
      You aren't *forced* to have the variable set to something, but there's no really good reason to keep variables around without sticking something in them.

      It's just a warning, but it's a good sign that you're not quite done programming yet. :)

        > It's just a warning, but it's a good sign that you're not quite done programming yet. :)

        You mean there's a point at which one's done programming? Gee, and I always thought the client would call again tomorrow asking for something else to be included! <snicker>

        Seriously, I have found that one of the main reasons to use -w is not for immediate benefit as chromatic's post might suggest, but it keeps you from having to figure out issues later on when you come back to maintain the code. Its a win-win situation: safer now, and better later...

        #!/home/bbq/bin/perl
        # Trust no1!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://35178]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-25 08:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found