Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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.

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (1)
As of 2017-06-27 19:46 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (612 votes). Check out past polls.