in reply to Re^2: Any differences between method and method()?
in thread Any differences between method and method()?
Yes, as you can see from this demonstration code:
#!/usr/bin/perl -w use strict; my $list = ' FUD() => "()", "FUD" => "str", FUD => "bare", -FUD => "-", +FUD => + "+", '; sub FUD { 'fud' } for( 0 .. 1 ) { my @a = eval $list; print "@a\n"; last if $_; undef &FUD; eval 'sub FUD() { "dud" }'; } __END__ fud () FUD str FUD bare -FUD - FUD + dud () FUD str FUD bare -FUD - FUD +
While the FUD() case always calls the function (and thus gives 'fud' then 'dud') and the "FUD" case always doesn't call the function (and thus always gives 'FUD'), the other bareword cases are affected by whether or not a prototype is used and so give the follow inconsistent results:
FUD +FUD -FUD ----- ----- ------ w/ prototype: FUD FUD -FUD w/o prototype: FUD FUD -FUD
Happy debugging!
Like anybody could possibly debug such wily inconsistency! So funny.
Update: Sorry, I accidentally reversed the "w/" vs "w/o" labels in the above table. Sorry for the confusion that must have caused.
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Any differences between method and method()? (=>)
by AnomalousMonk (Archbishop) on Aug 18, 2012 at 19:43 UTC | |
|
Re^4: Any differences between method and method()? (=>)
by sophate (Beadle) on Aug 19, 2012 at 04:32 UTC | |
by AnomalousMonk (Archbishop) on Aug 19, 2012 at 05:11 UTC | |
by Anonymous Monk on Aug 19, 2012 at 04:38 UTC |