#!/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 () { 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