|
|||||||||||||||||||||||||||
On Tue, 02 Nov 1999, sslug@sslug wrote:
> Lars Clausen wrote:
>>
>> >> 2) brug "use strict". Den vil tvinge dig til at deklarere alle de
>> >> variabler
>> > Og hvordan er det lige jeg gør det ???
>>
>> use strict;
>>
>
> Øhh...hmmm jeg tror du har ledt mig helt på vildspor... jeg får en masse
> fejl lige som denne:
>
> "Global symbol "$ny_domain" requires explicit package name at ./file.pl
> line 80"
Når du bruger strict, skal du erklære alle variabler, f.eks. med my ($foo,
$bar...).
> kan du ikke pege på et link eller fortælle hvordan jeg kan erklare de
> variabler ???
> Og det er EFTER jeg har skrevet "use strict;" i toppen af programmet.
Først, fra Perl FAQ:
How do I debug my Perl programs?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Have you used -w? It enables warnings for dubious practices.
Have you tried use strict? It prevents you from using symbolic references,
makes you predeclare any subroutines that you call as bare words, and
(probably most importantly) forces you to predeclare your variables with my
or use vars.
Did you check the returns of each and every system call? The operating
system (and thus Perl) tells you whether they worked or not, and if not
why.
open(FH, "> /etc/cantwrite")
or die "Couldn't write to /etc/cantwrite: $!\n";
Did you read the perltrap manpage? It's full of gotchas for old and new
Perl programmers, and even has sections for those of you who are upgrading
from languages like awk and C.
Have you tried the Perl debugger, described in the perldebug manpage? You
can step through your program and see what it's doing and thus work out why
what it's doing isn't what it should be doing.
Mere forklaring på
<URL:http://www.netcat.co.uk/rob/perl/win32perltut.html#163-BondageandDiscipline>.
-Lars
--
Lars R. Clausen (http://shasta.cs.uiuc.edu/~lrclause) Hårdgrim of Westfield
"I do not agree with a word that you say, but I will defend to the death your
right to say it." -- Voltaire (?)
|
||||||||||||||
|
||||||||||||||