I am developing a Web application on my Linux server at home that needs to work in two different environments: Linux based Web server with a commercial hosting provider & Windows XP on an intranet.

My development server and the Windows computer are both running xampp and the real Web server is running a real LAMP configuration.

I would like to write code so that I can copy it from one machine to the other without having to change anything.

As it is, I have to change the #! line for all of the Perl programs and I don't think I'll be able to avoid that. The other stuff, though, is all related to directories and file locations. This includes a use lib line for a module I wrote for this specific project.

For example, I would like something that works like this:

if ( $linux ) { $logdir = "/home/ghodmode/logs"; $sep = "/"; } elsif ( $windows ) { $logdir = "c:\\xampp\\xampp\\webapp\\logs"; $sep = "\\"; } $logfile = "$logdir${sep}error_log.txt";
I know that the use lib line will be tricker, but is it possible if I put it in a BEGIN block? Does anyone have some advice on how to do this stuff? Thank you,
--
-- GhodMode

In reply to Cross-Platform code by GhodMode

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.