Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Syntax error with loopsby bart (Canon) |
on Feb 25, 2004 at 18:32 UTC ( [id://331758]=note: print w/replies, xml ) | Need Help?? |
Isn't $printnumber the object reference??Well... your problem seems to be that in Perl, not everything is an object. A number is not an object. So, you have to use ordinary operators for ordinary variables to make it do what you want. Here that would be something like or
Just for fun, I'll make $printnumber an object, and have it accept your syntax:
This produces:
initial value: -1 looping: 0 1 2 3 4 5 6 7 8 9 overload magic (adding 5): 14 still an object (adding 2): 16
In Section
Seekers of Perl Wisdom
|
|