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!


In reply to mention a non-installed module in script by pashanoid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.