#!/usr/local/bin/perl -w use strict; sub starts_with { return substr($_[0], 0, length($_[1])) eq $_[1]; } my $proto=$ENV{'PROTO'}; my $newproto=$ENV{'NEWPROTO'}; my @new=(); while (my ($key, $value)=each(%ENV)) { if (starts_with($key, $proto.'LOCAL') or starts_with($key, $proto.'REMOTE')) { push(@new, [$newproto.substr($key, length($proto)), $value]); } } foreach my $entry (@new) { $ENV{$entry->[0]}=$entry->[1]; } exec({ $ARGV[0] } @ARGV);