#!/usr/bin/perl my $file=$0; # what machine are we looking at? $file=~s#^(?:.*/)?([^/]+)$#$1#; my $dest; # a config hash for expanding the name, and choosing the user. my $places={ box=>{full=>"boxwithlongname"}, home=>{full=>"blahblah",user=>"alexk"} }; # if i have many machines with the same long name - abbreviate to box # (as in hash above), so box1 goes to boxwithlongname1 etc my ($short,$number)=$file=~/^(\D+)(\d?)$/; my $hash=$places->{$short}; $dest=$hash->{full}?$hash->{full}.$number:$file; $user=$hash->{user}||"alex"; # and ssh to it. exec("ssh $user\@$dest @ARGV") if $dest;