pashanoid has asked for the wisdom of the Perl Monks concerning the following question:
Hello! I've searched and could not find this:
How do I go about "mentioning" a module in my program that does not exist on my system. This particular module WILL NOT install on a Linux system, but will on a Win32 system. However, in the logic of the program this module will not be used unless we're on windows.... example:
my $os = $^O; my $text_os = $c->createText($x0+570,$y0+10,-text=>"ОС: $o +s", -font=>'bar_rus', -fill=>'#afb3b0',-anchor=>'s',-tags => ['os']); eval { if ($os =~ /Win/ig){ use Win32::SerialPort; #we're on Windows } else { use Device::SerialPort; #we're on Linux } }
See, If I run this I get an error like:
[pasha@pelikan tk]$ perl dial.pl Can't locate Win32/SerialPort.pm in @INC (@INC contains: /usr/local/li +b/perl5 /usr/local/share/perl5 /usr/lib/perl5 /usr/share/perl5 /usr/l +ib/perl5 /usr/share/perl5 /usr/local/lib/perl5/site_perl/5.10.0/i386- +linux-thread-multi /usr/local/lib/perl5/site_perl/5.10.0/i386-linux-t +hread-multi /usr/local/lib/perl5/site_perl/5.10.0 /usr/lib/perl5/vend +or_perl/5.10.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl /us +r/lib/perl5/site_perl .) at dial.pl line 33. BEGIN failed--compilation aborted at dial.pl line 33.
But there is no way that I can install the Win32::SerialPort on my Linux box. Nore do I want to :)
Is there a way to have the module mentioned in my program and avoid the interpreter error?
Live long and proseper!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: mention a non-installed module in script
by ikegami (Patriarch) on Jun 15, 2011 at 06:06 UTC | |
by pashanoid (Scribe) on Jun 16, 2011 at 03:23 UTC | |
|
Re: mention a non-installed module in script
by ambrus (Abbot) on Jun 15, 2011 at 09:24 UTC | |
|
Re: mention a non-installed module in script
by Anonymous Monk on Jun 15, 2011 at 06:49 UTC | |
|
Re: mention a non-installed module in script
by 7stud (Deacon) on Jun 15, 2011 at 06:53 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |