Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

STERR and STDERR any difference?

by edwardt_tril (Sexton)
on Jan 29, 2006 at 20:14 UTC ( [id://526311]=perlquestion: print w/replies, xml ) Need Help??

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

Hi is there absolutely no difference between STDERR & STERR?
If any, can someone provide some code to illustrate the difference?
Thanks

Replies are listed 'Best First'.
Re: STERR and STDERR any difference?
by superfrink (Curate) on Jan 29, 2006 at 21:32 UTC
    Normally on unix-like systems a process is started with three open file descriptors. STDIN, STDOUT, STDERR. (Think "standard in", "standard out", "standard error".) Each file descriptor has a traditional use.

    Programs read from STDIN. Normally this means the program reads from the console but it is often from a pipe.

    Programs write the normal output to STDOUT. Normally this means when the program writes to STDOUT it goes to the console but it is often sent to a pipe.

    Programs write error related output to STDERR. Again normally this means when the program writes to STDERR it goes to the console but it is often sent to a pipe.

    Note that there is no requirement that the programs you write report errors to STDERR but most unix programs do. The reason is someone might throw away STDOUT because they don't actually want to see it but if an error shows up they do want to see it. For example "some_program > /dev/null".

    To see the difference run this program:
    #!/usr/bin/perl -w use strict; print STDOUT "this is stdout\n"; print STDERR "this is stderr\n";
    STDOUT is given the number 1 and STDERR the number 2. (STDIN is number 0, ie zero.) These BASH shell commands will show you what happens when you redirect the different files to the junk bin "/dev/null".
    $ ./stdout-stderr.pl 1>/dev/null this is stderr $ ./stdout-stderr.pl 2>/dev/null this is stdout

    If you are new to unix programming you should have a look at the Unix Programming Frequently Asked Questions.
Re: STERR and STDERR any difference?
by brian_d_foy (Abbot) on Jan 29, 2006 at 22:06 UTC

    STDERR is the filehandle name for output to standard error, and the name is special in Perl (see perlvar). STERR is nothing special in Perl, although someone might have used it as the name for a filehandle.

    You don't need any code to illustrate the difference because there's no difference to show. :)

    Where did you see this and why do you ask?

    --
    brian d foy <brian@stonehenge.com>
    Subscribe to The Perl Review
Re: STERR and STDERR any difference?
by zentara (Archbishop) on Jan 29, 2006 at 20:26 UTC
    You must be using windows, because on linux
    #!/usr/bin/perl use warnings; use strict; print STDERR "STDERR oops\n"; print STERR "STERR oops\n";
    gives
    Name "main::STERR" used only once: possible typo at ./z8a line 7. STDERR oops print() on unopened filehandle STERR at ./z8a line 7.

    I'm not really a human, but I play one on earth. flash japh
      Same error on my activestate 5.8.1 on win32
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: STERR and STDERR any difference?
by ambrus (Abbot) on Jan 30, 2006 at 08:45 UTC

    However, the stderr handle is aliased to STDERR for compatibility with older perls.

Re: STERR and STDERR any difference?
by spiritway (Vicar) on Jan 31, 2006 at 01:20 UTC

    They are not identical. STDERR is a handle, automatically opened, used to display error messages. I don't find anywhere that STERR is a Perl variable (or an OS variable, either).

    The main difference between the two is that STDERR is automatically opened when you start Perl (along with STDIN and STDOUT). You can print to or read from these three handles right away, without having to open them. If you want to use STERR as a handle, you need first to open it.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-24 10:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found