develooper Front page | perl.perl5.porters | Postings from April 2003

Re: [perl #21827] Carp::confess() reports wrong name for aliased subs

Thread Previous
Rafael Garcia-Suarez
April 7, 2003 07:07
Re: [perl #21827] Carp::confess() reports wrong name for aliased subs
Message ID:
Antti Lankila (via RT) <> wrote:
> I don't really care if this ever gets fixed or not, as I suspect people who
> make use of typeglob aliases deserve what they get. But nevertheless, I would
> like to have a clean way to alias functions to different names, as I sometimes
> need this feature. The less typing and runtime overhead to it, the better.
> % perl -wle 'use Carp; *foo = \&bar; sub bar { confess("Should be foo") } foo()'
> Should be foo at -e line 1
>          main::bar() called at -e line 1

I think that's intended, or at least useful, behaviour.
Consider the following script:

package Foo;
use Carp;
use Exporter;
    our @ISA = 'Exporter';
    our @EXPORT = 'bar';
sub bar { confess("Mea culpa") }
package main;
BEGIN { Foo->import(); }

It outputs:

Mea culpa at /home/rafael/x line 9
	Foo::bar() called at /home/rafael/x line 12

with the full name (as opposed to the aliased name) of the offending
function. It looks more useful to the programmer.

Unending is not *NIX

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About