in reply to printing references

When an error is detected in the subroutine, I want to print out the name of the array

Arrays don't have names. All they have is an indexed list of references to scalar values. Consider the following case:

field (['foo', 'bar', 'baz'], 3, [map{somefunc()}@quux], 4);

What 'name' do you propose should be printed?

If you use warn or carp or something along those lines, you can get Perl to tell you the line number where your routine was called, and then you can look at that line in the source and see how it was called (e.g., what arrays were passed in), but if you want your arrays to have names then you need something more elaborate than garden-variety Perl arrays, some kind of object that knows how to report its name.


$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/