#!/usr/bin/perl
#

package LoudDecl;
use strict;
use warnings;
use Attribute::Handlers;

sub Loud :ATTR {
    my ($package, $symbol, $referent, $attr, $data, $phase) = @_;

    print STDERR "($referent), ", ref($referent), " ";
### comment out next line to make things work
    print STDERR *{$symbol}{NAME}, " ";
    print STDERR "got attribute ${attr} ";
    print STDERR "with data ($data), ";
    print STDERR "in phase $phase\n";
}

package main;

use strict;
use warnings;
our @ISA;
BEGIN { push @ISA, 'LoudDecl' };

sub foo :Loud(Boe)
{
    my $arg = shift;
    return "foo $arg";
}

# this works only if inside a BEGIN block:
require "bar.pl";
# bar.pl contains:
#sub bar :Loud(Hello)
#{
#    my $arg = shift;
#    return "bar $arg";
#}
#
#1;
#
#-- or if it is inlined

print foo("hi"), "\n", bar("boo"), "\nDone\n";
