Changes
PERL
,Created page with "<p><span style="font-size:20px">Basic of Perl</span></p> <hr /> <p><span style="font-size:14px">1) <strong>Variable</strong></span></p> <p>Variable is a place to store a value,..."
<p><span style="font-size:20px">Basic of Perl</span></p>
<hr />
<p><span style="font-size:14px">1) <strong>Variable</strong></span></p>
<p>Variable is a place to store a value, so we can refer to it or manipulate it throughout program. Perl has three types of variables; scalars, arrays and hases.</p>
<p><strong>Scalar ($) </strong></p>
<p>Scalar variable stores a single (scalar) value. Perl scalar names are prefixed with a dollar sign ($), so for example, <code>$x, $y, $z, $username,</code> and <code>$url</code> are all examples of scalar variable names. A scalar can hold data of any type, be it a string, a number, or whatnot.</p>
<p>ex) </p>
<pre>
$name = "Byeongeun Lee";
</pre>
<p><strong>Array (@)</strong></p>
<p>An array stores a list of values. While a scalar variable can only store one value, an array can store many. Perl array names are prefixed with an at-sign (@). In Perl, array indices start with 0, so to refer to the first element of the array @colors, you use $colors[0]. Note that when you're referring to a single element of an array, you prefix the name with a $ instead of the @. The $-sign again indicates that it's a single (scalar) value; the @-sign means you're talking about the entire array.</p>
<p>ex)</p>
<pre>
@Grades = ("A","B","C");</pre>
<p> </p>
<p><strong>Hash (%)</strong></p>
<p>A hash is a special kind of array - an associative array, or paired group of elements. Perl hash names are prefixed with a percent sign (%), and consist of pairs of elements - a key and a data value.</p>
<p>ex)</p>
<pre>
my %courses = (
"Cell bio" => "prof.P",
"Micro" => "prof.M",
);</pre>
<p> </p>
<p><span style="font-size:20px">Assignment study</span></p>
<hr />
<p> </p>
<hr />
<p><span style="font-size:14px">1) <strong>Variable</strong></span></p>
<p>Variable is a place to store a value, so we can refer to it or manipulate it throughout program. Perl has three types of variables; scalars, arrays and hases.</p>
<p><strong>Scalar ($) </strong></p>
<p>Scalar variable stores a single (scalar) value. Perl scalar names are prefixed with a dollar sign ($), so for example, <code>$x, $y, $z, $username,</code> and <code>$url</code> are all examples of scalar variable names. A scalar can hold data of any type, be it a string, a number, or whatnot.</p>
<p>ex) </p>
<pre>
$name = "Byeongeun Lee";
</pre>
<p><strong>Array (@)</strong></p>
<p>An array stores a list of values. While a scalar variable can only store one value, an array can store many. Perl array names are prefixed with an at-sign (@). In Perl, array indices start with 0, so to refer to the first element of the array @colors, you use $colors[0]. Note that when you're referring to a single element of an array, you prefix the name with a $ instead of the @. The $-sign again indicates that it's a single (scalar) value; the @-sign means you're talking about the entire array.</p>
<p>ex)</p>
<pre>
@Grades = ("A","B","C");</pre>
<p> </p>
<p><strong>Hash (%)</strong></p>
<p>A hash is a special kind of array - an associative array, or paired group of elements. Perl hash names are prefixed with a percent sign (%), and consist of pairs of elements - a key and a data value.</p>
<p>ex)</p>
<pre>
my %courses = (
"Cell bio" => "prof.P",
"Micro" => "prof.M",
);</pre>
<p> </p>
<p><span style="font-size:20px">Assignment study</span></p>
<hr />
<p> </p>