I was wondering how to make a python script portable to both linux and windows?
One problem I see is shebang. How to write the shebang so that the script can be run on
I don't know enough to comment on Python approaches to this problem, so I won't.
Most things in Perl will just work. There are a few gotchas that are easy to avoid.
Here are a few things I have come across in the years I've been working with Win32 Perl:
open
. The two argument form can have problems with spaces in paths. (You should already be doing this anyway.)use Warnings;
will appear to work, but in reality it will fail.select
only works on actual sockets under Windows. You can't use it on any other sort of handle.File::Spec
to manage paths to files.CRLF
will automatically be converted to LF
line endings as the handle is read. LF
is changed to CRLF
on write. If you want to avoid this, use binmode
on the handle to prevent the translation.See perlport for more information on individual functions.