こんにちは
今、CGIをPERLで作ってますが
プログラム中に同じ構文がたくさん出てくるので簡単にできませんか?
print "<caption>★ああああ</caption>";
print "<table border=1 cellspacing=1 >\n";
print "<tr>\n";
my $linemax=$yoko-1;
my $count=0;
for(@DATA){
chomp;
($no,$name,$banar,$se,$jan)=split /<>/;
if($count > $linemax){print"</tr>";$count=0;}
if ($jan eq '0'){
print "<td width='140'><a href=http://$name target='_blank'><center><img src=http://$banar height='100' width='60' Border='0' ALT=$se ></a></td></center>\n";
$count++;
}
}
print "</table>\n";
print "<caption>★いいいいいい</caption>";
print "<table border=1 cellspacing=1 >\n";
print "<tr>\n";
my $linemax=$yoko-1;
my $count=0;
for(@DATA){
chomp;
($no,$name,$banar,$se,$jan)=split /<>/;
if($count > $linemax){print"</tr>";$count=0;}
if ($jan eq '1'){
print "<td width='140'><a href=http://$name target='_blank'><center><img src=http://$banar height='100' width='60' Border='0' ALT=$se ></a></td></center>\n";
$count++;
}
}
上の式で
my $linemax=$yoko-1;
my $count=0;
for(@DATA){
chomp;
($no,$name,$banar,$se,$jan)=split /<>/;
if($count > $linemax){print"</tr>";$count=0;}
と
"<td width='140'><a href=http://$name target='_blank'><center><img src=http://$banar height='100' width='60' Border='0' ALT=$se ></a></td></center>\n";
$count++;
が同じなのですが何か変数みたいに使いまわしできませんか?