ファイル名: ./j/hash1.cgi

#!/usr/local/bin/perl

# -----------------------------------------------------------------------------
# スカラー変数・配列・ハッシュ  (ファイル名: hash1.cgi )
# -----------------------------------------------------------------------------

$Title = 'ハッシュ';

# ------------------- @members にメンバーを代入 ------------------------

$bandname = "BEATLES";

$name1 = "John";
$name2 = "Paul";
$name3 = "George";
$name4 = "Ringo";

@members = ("John","Paul","George","Ringo");
%gakki = ("guitar1","John","bass","Paul","guitar2","George","drum","Ringo");
# ----------------------HTML------------------------------

print"Content-type: text/html\n\n";

print <<__HTML__;

<HTML>
<HEAD>
<TITLE>$Title</TITLE>
</HEAD>
<BODY bgcolor="#000000" text="#ffff99">

------------------------------------------------------------------------------- <BR>
●[代入]<BR><BR>


<B>スカラー変数</B><BR><BR>
\$name1 = "John";
\$name2 = "Paul";
\$name3 = "George";
\$name4 = "Ringo";
<BR><BR>
<B>配列変数</B><BR><BR>
\@members = ("John","Paul","George","Ringo");
<BR><BR>
<B>連想配列(ハッシュ)</B><BR><BR>
\%gakki = ("guitar1","John","bass","Paul","guitar2","George","drum","Ringo");
<BR><BR>
------------------------------------------------------------------------------ <BR>
<BR><BR>
●[出力]<BR><BR>

<P><B>スカラー変数</B></P>
\$name1
<TABLE border="1">
<TBODY>
<TR>
<TD width="40" height="20" bgcolor="#000099">$name1</TD>
</TR>
</TBODY>
</TABLE>
<BR><BR>
\$name2
<TABLE border="1">
<TBODY>
<TR>
<TD width="40" height="20" bgcolor="#000099">$name2</TD>
</TR>
</TBODY>
</TABLE>
<BR><BR>
\$name3
<TABLE border="1">
<TBODY>
<TR>
<TD width="40" height="20" bgcolor="#000099">$name3</TD>
</TR>
</TBODY>
</TABLE>
<BR><BR>
\$name4
<TABLE border="1">
<TBODY>
<TR>
<TD width="40" height="20" bgcolor="#000099">$name4</TD>
</TR>
</TBODY>
</TABLE>
<P><BR>
</P>
<P><B>配列変数</B><BR></P>
<TABLE border="1">
<TBODY>
<TR>
<TD bgcolor="#009999">\$members[0]</TD>
<TD bgcolor="#009999">\$members[1]</TD>
<TD bgcolor="#009999">\$members[2]</TD>
<TD bgcolor="#009999">\$members[3]</TD>
</TR>
<TR>
<TD bgcolor="#000099">$members[0]</TD>
<TD bgcolor="#000099">$members[1]</TD>
<TD bgcolor="#000099">$members[2]</TD>
<TD bgcolor="#000099">$members[3]</TD>
</TR>
</TBODY>
</TABLE>
<P><BR><BR>
<P><B>連想配列(ハッシュ)</B><BR></P>
<TABLE border="1">
<TBODY>
<TR>
<TD bgcolor="#009999">\$gakki{"guitar1"}</TD>
<TD bgcolor="#009999">\$gakki{"bass"}</TD>
<TD bgcolor="#009999">\$gakki{"guitar2"}</TD>
<TD bgcolor="#009999">\$gakki{"drum"}</TD>
</TR>
<TR>
<TD bgcolor="#000099">$gakki{"guitar1"}</TD>
<TD bgcolor="#000099">$gakki{"bass"}</TD>
<TD bgcolor="#000099">$gakki{"guitar2"}</TD>
<TD bgcolor="#000099">$gakki{"drum"}
</TD>
</TR>
</TBODY>
</TABLE>
<P><BR><BR>
</P>


</BODY>
</HTML>

__HTML__

exit;