I would use local for tweaking the environment variable:
use strict;
use Tk;
my @Displays = qw"node1:0 node2:0";
my $top = MainWindow->new();
my %top;
foreach (@Displays) {
local $ENV{'DISPLAY'} = $_;
if (eval {$top{$_} = MainWindow->new()}) {
print "MainWindow opened on $_\n";
} else {
print "MainWindow failed to open on $_\n";
$top{$_} = 0;
}
}
MainLoop;
--
Oh Lord, won’t you burn me a Knoppix CD ?
My friends all rate Windows, I must disagree.
Your powers of persuasion will set them all free,
So oh Lord, won’t you burn me a Knoppix CD ?
(Missquoting Janis Joplin)