<?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: Generating a random string with Perl]]></title>
	<link>https://bioinformaticsonline.com/snippets/view/27422/generating-a-random-string-with-perl?</link>
	<atom:link href="https://bioinformaticsonline.com/snippets/view/27422/generating-a-random-string-with-perl?" rel="self" type="application/rss+xml" />
	<description><![CDATA[]]></description>
	
	<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/27422/generating-a-random-string-with-perl</guid>
	<pubDate>Fri, 20 May 2016 05:13:20 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/27422/generating-a-random-string-with-perl</link>
	<title><![CDATA[Generating a random string with Perl]]></title>
	<description><![CDATA[<code>#!/usr/bin/perl

# This function generates random strings of a given length
sub generate_random_string
{
	my $length_of_randomstring=shift;# the length of 
			 # the random string to generate

	my @chars=(&#039;a&#039;..&#039;z&#039;,&#039;A&#039;..&#039;Z&#039;,&#039;0&#039;..&#039;9&#039;,&#039;_&#039;);
	my $random_string;
	foreach (1..$length_of_randomstring) 
	{
		# rand @chars will generate a random 
		# number between 0 and scalar @chars
		$random_string.=$chars[rand @chars];
	}
	return $random_string;
}

#Generate the random string
my $random_string=&amp;generate_random_string(11);

print &quot;Random string: &quot;.$random_string.&quot;\n&quot;;
print &quot;Length: &quot;.length($random_string).&quot;\n&quot;;</code>]]></description>
	<dc:creator>Abhi</dc:creator>
</item>
<item>
	<guid isPermaLink='true'>https://bioinformaticsonline.com/snippets/view/27422/generating-a-random-string-with-perl#item-annotation-2418</guid>
	<pubDate>Fri, 20 May 2016 05:17:01 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/27422/generating-a-random-string-with-perl#item-annotation-2418</link>
	<title><![CDATA[Comment by Jit]]></title>
	<description><![CDATA[<p>Hmmm interesting, but I prefer Perl module String::Random;</p>
<p>use String::Random;<br>my $pass = String::Random-&gt;new;<br>print "Your password is ", $pass-&gt;randpattern("CCcc!ccn"), "\n";</p>
<p>This would output something like this:<br><br>Your password is UDwp$tj5</p>]]></description>
	<dc:creator>Jit</dc:creator>
</item>

</channel>
</rss>