I did this initially, but I got the following error: Undefined subroutine &print_r::print_r called at ./print_r.pl line 55.
Odd. If I take out the main:: prefix, and the package declaration I receive no error. In fact, I've never seen a package declaration within a subroutine. It seems strange, to say the least, and I wonder if it does what you think it does. What do you think it does?
Looking more closely at the code, I suspect you want my variables and not our.
As to why you want to have an object reference itself, one answer is "it makes life easier". It most frequently occurs in hierarchical structures, where one of the keys at a node will be a reference to an ancestor or sibling. It makes it easier to move around in the object without having to maintain context. Have a look at an XML::Twig object some time.
• another intruder with the mooring in the heart of the Perl
In reply to Re^3: print_r
by grinder
in thread print_r
by GhodMode
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |