1: ## get it while it's hot (cause it's not part of wxPerl core yet)
   2: 
   3: #############################################################################
   4: ## Name:        Carp.pm
   5: ## Purpose:     Wx::Carp class (a replacement for Carp in Wx applications)
   6: ## Author:      D.H. aka PodMaster
   7: ## Modified by:
   8: ## Created:      12/24/2002
   9: ## RCS-ID:      
  10: ## Copyright:   (c) 2002 D.H.
  11: ## Licence:     This program is free software; you can redistribute it and/or
  12: ##              modify it under the same terms as Perl itself
  13: #############################################################################
  14: 
  15: =head1 NAME
  16: 
  17: Wx::Carp - a replacement for Carp in Wx applications
  18: 
  19: =head1 SYNOPSIS
  20: 
  21: Just like L<Carp>, so go see the L<Carp> pod (cause it's based on L<Carp>).
  22: 
  23:     # short example
  24:     use Wx::Carp;
  25:     ...
  26:     carp "i'm warn-ing";
  27:     croak "i'm die-ing";
  28: 
  29: =head1 SEE ALSO
  30: 
  31: L<Carp> L<Carp> L<Carp> L<Carp> L<Carp>
  32: 
  33: =head1 COPYRIGHT
  34: 
  35: (c) 2002 D.H. aka PodMaster (a proud CPAN author)
  36: 
  37: =cut
  38: 
  39: package Wx::Carp;
  40: 
  41: BEGIN {
  42:     require Carp;
  43:     require Wx;
  44: }
  45: 
  46: use Exporter;
  47: @ISA         = qw( Exporter );
  48: @EXPORT      = qw( confess croak carp );
  49: @EXPORT_OK   = qw( cluck verbose );
  50: @EXPORT_FAIL = qw( verbose );              # hook to enable verbose mode
  51: 
  52: sub export_fail { Carp::export_fail( @_) } # make verbose work for me
  53: sub croak   { Wx::LogFatalError( Carp::shortmess(@_) ) }
  54: sub confess { Wx::LogFatalError( Carp::longmess(@_) ) }
  55: sub carp    { Wx::LogWarning( Carp::shortmess(@_) ) }
  56: sub cluck   { Wx::LogWarning( Carp::longmess(@_) ) }
  57: 
  58: 1;

Replies are listed 'Best First'.
Re: Wx::Carp - a replacement for Carp in Wx applications
by ibanix (Hermit) on Dec 25, 2002 at 18:25 UTC
    I'm not a genius when it comes to modules... but didn't you just export Carp subs and rename them under Wx::Carp?

    I'd love to know if I'm wrong, or missing something important.

    Cheers,
    ibanix

    $ echo '$0 & $0 &' > foo; chmod a+x foo; foo;
      /me looks around a little confused
      but didn't you just export Carp subs and rename them under Wx::Carp?
      No, that's not all I did. Instead of warning or dieing, Wx::LogFatalError and Wx::LogWarning are called.

      I use Carp; all the time. When I write CGI apps, I use CGI::Carp, cause it does things appropriate for a CGI environment.

      Ah, that makes me think I should've put die and warn in there, i'll do that, thanks.

      ###################################################################### +####### ## Name: Carp.pm ## Purpose: Wx::Perl::Carp class (a replacement for Carp in Wx app +lications) ## Author: D.H. aka PodMaster ## Modified by: ## Created: 12/24/2002 ## RCS-ID: ## Copyright: (c) 2002 D.H. ## Licence: This program is free software; you can redistribute it + and/or ## modify it under the same terms as Perl itself ###################################################################### +####### =head1 NAME Wx::Perl::Carp - a replacement for Carp in Wx applications =head1 SYNOPSIS Just like L<Carp>, so go see the L<Carp> pod (cause it's based on L<Ca +rp>). # short example Wx::Perl::Carp; ... carp "i'm warn-ing"; croak "i'm die-ing"; =head1 SEE ALSO L<Carp> L<Carp> L<Carp> L<Carp> L<Carp> =head1 COPYRIGHT (c) 2002 D.H. aka PodMaster (a proud CPAN author) =cut package Wx::Perl::Carp; BEGIN { require Carp; require Wx; } use Exporter; @ISA = qw( Exporter ); @EXPORT = qw( confess croak carp die warn); @EXPORT_OK = qw( cluck verbose ); @EXPORT_FAIL = qw( verbose ); # hook to enable verbose mo +de sub export_fail { Carp::export_fail( @_) } # make verbose work for me sub croak { Wx::LogFatalError( Carp::shortmess(@_) ) } sub confess { Wx::LogFatalError( Carp::longmess(@_) ) } sub carp { Wx::LogWarning( Carp::shortmess(@_) ) } sub cluck { Wx::LogWarning( Carp::longmess(@_) ) } sub warn { Wx::LogWarning( @_ ) } sub die { Wx::LogFatalError( @_ ) } 1;
      update: i've renamed it to Wx::Perl::Carp in keeping with what Mattia setup.


      MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
      ** The Third rule of perl club is a statement of fact: pod is sexy.

        Ok, I think I get it now. You call Carp and pipe the output through Wx::LogFatalError or ::LogWarning; and that's what you get when you use Wx::Carp and then call carp "foo!" later.

        Am I right?

        $ echo '$0 & $0 &' > foo; chmod a+x foo; foo;