porta has asked for the wisdom of the Perl Monks concerning the following question:
Hi to all. I'm a perl rookie and I started to struggle creating my own modules.
I'm having a question that I cannot answer by myself and I ask for your Wisdom to trow some light on my dilemma.
Lets say that I create a module Foo.pm, which has "new" sub.
Lets say I want to create a sub on Foo.pm that just returns the name of $one or $second.
Note that I need this to be able to catch and display my own custom warnings on Foo.pm and I want to give the name of the variable that caused the warning when printing on screen the warning message.
I hope my question is clear enough. I'm not a good english speaker so please excuse any error on the writing. Thanks in advance for any help or comment about this.
Lets say that I create a module Foo.pm, which has "new" sub.
And, I have my script test.pl which has:package Foo; sub new { my ($class) = @_; my $self = {}; bless $self, $class; }
And my question is: Is there a way that I can, inside Foo.pm, know the name of the variable that I'm using on test.pl?use Foo; my $one = Foo->new; my $second = Foo->new;
Lets say I want to create a sub on Foo.pm that just returns the name of $one or $second.
Note that I need this to be able to catch and display my own custom warnings on Foo.pm and I want to give the name of the variable that caused the warning when printing on screen the warning message.
I hope my question is clear enough. I'm not a good english speaker so please excuse any error on the writing. Thanks in advance for any help or comment about this.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Variable Name Mistery. Who calls?
by ikegami (Patriarch) on Oct 25, 2006 at 16:32 UTC | |
by Fletch (Bishop) on Oct 25, 2006 at 16:46 UTC | |
Re: Variable Name Mistery. Who calls?
by sauoq (Abbot) on Oct 25, 2006 at 17:17 UTC | |
by porta (Sexton) on Oct 25, 2006 at 18:53 UTC | |
by ikegami (Patriarch) on Oct 25, 2006 at 19:16 UTC | |
by cephas (Pilgrim) on Oct 25, 2006 at 19:26 UTC | |
by porta (Sexton) on Oct 25, 2006 at 22:17 UTC | |
by ikegami (Patriarch) on Oct 26, 2006 at 02:19 UTC | |
by ysth (Canon) on Oct 26, 2006 at 00:01 UTC | |
Re: Variable Name Mistery. Who calls?
by cephas (Pilgrim) on Oct 25, 2006 at 17:27 UTC | |
Re: Variable Name Mistery. Who calls?
by gam3 (Curate) on Oct 25, 2006 at 23:45 UTC | |
by Hofmator (Curate) on Oct 26, 2006 at 09:43 UTC | |
Re: Variable Name Mistery. Who calls?
by Anonymous Monk on Oct 25, 2006 at 17:26 UTC | |
Re: Variable Name Mistery. Who calls?
by DrHyde (Prior) on Oct 26, 2006 at 09:37 UTC |
Back to
Seekers of Perl Wisdom