<?xml version='1.0'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:atom="http://www.w3.org/2005/Atom" >
<channel>
	<title><![CDATA[BOL: Perl script introduces control structures, arrays and hashes.]]></title>
	<link>https://bioinformaticsonline.com/snippets/view/28282/perl-script-introduces-control-structures-arrays-and-hashes?</link>
	<atom:link href="https://bioinformaticsonline.com/snippets/view/28282/perl-script-introduces-control-structures-arrays-and-hashes?" rel="self" type="application/rss+xml" />
	<description><![CDATA[]]></description>
	
	<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/28282/perl-script-introduces-control-structures-arrays-and-hashes</guid>
	<pubDate>Mon, 04 Jul 2016 08:42:47 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/28282/perl-script-introduces-control-structures-arrays-and-hashes</link>
	<title><![CDATA[Perl script introduces control structures, arrays and hashes.]]></title>
	<description><![CDATA[<code>#!/usr/bin/env perl

use strict;
use warnings;

my @first_array = (&#039;DNA&#039;, &#039;ATGCGTGC&#039;, 5, &#039;RNA&#039;, &#039;AUGC&#039;);
print $first_array[0], &quot;\n\n&quot;;

# Scalar gives actual size of an array

my $size_of_array = scalar(@first_array);
my $another_way_of_getting_size_of_array = @first_array; # implicit way
print &quot;Scalar of array: $size_of_array\n\n&quot;;
print &quot;Perl&#039;s index size of array: $#first_array\n\n&quot;;
print &quot;Another way of getting size: $another_way_of_getting_size_of_array\n\n&quot;;

# Control Loop: for

for (my $i=0; $i&lt;=$#first_array; $i++) {
    print &quot;Perl&#039;s array index: $i\n\n&quot;;
    print &quot;$first_array[$i] \n\n&quot;; 
}

my %sequence = (&#039;DNA&#039; =&gt; &#039;ATCGATGCT&#039;,
                &#039;RNA&#039; =&gt; &#039;AUGC&#039;,
                &#039;Number of seqs&#039; =&gt; 2
                );

print $sequence{&#039;DNA&#039;}, &quot;\n&quot;;
# Control Loop: foreach

foreach my $key (sort (keys %sequence)) {
    print &quot;Key of hash is $key\tValue of hash is $sequence{$key}\n\n&quot;;
}</code>]]></description>
	<dc:creator>Neel</dc:creator>
</item>

</channel>
</rss>