Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: Can Perl do anything Java can do?

by haukex (Archbishop)
on Jul 19, 2017 at 12:39 UTC ( [id://1195450]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Can Perl do anything Java can do?
in thread Can Perl do anything Java can do?

Won't the Perl code run in Unix (our code will be running in Linux machines) and Windows both??

Perl and many modules will run just fine in both environments, and there is lots of Perl code that is entirely portable to many platforms. But in some cases, care has to be taken to ensure portability. For example, you'll often see code that is hard-coded to use the forward slash as a directory separator, which works in many cases on Windows, but not all. If instead one uses the core module File::Spec or one of the more user-friendly modules from CPAN like Path::Class, they'll do filename handling in a more native way, and you should have much less portability issues. When picking modules, you can look at their documentation as well as the CPAN Testers Matrix for compatibility (e.g. this is the one for IPC-Run3).

  • Comment on Re^3: Can Perl do anything Java can do?

Replies are listed 'Best First'.
Re^4: Can Perl do anything Java can do?
by kennethk (Abbot) on Jul 19, 2017 at 14:05 UTC
    You should be aware that if you specify a path with forward slashes to a Windows instance of perl, the interpreter will usually auto-convert the forward slashes to backslashes for file access. This is a particularly helpful feature when wrapping a Windows path in interpolating delimiters, e.g. double quotes. Obviously, File::Spec et al. represent the most transferable approach.

    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

      Actually, it's Windows itself that copes with forward slashes as well as backslashes, not Perl.

      It is mostly the shell and UNC filenames that really need backslashes.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1195450]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (2)
As of 2024-04-26 03:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found