An alternative to using print STDERR "error message"; as sundialsvc4 suggested, you could do warn "error message"; which does the same thing.
Strictly speaking, no. They don't do the same.
warn does more than just printing to STDERR. warn appends filename and line number to the text, unless the text ends with a newline. It also checks $SIG{__WARN__}. If a handler is set, the handler is called and nothing is printed by warn itself. This is documented in perlfunc.
If you just want to print to the error output, use print STDERR. It does not modify the text, and it calls no handlers. If you need to warn that something is wrong, use warn.
And if there is a fatal error, use die. Don't mess with warn, print STDERR and exit in that case, because only die errors can be caught by the caller using eval (or $SIG{__DIE__}).
Alexander
--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
| [reply] [d/l] [select] |