in reply to building and running a unix script with Perl

It is quite easy to write files from Perl, see open and print. Be sure to chmod (assuming UNIX). When calling the script using system or qx it is probably best to pass the full path name.

On the other hand, would it not be better to write it in Perl? Off hand I can't think of anything shell scripts can do (even the very latest versions) that Perl cannot.
  • Comment on Re: building and running a unix script with Perl

Replies are listed 'Best First'.
Re^2: building and running a unix script with Perl
by JavaFan (Canon) on Jan 25, 2010 at 15:21 UTC
    There's nothing shell scripts can do that cannot be done in Perl1. But there are things that are easier done in a shell script than in Perl. Sourcing other shell scripts for instance (and hence, getting access to environment variables). You can't really beat
    . /path/to/config/file
    in Perl for ease, neither keystrokes.

    1Of course, there's nothing a Perl program can do that cannot be done in Python, Java or C. That doesn't imply some people rather write Perl...