#Minimal package A; use Want; sub sub :lvalue{ if( want('LVALUE', 'ASSIGN') ){ print want('ASSIGN'), "\n"; lnoreturn; } if( want('LIST') ){ rreturn 'xyzzy'; } else{ rreturn 'you were eaten by a grue'; } return; } package main; print A::sub, "\n"; print scalar A::sub, "\n"; A::sub() = 42; #### #To work properly comment out the next line package Xmas; use Want; use Lingua::EN::Numbers::Ordinate; @days = ; sub days :lvalue { if( want('LVALUE', 'ASSIGN') ){ my $n = shift; $days[$n] = want('ASSIGN'); lnoreturn; } if( want('SCALAR') ){ my $str = ''; foreach( 1..12 ){ $str .= sprintf $days[0], ordinate($_); $str .= join'', reverse(@days[1..$_]), "\n"; } return $str; } if( want('ARRAY') ){ if( my $n = howmany() ){ return @days[1..$n]; } return @days; } } return; } #To work properly comment out the next line, I also tried calling Xmas::days *main::days = \&days; package main; print scalar days(); days(5) = "Five onion rings!\n"; print scalar days(); __DATA__ On the %s day of Christmas, my true love gave to me A partridge in a pear tree. Two turtle doves Three French hens Four calling birds Five golden rings. Six geese a-laying, Seven swans a-swimming Eight maids a-milking Nine ladies dancing Ten lords a-leaping Eleven pipers piping Twelve drummers drumming