in reply to Easing cross-platform scripting
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Easing cross-platform scripting
by kschwab (Vicar) on Nov 27, 2018 at 21:12 UTC | |
by hippo (Archbishop) on Nov 27, 2018 at 22:38 UTC | |
by haukex (Archbishop) on Nov 28, 2018 at 15:30 UTC | |
|
Re^2: Easing cross-platform scripting
by White Raven (Initiate) on Nov 27, 2018 at 13:51 UTC | |
|
Re^2: Easing cross-platform scripting
by Anonymous Monk on Nov 27, 2018 at 21:25 UTC |