Welllll, actually, I just copied my perl directory from a file server
instead of installing it, so I don't have any of the modules, just the
compiler.  I get error messages when I use strict and warnings about @INC.
I need to sit down and install it correctly... next week, I think.

-Sarah (okay, it's stupid, but I'd have to get a tech to come to my computer
to install it because of the lock down and it's just stupid). 

-----Original Message-----
From: Chas Owens [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 13, 2002 10:49 AM
To: Kirby_Sarah
Cc: '[EMAIL PROTECTED]'
Subject: RE: How could this happen?


On Tue, 2002-08-13 at 10:26, Kirby_Sarah wrote:
> That would work if I was writing a script using a plan.  However what I do
> right now is just add one function at a time, going back to improve
sections
> of code whenever I figure out a better way of doing things.  It's a
terrible
> way to code, I know, but I never seem to be able to wait long enough to
> sketch out a plan and it works for the most part.  Most of the time when I
> really want to differentiate between print lines, I just put some nonsense
> in there like 'print "Grrr: $variable\n";  so I know that's the actual
line.
> I haven't gotten past the one program stage yet.  I will file that away
for
> when I start writing my code libraries.
> 
> -Sarah (not a hacker, just a hack programmer)

__LINE__ and __FILE__ are macros that become the line number and file
name of the current line, so they are always correct (hence the need for
version numbers in the log file since the line numbers of the messages
will change over time as lines are added/removed).  If you add the
following subroutine to all of your scripts you can replace your normal
debug by printing method with calls to DEBUG.

<example>
#!/usr/bin/perl

use warnings; #you are using warnings right?
use strict;   #you are using strict right?

our $VERSION = "1.0.0"
our $DEBUG   = 1; #set to 1 if your wish debug messages to be printed
code
code
code
DEBUG($variable);
code
DEBUG("Reached here and variable was $variable");
code

sub DEBUG {
        our $DEBUG;
        $DEBUG = 0 unless defined $DEBUG;
        return unless $DEBUG;
        our $VERSION;         #get access to the $VERSION variable
        $VERSION ||= "0.0.1"; #set a version if none exists 
                              #use //= in Perl 6
        print "DEBUG version $VERSION, pid $$, line " . 
                __LINE__ . ", file " . __FILE__ . "\n$_[0]\n;
} 
</example>

-- 
Today is Setting Orange the 6th day of Bureaucracy in the YOLD 3168
Pzat!

Missile Address: 33:48:3.521N  84:23:34.786W


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to