Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

How can I see a CPAN module's print message

by anaconda_wly (Scribe)
on Jan 06, 2013 at 07:00 UTC ( #1011838=perlquestion: print w/ replies, xml ) Need Help??
anaconda_wly has asked for the wisdom of the Perl Monks concerning the following question:

##Hi, happy new year perl monks! 1. I had add print message in a CPAN's module. But I didn't see any in output. Did they redirect it to somewhere else? 2. I see croak and carp used in a CPAN module. I add some in my code to display some message. But when I run, I didn't see any on screen, why Thanks! ##

Yes, as roboticus said, one error. I modified my question as this:

I want to trace the process of a module, say TieRegistry. So I add some print messge to it. For simple like below:

use vars qw( $RegObj %_Roots %RegHash $Registry ); carp "my print message\n ";#no print print "my print message\n ";#no print

The two lines are in a global place out of any function. So I think in my code, it will print the messages at the place of use, right?

use TieRegistry
I didn't see either of them.

Comment on How can I see a CPAN module's print message
Select or Download Code
Replies are listed 'Best First'.
Re: How can I see a CPAN module's print message
by roboticus (Chancellor) on Jan 06, 2013 at 07:37 UTC

    1) maybe

    2) you're doing it wrong.

    Seriously, though, how do you expect us to be able to tell you what you did wrong without you showing us what you did?


    When your only tool is a hammer, all problems look like your thumb.

Re: How can I see a CPAN module's print message
by live4tech (Sexton) on Jan 06, 2013 at 08:39 UTC

    If this code is in a package called "TieRegistry", you will not see the output from print statements outside of any methods (subroutines) in that module just by typing "use TieRegistry"

    If the print statements are in a subroutine in the package TieRegistry:

    package TieRegistry; use strict; use Carp; sub new { my $class = shift; my $self = bless {}, $class; } sub PrintThis { print "my print message\n"; }

    And then in your main program, after "use TieRegistry", you had:

    my $test = TieRegistry->new; $test->PrintThis;

    The line "my print message" would print.

      But why? As I can do it like this:
      use strict; use warnings; { package MyPackage; use Carp; carp "print message"; } 1;
      use MyPackage; &main; sub main { }

        Also consider that Perl will load the first file it finds in @INC. Inspect the values of %INC to find out which file Perl loaded, and which one you edited. See perlvar and Data::Dumper.

        use TieRegistry; print Dumper \%INC;

        That line will print because it's not in a sub. A line inside a sub can only print when that sub is actually executed.

        (The exception to this rule being a line that is evaluated at compile time. But it would be unusual to do this.)

        perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
Re: How can I see a CPAN module's print message
by live4tech (Sexton) on Jan 06, 2013 at 07:34 UTC

    Please provide code. Very difficult to help if we cannot see what you are referring to.

Re: How can I see a CPAN module's print message
by Anonymous Monk on Jan 06, 2013 at 07:49 UTC
    Why are you editing, what problem are you trying to solve?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1011838]
Approved by ansh batra
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2015-10-09 16:57 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (247 votes), past polls