Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Very basic question on reading error messages

by jerrygarciuh (Curate)
on Sep 07, 2001 at 21:10 UTC ( #110947=perlquestion: print w/replies, xml ) Need Help??

jerrygarciuh has asked for the wisdom of the Perl Monks concerning the following question:

During local testing when I use strict; and
use warnings; I get so many errors I
can't see them on my screen from command prompt or in ms-
dos popup window. How do I get to these to read
them. I read some stuff in the library on debugging but
I didn't quite get it.
jerry garciuh

Replies are listed 'Best First'.
Re: Very basic question on reading error messages
by broquaint (Abbot) on Sep 07, 2001 at 21:37 UTC
    Perhaps not a basic solution to a basic questions, but hopefully useful all the same
    $SIG{__WARN__} = sub { open(ERR, ">>error.log") or die ("Died because: $!\n"); print ERR @_; close(ERR); };
    What this does is re-assigns the __WARN__ signal handler (the thing that handles all warnings) to an anonymous sub that outputs the warnings to a file. So now STDERR should be nice and quiet.


Re: Very basic question on reading error messages
by runrig (Abbot) on Sep 07, 2001 at 21:17 UTC
    Redirect errors to a file and read them at your leisure:
    perl 2>errors.txt # Or on WinNT you can do just like Unix: perl 2>&1 | more

      The first one doesn't work under Win9x either (IIRC). If you are on Win9x, the command shell is so broken that there is no way to get it to send STDERR to a file. Luckilly, you have Perl which means you have lots of ways you could do it:

      perl -e "open(STDERR,'>>errors.log'); do ''" perl -e "open(STDERR,'>>errors.log'); exec $^X,''"
      to give just a couple that I didn't notice already in this thread. (:

              - tye (but my friends call me "Tye")
        program -args >& out.txt works just fine if you use the 4NT shell. Nobody in his right mind who actually uses the command line would try and cope with CMD.exe or worse yet COMMAND.COM.


Re: Very basic question on reading error messages
by demerphq (Chancellor) on Sep 07, 2001 at 22:31 UTC
    Aside from the other worthy responses about how to capture to a file or to use more you could get yourself an editor that will do it for you.

    My preference is UltraEdit (I am a W2K user), but there are many others (and for as many editors there are there are 100 times more opinions as to which is the best etc, the source of many a holy flame war). I suggest you do a search for programming editors in super search.

    Another advantage to using a propper editor is that you get syntax highlighting, hexadecimal view, commenting in some even auto-format. A good programming editor is just as useful (if not more) than an IDE like VB/C++ and is an essential part of a good coders toolbox.

    You are not ready to use symrefs unless you already know why they are bad. -- tadmc (CLPM)

Re: Very basic question on reading error messages
by jlongino (Parson) on Sep 07, 2001 at 21:21 UTC
    If you don't want to mess with a separate file, use:

    perl | more

    Update: Sorry. The above doesn't work as per blakem (below). Could have sworn I used it before. BTW, it doesn't work for similar reasons under Unix either.

    @a=split??,'just lose the ego and get involved!';
    for(split??,'afqtw{|~'){print $a[ord($_)-97]}
      That will pipe STDOUT through more, but if a ton of messages are being dumped to STDERR it wont solve anything. Use something like this to send both STDERR and STDOUT through more
      perl 2>&1 | more


      Under 4NT shell,  myprogram |& more or better yet myprogram |& list /S.


Re: Very basic question on reading error messages
by cmilfo (Hermit) on Sep 07, 2001 at 22:53 UTC
    If you are new to Perl (I think you mentioned this earlier), then you might be new to the whole command line programming scene. If you don't like writing your output to a file and reading, you might try just making your command prompt buffer bigger. It has been a while since I've changed this, but if memory serves me, you right click on the menu bar of your window and click on properties. Then look through the menu options for the buffer size. Crank that puppy up!

    Another option for you might be to use an IDE. Then your output will be written to an onscreen scrollable buffer.

    I've seen two that look decent:

    Komodo from ActiveState
    PerlBuilder from SolutionSoft

    They both cost money, but sometimes it is worth it. Personally, I just use Vim. But, I work on Linux machines, and I can make my command line buffers, HUGE.

      ... and because it is perl, we have also free open-source IDE:

      Jürgen Güntherodt anounced Open Perl IDE, free lookalike of VisualPerl, with features:
      -Perl Syntax Coloring
      -Visual Debugging
      -Integrated Help System
      -Customizable Environment

      Jürgen invited to look at

      Try take a look, and then tell us...:)

      To make errors is human. But to make million errors per second, you need a computer.

Re: Very basic question on reading error messages
by jerrygarciuh (Curate) on Sep 07, 2001 at 23:50 UTC
    Thank you all for answers!
    I am working on using them now.
    º º º (or peas by degrees)

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://110947]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2022-06-28 21:29 GMT
Find Nodes?
    Voting Booth?
    My most frequent journeys are powered by:

    Results (92 votes). Check out past polls.