Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Dev Hashbang

by scorpio17 (Abbot)
on Feb 19, 2010 at 15:01 UTC ( #824170=note: print w/replies, xml ) Need Help??


in reply to Dev Hashbang

symbolic links to the rescue!

On your development machine, install your custom perl in /usr/local, then make /usr/bin/perl a symbolic link to /usr/local/bin/perl like this:

ln -s /usr/local/bin/perl /usr/bin/perl

Then you can use the same shebang on both development and production servers.

For modules, install everything into a local 'lib' directory, then use the line:

use lib '/path-to-lib/lib';

In all your scripts. Copy the lib directory to the production server, so that the scripts there will have access to the same libraries.

For anything else, try to use config files. For example, say you want "debug mode" to be active on the development server, and not active on the production server.

First create two files: dev-config.ini will contain the line:

DEBUG = 1

prod-config.ini will contain the line:

DEBUG = 0

Now create more symbolic links:

On the development server:

ln -s dev-config.ini config.ini

On the production server:

ln -s prod-config.ini config.ini

So your scripts only need to read "config.ini", but it's one thing on the dev side and another on the prod side. Once you read the config file, you can do things like this in your script:

if ($DEBUG) { # do debug stuff } else { # whatever }

The idea is to make each server look as much the same as possible, so that you can just tar/zip the entire app directory on the development server, ftp it to the production server, and then unzip/tar it and everything work. With a little effort up front, it's definitely possible, and it makes life much easier.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://824170]
help
Chatterbox?
[Your Mother]: I say I do. :P
[Your Mother]: Missiles would be an idiot’s play. Putin is many things but he is not an idiot.
[erix]: I like the idea of the trumps troup of imbeciles growing slightly nervous now their incompetence will be tested
[erix]: you seem forget there is another idiot coming :)
[Your Mother]: The US government does not attract talent, but grafters and liars and it has been that way for the better part of a century. FEW exceptions.
[erix]: you think it only /looks/ worse this time?
[Your Mother]: HR Clinton was literally threatening Russia. She would have been MUCH more likely to start real trouble.
[Your Mother]: I think there is less decorum this time.
[Your Mother]: We’ve had rapists and thieves and unqualified government. They just had decorum.
[erix]: heh, understatement of the week :)

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2017-01-20 01:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (173 votes). Check out past polls.