Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I normally do my development at home (Windows) and then upload my code and let it run on the server (Linux). It's a bit of a headache, but it works for me. To make this easier, all of my programs start with the following lines:
#!c:\perl\perl.exe #!/usr/local/bin/perl use strict;

When I upload the file to the server, I delete the first line and things seem to work. However, I'm now writing a script that has a data file. It seems that I need to refer to this file by an absolute path and I'm trying to implement this without requiring a lot of editing on the server-side version.

My current solution has me setting the path to the datafile as a global variable. The script checks the path to Perl and sets the value of the variable accordingly. Here's the code:

use strict; use Config; my $datafile = ""; if ( $Config{"perlpath"} =~ m/^c:/i ) { $datafile = 'c:\work\perl\data'; } else { $datafile = '/usr/svsingh/data'; }

That seems to work, but it looks like a kludge to me. Here are my questions:

  1. Other than putting the data file in the same directory as the script, is there a way around this issue? The directory structure for my ISP is quite funky, so I'd rather not use a relative path.
  2. Is there a better way than testing $Config{"perlpath"} to figure out which computer the script is running on and, therefore, where the data file is?

Thanks for your help.


In reply to Switching Between Development and Production Environments by svsingh

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-23 06:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found