in reply to Method Chaining and Accessors

Thanks for all your comments. It's been interesting reading! I'm a Unix system administrator by trade and even though I've been using Perl since the early 90s most of the time I'm just using it for quick and dirty hacks to get something working now. I relish the chance to do more advanced things with it, hence my question today.

I guess the main reason I wanted to use chained methods is because I've seen them used elsewhere and when it came to writing this current application I figured I'd try to figure them out for myself. Not because I particularly need them but just because I was curious. :-)

One of the things I love about Perl is that once you know the basics you can figure out how to do a lot of complicated things just by "guessing." So, in this instance I thought "I wonder if all I need to do is return $self to get chaining to work?" It did work but broke something else which is what prompted my question here.

I'll never forget when I found out about hashes of hashes. It turned out that I'd been using things like $foo{'bar'}{'baz'} for years because it just seemed logical to me to do it but I never realised that what I was doing actually had a name and that what I was really doing was storing an anonymous hash with a key of 'baz' in another hash with a key of 'bar'. Once I figured that out it opened up a whole world of complex data structures but it all stemmed from me just assuming that I could put multiple keys on a hash to create a multi-dimensional array and Perl would DWIM.

Anyway, that's just my longwinded way of saying thanks! I've been lurking here for a while reading people's questions and answers but this was my first question and even though it had a simple answer it has made me think a lot more about what I'm doing!