RE: Use Carp in package
Excellent, Thanks Jenda and Tassilo Yeah I did mean qw() instead of () oops. Thanks for the info, I think I will just use Carp; and take your wisdom and apply it's functions appropriately Thanks again! What a great list!!! Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Use Carp in package
On Tue, Jun 24, 2003 at 01:52:20PM -0500 Dan Muey wrote: > I'm writing a simple module to return a few variables and functions. > > The perldoc perlmod* stuff says I should use Carp; and call that > instead of warn(). > So.. > 1) > If I use Carp shoud I still use warnings; in the package? Those two are independent of each other. Carp provides ways for you, the programmer, do emit warnings and error messages. They'll show up no matter whether warnings are in effect. Warnings on the other hand will make the Perl interpreter emit messages when it has encountered something warnings-worthy. It's the same as with warn(): You use that indepently from warnings, too. > 2) > If I understand it correctly the preffered way would be to do: > > use Carp; > ... > carp("Watch your monkey"); > > Instead of: > ... > warn("Watch your monkey"); > > Is that a correct assumption? Yes, this is correct. > 3) > Should I just do > > use Carp(carp); > Since I'll only be calling carp() ( assuming carp() is warn()'s > replacement in Carp.pm ) That's up to you. Carp exports carp() and croak(). I usually end up needing both after a while. Tassilo -- $_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({ pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#; $_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~;eval -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Use Carp in package
From: "Dan Muey" <[EMAIL PROTECTED]> > I'm writing a simple module to return a few variables and functions. > > The perldoc perlmod* stuff says I should use Carp; and call that > instead of warn(). So.. 1) If I use Carp shoud I still use warnings; > in the package? Definitely. "use Carp" and "use warnings" are not as related as it may seem. "use warnings" is a pragma that controls the warnings issued by Perl itself, and "use Carp" allows you to issue a warning (or die) from perspective of caller. That is the message will contain the filename and line number of the call to your function, not of some line in the function itself. > 2) If I understand it correctly the preffered way > would be to do: > > use Carp; > ... > carp("Watch your monkey"); > > Instead of: > ... > warn("Watch your monkey"); Depends. If you want to say the user of your module did something you don't like you should use carp(), if you fail doing somethig you should warn(). Depends on where do you want the "user" of your module to look. > 3) > Should I just do > > use Carp(carp); > Since I'll only be calling carp() ( assuming carp() is warn()'s > replacement in Carp.pm ) I guess you mean use Carp qw(carp); yes, you may do that. Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]