in reply to Re: Stupid OO question
in thread Stupid OO question

That eval/use is a bit over the top, although it'll work. I'll prefer this:
BEGIN { if ($some_condition) { require Win32::SerialPort; import Win32::SerialPort qw(:ALL); } else { require Device::SerialPort; import Device::SerialPort qw(:ALL); } }
There. A conditional "use".

P.S. I just typed this earlier today on comp.lang.perl.tk. I wonder if this is the same person. {grin}

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
RE: RE: Re: Stupid OO question
by tye (Sage) on Aug 03, 2000 at 06:42 UTC

    Good point. I was thinking of the general case when the module name is in a scalar. But I couldn't come up with a good example of that for the first example. Of course, you can try converting "::"s to the appropriate directory separators and adding on ".pm", put I think porting that to VMS would be some work (I'd probably pull in parts of MakeMaker).

    But for the example I came up with, your solution is superior.