Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Very basic question on reading error messages

by jerrygarciuh (Curate)
on Sep 07, 2001 at 21:10 UTC ( [id://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.
tia
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.
    HTH

    broquaint

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 myprogram.pl 2>errors.txt # Or on WinNT you can do just like Unix: perl myprogram.pl 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 'script.pl'" perl -e "open(STDERR,'>>errors.log'); exec $^X,'script.pl'"
      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.

        —John

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.

    Yves
    --
    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 myprogram.pl | 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 myprogram.pl 2>&1 | more

      -Blake

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

      —John

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.

    Cheers!
      ... 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 http://open-perl-ide.sourceforge.net

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

      pmas
      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)
    jg

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-19 19:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found