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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I've looked around for a way to easily debug scoping problems. I used App::Trace, and Devel::SimpleTrace, which I prefer to diagnostics. I didn't cleanup the code, but I followed chromatic's advice about single-argument bless being almost always an error and fixed the bless; also, I declared $sound1 and $sound2 in your sound sub.
#!/usr/bin/perl -T use strict; use warnings; use App::Options; use App::Trace; use Devel::SimpleTrace; Animal::Hog->sound(); { package Animal::Hog; sub new { &App::sub_entry if ($App::Trace); my ($this, @args) = @_; my $class = ref($this) || $this; my $self = { @args }; bless $self, $class; &App::sub_exit($self) if ($App::Trace); return($self); } sub sound { my $sound1 = 'knor1'; my $sound2 = 'knor2'; &App::sub_entry if ($App::Trace); my $self = shift; &App::sub_exit($_) if ($App::Trace); print $sound1, "\n", $sound2, "\n"; } if ($App::debug && &App::in_debug_scope) { print "Debug output\n"; } }

In reply to Re^2: scope and declaration in local packages by Khen1950fx
in thread scope and declaration in local packages by december

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-04-19 14:32 GMT
Find Nodes?
    Voting Booth?

    No recent polls found