Note the format of the config file, to make it a bit easier to maintain and understand, I have chosen to put the full path to perl executable against each user (rather than path to bin directory), and the script will strip out the /perl bit before printing the modified path to STDOUT.#!/usr/bin/perl -w use strict; # Validate current user die "Unknown user!" if (!$ENV{LOGIN}); # Load user configuration (from external file or from this script) my %config; while (<DATA>) { chomp; my ($user, $pref) = /(\w+)\s+(.*)\/perl/; $config{$user} = $pref; } # Find out the preferred perl version for this user # If user not seen in the config file, set to default # path to the latest version of perl my $path = $config{$ENV{LOGIN}} || "/usr/local/bin"; # Export the modified path for the user print "export PATH=$path:\${PATH}\n"; __DATA__ roger /usr/bin/perl james /usr/local/bin/perl thomas /usr/bin/perl peter /usr/perl/bin/perl
To the system /etc/profile or user's ~/.bash_profile.eval $(/etc/perl_config.pl)
In reply to Re: Upgraded perl but cant get to the new version
by Roger
in thread Upgraded perl but cant get to the new version
by Clunk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |