Just to add a couple of points to the already excellent answers by Discipulus and kcott: In general, much of core Perl is already written to be fairly platform-independent, with differing implementations inside the interpreter itself (for example, see the win32 directory in the Perl source). For anything else in a cross-platform application, I would very strongly recommend to hide any platform-specific stuff behind an abstraction layer. For example, for filesystem stuff, there's File::Spec (mentioned by kcott), or with an IMO nicer API, Path::Class. You'll also find a lot of modules on CPAN with "Any" in their name, for example, ShellQuote::Any, which automatically uses either Win32::ShellQuote or String::ShellQuote under the hood. Sometimes, you may have to load the modules yourself, for example, I'm not aware of an ::Any module that loads either Win32::SerialPort or Device::SerialPort, although they both provide a very similar API.

So you see there are already quite a few abstraction layers available, and if you're planning on writing your own platform-dependent code with an abstraction layer, it would probably be best if you say what functionality it is you want to abstract, perhaps we can give some more specific suggestions on how to do that.


In reply to Re: Easing cross-platform scripting by haukex
in thread Easing cross-platform scripting by White Raven

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.