# Offsets into the path my %indexes = (home => 1, Users => 2, Home => 1, export => 2); # This would be one of the scalars you have access to (I'm using the # CGI-BIN one in this code.) my $path = '/home/username/public_html/cgi-bin/dir'; # Remove the leading / and then split up my @pieces = split('/', substr($path, 1)); # Extract the user name information my $username = $pieces[$indexes{$pieces[0]}]; print "$username\n";