Da_Lu has asked for the wisdom of the Perl Monks concerning the following question:

I'm developing a house-keeping program much like logrotate, but with some extension specifically modeled to our company. Since I want this thing to have as-readable-as-possible code I'm trying to go OOP all the way. And the proper way to do errors in OOP are exceptions (for all I know). Now, I know about Error, Exception::Class, and why $@ is unreliable.

But here's the crux of the thing: none of the servers really has any modules besides the core of 5.8.8, as packaged by ActiveState; none of the servers is allowed access to the Internet at all, so there's no CPAN; and finally, all third party software installs have to be approved and packaged for all possible systems.

So my question is: is there any other way for an half-way decent exception handling besides the fugly eval { ... }; if ( $@ ) { ... } or importing Error via the "smuggling bay" by making it part of my package?

Replies are listed 'Best First'.
Re: Objects and Exceptions sans CPAN
by marto (Cardinal) on Jan 13, 2010 at 10:15 UTC

    I was in a similar situation with a client a while ago. On several servers I built Perl 5.8.8 from source. Their network had no internet connectivity, though I could transfer files between networks via a USB memory stick and an uploader station. On my own network I used CPAN::Mini to create a local mirror. After some discussion with their Security team, the agreed to allow me to host this internally to their network. Given that you work for the company in question making them see sense in allowing you to do something similar shouldn't be a big issue. As you say you could copy and paste the source of a module from cpan, which in theory breaks their 'third party rule'.

    In order to protect yourself from any potential disciplinary actions I think you should discuss such a course of action as detailed above.

      Haven't heard about CPAN::Mini, thanks for that.

      The problem isn't so much the approval process (shouldn't be too much of an issue), but the packaging process: I'd have to create packages for 2 operating systems (Linux and HP-UX), in different versions (3 each), on different platforms (4 in total), which IMO is too much overhead for one piece of software that's not even written yet. Thus my question for a simpler way.

      By the way, Error would have been perfect (pure Perl, 1 file, simple usage), if it weren't that its use is discouraged by the author.

        Did you look at Try::Tiny?


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        How many machines are you going to install this applcation on? Does each of them have perl installed? If so you could host your CPAN::Mini generated mirror internally and create a bundle of modules to be installed.

        Have you considered using PAR to package your application. It may be worth looking at PAR,PAR::Tutorial and pp.

Re: Objects and Exceptions sans CPAN
by almut (Canon) on Jan 13, 2010 at 10:22 UTC
    ...or importing Error via the "smuggling bay" by making it part of my package

    What's wrong with making it part of your package?  When third party packages have to get approved, simply try to avoid them, and ship all you need together with your own program...

Re: Objects and Exceptions sans CPAN
by JavaFan (Canon) on Jan 13, 2010 at 10:53 UTC
    Since I want this thing to have as-readable-as-possible code I'm trying to go OOP all the way.
    That doesn't follow, IMO. It's easier to make things unreadable by using OO than not. OO, specially so-called 'readable' OO, quickly goes to "you're in maze of twisty little packages, all alike".

      If I'd wanted perfectly readable code, I'd have chosen COBOL. :P

      But seriously, I'm going with OOP as I'm trying to encapsulate logical units as small as possible, and with defined interfaces between them. I've had design help from one of our senior programmers, and exception handling was one of the last "problems" we've had. To be honest, based on the current design if it weren't for bless and new you'd see a few regular packages.

Re: Objects and Exceptions sans CPAN
by ikegami (Patriarch) on Jan 13, 2010 at 16:29 UTC
    Just a note on one point,

    none of the servers is allowed access to the Internet at all, so there's no CPAN

    You don't need the internet to use cpan (CPAN::Mini), and even if you did, you don't need cpan to install modules.