I'm not sure I fully understand your problem but try this
#!perl
use strict;
# test
for ('file1LAY.html','file1DFT.html','file2DFT.html'){
open OUT,'>',$_;
createButtons(undef,$_);
}
sub createButtons{
my ($outfile,$filename) = @_;
my %file=();
if ($filename =~ m/(.+)(?:LAY|DFT)\.html/){
for my $s ('LAY','DFT'){
$file{$s} = './'.$1.$s.'.html';
$file{$s} = '#' unless (-e $file{$s});
}
}
print qq!
<a href="$file{'LAY'}" class="button_lay">Layout</a>
<a href="$file{'DFT'}" class="button_dft">DfT</a>\n
</div>\n!;
}
poj