in reply to using warn instead or print STDERR?

Meh, they both work fine. That said, I like to have a numerical debug level -- categories are too complicated, and on-or-off is too coarse -- and to write debugging statements like this:
dprint 1, "this is debugging"
Then you can implement dprint as e.g.
sub dprint { my $level = shift; return unless $DEBUG >= $level; my ($file, $line) = (caller)[1,2]; print STDERR "$file:$line: @_\n"; }