Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Determining a module's user

by clueless newbie (Chaplain)
on Oct 10, 2007 at 15:54 UTC ( #644003=perlquestion: print w/replies, xml ) Need Help??
clueless newbie has asked for the wisdom of the Perl Monks concerning the following question:

I have a module which uses Filter::Simple and I would like to know while filtering the name of the module that I'm filtering. Is there any way to do that?

Replies are listed 'Best First'.
Re: Determining a module's user
by Fletch (Chancellor) on Oct 10, 2007 at 16:37 UTC

    caller looks to work sanely inside the Filter::Simple called block (at least with a quick test module).

    $ cat FSTest.pm package FSTest; use Filter::Simple; FILTER { print STDERR "in FILTER, caller package: ", (caller( 1 ))[0], "\n"; } 1; $ perl -MFSTest -e 0 in FILTER, caller package: main

    Update: Oop. Quick test module FTL then apparently. You may can get at it by calling caller in a custom import sub of your own, of you might have to fall back to using Filter::Util::Call instead. We're past my simple experience with Filter::Simple at any rate.

      For me (Windows/Activestate 5.8) it doesn't. If "main" calls "package" and "package" uses the filtering module, (caller( 1 ))[0] returns not "package" but "main".

      I've found a poor work around that involves "use myFilter __PACKAGE__;".

      Thanks, Fletch!
      --- it seems to be (caller(1))[1]!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://644003]
Approved by perrin
help
Chatterbox?
[Discipulus]: good morning again monks!
[choroba]: Good morning!
[Corion]: I have a rough plan to release an ImageNet classifier in Perl (well, using pretrained data, but still a nice toy)
Discipulus is going mad with the new win10 client.. tried mv Cortana /dev/null but no succes
[Corion]: Ouch - another pretrained set is available, using images from IMDB and Wikipedia. So I expect interesting results for non-PR images where people are pictured that are not made up
[Corion]: Discipulus: Yeah, from my investigations, you can somewhat silence+disable Cortana, but some services of it remain always running unfortunately. What a waste of resources :-/
[Corion]: I hope you had a good weekend still ;)
choroba had a workshop with the band

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2017-09-25 08:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (277 votes). Check out past polls.

    Notices?