use
5.006 ;
our
@ISA
=
qw(Exporter)
;
our
%EXPORT_TAGS
=
(
'all'
=> [
qw()
]
) ;
our
@EXPORT_OK
= ( @{
$EXPORT_TAGS
{
'all'
} } ) ;
our
@EXPORT
;
push
@EXPORT
,
qw( Ref )
;
our
$VERSION
=
'0.02'
;
sub
Ref
{
my
$self
=
shift
;
if
(
defined
$self
&& __PACKAGE__ eq
ref
$self
)
{
my
$information
=
shift
;
confess
"First argument to 'Ref' should be a description"
unless
''
eq
ref
$information
;
my
%references
=
@_
;
my
%address_to_reference
;
my
$spreadsheet_reference_sub
=
bless
[
$information
,
sub
{
${
$address_to_reference
{
$_
[1]}} =
$_
[2] ;
}
,
sub
{
${
$address_to_reference
{
$_
[1]}}
}
],
"Spreadsheet::Perl::Reference"
;
while
(
my
(
$address
,
$reference
) =
each
%references
)
{
for
my
$current_address
(
$self
->GetAddressList(
$address
))
{
$address_to_reference
{
$current_address
} =
$reference
;
$self
->Set(
$current_address
,
$spreadsheet_reference_sub
) ;
}
}
}
else
{
my
$information
=
$self
;
confess
"First argument to 'Ref' should be a description"
unless
''
eq
ref
$information
;
my
$reference
=
shift
;
confess
"Error: 'Ref' takes a reference as argument"
unless
(
defined
$reference
) ;
for
(
ref
$reference
)
{
'SCALAR'
eq
$_
&&
do
{
return
bless
[
$information
,
sub
{
$$reference
=
$_
[2] ;}
,
sub
{
$$reference
}
],
"Spreadsheet::Perl::Reference"
;
} ;
confess
"Error: 'Ref' doesn't know how to handle reference of type '$_'"
;
}
}
}
sub
get_reference_description
{
my
(
$self
,
$address
) =
@_
;
my
@information
;
for
my
$current_address
(
$self
->GetAddressList(
$address
))
{
if
(
exists
$self
->{CELLS}{
$current_address
})
{
if
(
exists
$self
->{CELLS}{
$current_address
}{REF_SUB_INFO})
{
push
@information
,
$self
->{CELLS}{
$current_address
}{REF_SUB_INFO} ||
''
;
}
}
else
{
push
@information
,
''
;
}
}
return
@information
;
}
*REF_INFO
= \
&get_reference_description
;
1 ;