in reply to say statements within 'sub AUTOLOAD'
See the following:
#! /usr/bin/env perl package Foo; use strict; use warnings; use feature 'say'; sub AUTOLOAD { (my $method = our $AUTOLOAD) =~ s/.*:://; return if $method eq 'DESTROY'; say "Foo::$method was called"; die "bad method $method\n" if $method ~~ [qw/troz narf/]; if ($method eq 'day') { return +(localtime)[3]; } elsif ($method eq 'month') { return +(localtime)[4] + 1; } } package main; use strict; use warnings; use feature 'say'; say( Foo->day ); say( Foo->troz ); __END__ Foo::day was called 25 Foo::troz was called bad method troz
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: say statements within 'sub AUTOLOAD'
by ianyappy (Initiate) on Dec 25, 2010 at 17:22 UTC | |
by AnomalousMonk (Archbishop) on Dec 25, 2010 at 19:26 UTC | |
by ianyappy (Initiate) on Dec 26, 2010 at 03:04 UTC | |
by Anonymous Monk on Dec 25, 2010 at 18:23 UTC |