in reply to Of Perl Ports and Maintainability

A few of the obvious points:
  1. Use modules for anything you would drop into the OS for. File::Spec, File::Copy, etc. (It turns out that File::Copy is sometimes faster than cp, to boot!)
  2. Don't use %ENV. Ever. Not only is it potentially insecure and undependable, it's also implemented differently on different systems.
  3. Don't expect to be able to run against STDIN and STDOUT interactively on Win32. You might have to telnet to yourself to have a terminal window.
If you keep each component really simple, you might be able to get away with very few blocks of
if ($^O eq 'Win32') { } else { }

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Replies are listed 'Best First'.
Re^2: Of Perl Ports and Maintainability
by particle (Vicar) on Jul 29, 2003 at 18:33 UTC
    if ($^O eq 'Win32')

    is incorrect. use

    if( $^O =~ m/Win32/ )

    instead. some windows operating systems report 'MSWin32', while others report 'Win32'. take the safe route. see Re: Re^2: Prune File Find search for a little more detail.

    ~Particle *accelerates*

Re: Re: Of Perl Ports and Maintainability
by nimdokk (Vicar) on Jul 29, 2003 at 20:08 UTC
    I've noticed that about File::Copy on Unix, my benchmarks have it copying a set of files almost twice as fast as cp or an off the shelf tool. And given what I've learned thus far in the port process, I'm going to go back to the Unix side and change those as well to use File::Spec. As for the environement hash (on Unix) I can't get away from it. Doesn't matter on Windows though. I've done my best to try to make %ENV safer. I'll take a look at using having the routine check the OS version and do work based on that. Thanks for the input.


    "Ex libris un peut de tout"
      As for the environement hash (on Unix) I can't get away from it.

      That's not the attitude I would take. The %ENV hash can be replaced very easily with any one of the Config modules on CPAN. And, in fact, should be replaced with those. By doing that, you remove a huge area which is OS-dependent. It also removes a lot of the maintenance headaches for you. I would seriously look into doing that.

      ------
      We are the carpenters and bricklayers of the Information Age.

      Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

      Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.