On Saturday, June 22, 2002, at 08:24 , Harry Putnam wrote:

> drieux <[EMAIL PROTECTED]> writes:
>
>>>  I could stick lots of `prints'
>>> int there, but isn't there a way to simulate -x?
>>
>> This is where we all start and really shouldn't - but we all
>> do it - because at times it is 'simpler' to do. In this space
>> I normally do the gambit of
>>
>>      my $debug = 0;
>>
>> .....
>>      print "Some Skank here" if $debug ;
>>
>> and then flip that on or off....
>
> At risk of justifiably earning the `dumb as a stick' sobriquet, can
> I ask for a simple example of what you mean here?  How does $debug
> get a value and thus trip printing?

Forgive me for noting it - but You'll have to work much
harder to even get nominated in the "dumb as a stick" contest...

You might want to peek at say:

http://www.wetware.com/drieux/pbl/Sys/NextStuff/A_pipes_to_b.txt

I just set it at the top of the script - and use it as needed.
In this case I actually pass it along to a function -

        cleanUp($debug, map {$CmdPlays{$_}->{name}} keys %CmdPlays );

        ......

        #------------------------
        # well Given a Mess, Clean it up
        sub cleanUp {
        my ($debug,@progs) = @_;
        print "#---END GAME------\n# What were those command texts\n"
                                if ($debug);
        for my $cmd (@progs) {
                if($debug && -f $cmd) {
                print "Checking $cmd\n";
                open(FH, $cmd) or die "can not open $cmd:$!\n";
                print $_ while(<FH>);
                close(FH);
                print "\n#------- end of $cmd ----------\n";
                }
                unlink $cmd if ( -f $cmd);
        }
        } # end of cleanUp

So that while the code was running I could see that the 'cmds' I was
generating were what i expected of them...  simply by editing the
script and setting it to

        my $debug = 1;

The alternative strategy would have been to allow some sort of command
line change where we start down the path

        my $debug = 0;
        $debug++ if ( $ARGV[0] eq '-d' );

and then it's off to Getopt::Std or Getopt::Long - to make sure that
we actually do that right and all...

Given you request for a simple solution - this may be the way to have
a command line argument alternative that will turn on 'debug statements'
in selected places with

        myScript.plx -d

HTH....

{ but you really will want to get on a first name basis with the
perl debugger - It is WAY too much more cooler... }


ciao
drieux

---


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

Reply via email to