http://qs1969.pair.com?node_id=11138161


in reply to Procedural vs OOP modules

I'm totally on board with what choroba said.

If state needs to be shared between methods or even modules/classes, and/or you want to store an object of a different class in an object so you can make calls on it through the main object (eg. $computer_obj->video_card_obj->display();, OOP works (my RPi::WiringPi is a good example of that example, almost literally).

If no state needs kept, no magic between objects needs to happen, and your subroutine naming conventions won't likely clash with already-imported functions, procedural is the way to go (eg. Bit::Manip).

Other times, I've provided both a functional and object oriented interface within the same module for the same subroutines (eg: WiringPi::API).

Personally, the vast majority of the code I write keeps state, so I'd go as far as to guess that 90%+ of the 55 CPAN distributions I've published are OOP.