in reply to Re: say statements within 'sub AUTOLOAD'
in thread say statements within 'sub AUTOLOAD'
Hi, and many thanks (with a belated Merry Xmas) for the reply. Wish to address it in point form:
1. Using strictures: I did use those strictures (written outside the braces for the package MyDate). My bad for not reproducing it.. So I don't think its about any error being generated because i didn't declare those strictures. Using print rather than say didn't make any difference either.
2. Coderefs: I'm not quite sure what you mean by me not assigning a coderef? I defined the subroutines within my if statements.. so if $method was 'day' wouldn't &$method be calling &day? I did get the desired outputs from the subroutines.. so it seems to me like that wasn't a problem either.
3. Defining subs: I was learning AUTOLOAD (from Intermediate Perl) in the context of dynamically defining new subroutines, while your code only returns the desired value. I presume that means that if I write
say( Foo->day ); say( Foo->month ); say( Foo->day );
I would expect the output
Foo::day was called 26 Foo::month was called 12 26
rather than the actual output
Foo::day was called 26 Foo::month was called 12 Foo::day was called 26
Actually I get the impression that AUTOLOAD isn't even being called. Changing the words in my grep statement or writing if ( $method eq "dayz") {...} doesn't produce any errors while changing the name of my subroutine does. So erm...:S why?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: say statements within 'sub AUTOLOAD'
by AnomalousMonk (Archbishop) on Dec 25, 2010 at 19:26 UTC | |
by ianyappy (Initiate) on Dec 26, 2010 at 03:04 UTC | |
|
Re^3: say statements within 'sub AUTOLOAD'
by Anonymous Monk on Dec 25, 2010 at 18:23 UTC |