in reply to Debugging Aid

One suggested improvement: you don't really need the "Start" tag... in place of the if/else/Start, this should be sufficient:
unlink "debug.log" if $type eq 'w';
Actually, even that statement should be unnecessary, too. :-) It looks like it's simple and good for what it does, but is there a reason for creating a separate script like this instead of using the perl debugger or even print statements within the original script?

Update: Ah, sorry, I think I misunderstood how it's to be used. In effect, this is a way of putting print statements in your original script. You may also want to look into Data::Dumper, which will let you print out data for types other than scalar.

Replies are listed 'Best First'.
Re: Re: Debugging Aid
by DaWolf (Curate) on Apr 12, 2002 at 16:25 UTC
    I've used the Start tag mainly to prevent an error. If you take a look at the line that says:
    unlink "debug.log" or goto Start
    You'll see that if the debug.log file doesn't exist, the script goes to the Start tag, instead of generating an error.

    Er Galvão Abbott
    a.k.a. Lobo, DaWolf
    Webdeveloper
      DaWolf, unlink will not error unless you tell it to. So, your default behaviour is to continue running the program as if nothing happened.

      Both goto Starts are redundant, as is the Start: label.

        Thanks.

        I didn't knew that unlink wont return an error if the file is not found.

        Er Galvão Abbott
        a.k.a. Lobo, DaWolf
        Webdeveloper