in reply to Debugging My Perl

Somtimes i have this problem both in C++ and PERL. In PERL you could use the fact that you can redirect any print ng to screen to a file insteed. Create a filehandle tex. $myDebug = open(.... and switch screen to this file with select Example:
----------------------------------
#!/usr/bin/perl

use warnings;
use strict;

open (DEBUG, ">debug.txt") || die $!;

print "Before redirecting to file\n";
select DEBUG;

print "This goes to de files\n";

select STDOUT;

print "And now we back\n";
-------------------------------------

// Anders

Replies are listed 'Best First'.
Re^2: Debugging My Perl
by Spidy (Chaplain) on Sep 06, 2004 at 05:51 UTC
    Hmmm. I tried doing this, and apparently it DID print to the file, as the file now exists, but it says there is an error in permissions, and won't let me open it. Any ideas?
      Sorry i missed
      That you have to close the file, under Linux i could read the file anyway but i have hade troble with this under Windows, that a open file don't give you right to read.

      add Close as below example

      select STDOUT;
      close(DEBUG); # Close the debugfile
      print "And now we back\n";

      // Anders