Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
This cannot be done easily I'm afraid as when you alias globs they merely point to the other glob (or in this case the subroutine). So when you call the aliased subroutine there's no difference to the the call except the name that you use (so caller() is useless). You can probably get the information using DB or one of the B:: modules though, but that would seem overkill in this case.

A simpler technique may be just to have a base sub and then wrap the other subs around it e.g

sub base { return "doing stuff" } sub foo { return base(). " in foo\n" } local *bar = sub { return base(). " in bar\n" }; foo(), bar(); __output__ doing stuff in foo doing stuff in bar
Simpler still use one of the Hook:: modules, or just take Zaxo's advice and use the ever-handy File::Spec.
HTH

_________
broquaint


In reply to Re: aliasing subs by broquaint
in thread aliasing subs by december

Title:
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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-26 06:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found