{"id":273,"date":"2013-12-27T12:38:44","date_gmt":"2013-12-27T17:38:44","guid":{"rendered":"http:\/\/www.popmartian.com\/tipsntricks\/?p=273"},"modified":"2014-01-03T15:56:00","modified_gmt":"2014-01-03T20:56:00","slug":"howto-create-a-random-alpha-numeric-string-in-perl","status":"publish","type":"post","link":"https:\/\/www.popmartian.com\/tipsntricks\/2013\/12\/27\/howto-create-a-random-alpha-numeric-string-in-perl\/","title":{"rendered":"HOWTO: Create a random alpha-numeric string in Perl"},"content":{"rendered":"<p>Creating an alpha-numeric string in Perl is easy, but having a quick function you can call is better!<\/p>\n<p>This is very useful for things like password generators.<\/p>\n<p>To see how to do this in Python, check out this post: <a href=\"http:\/\/www.popmartian.com\/tipsntricks\/2013\/12\/27\/howto-create-a-random-alpha-numeric-string-in-python\/\" title=\"HOWTO: Create a random alpha-numeric string in Python\">&#8230;howto-create-a-random-alpha-numeric-string-in-python<\/a><\/p>\n<p>To see how to do this in PHP, check out this post: <a href=\"http:\/\/www.popmartian.com\/tipsntricks\/2014\/01\/02\/howto-create-a-random-alpha-numeric-string-in-php\/\" title=\"HOWTO: Create a random alpha-numeric string in PHP\">&#8230;howto-create-a-random-alpha-numeric-string-in-php<\/a><\/p>\n<p><code><br \/>\nsub makeID {<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;my $makeIDchars = ( $#_ >= 0 ? shift @_ : 6);<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;my @makeIDpool = ('a'..'z','A'..'Z',0..9);<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;return join '', map $makeIDpool[int(rand($#makeIDpool - 1))], 1..$makeIDchars;<br \/>\n}<br \/>\n<\/code><\/p>\n<p>Example:<\/p>\n<p>This code sample:<br \/>\n<code><br \/>\nprint makeID().\"\\n\";<br \/>\nprint makeID(10).\"\\n\";<br \/>\nprint makeID(20).\"\\n\";<br \/>\nprint makeID(1).\"\\n\";<br \/>\n<\/code><\/p>\n<p>Will print something like this:<br \/>\n<code><br \/>\nQLNbMX<br \/>\n1wO6uBRbER<br \/>\nbjbYBJSMLONKOPU0SiQS<br \/>\np<br \/>\n<\/code><\/p>\n<blockquote><p>Did you find this post useful or have questions or comments?  Please let  me know!<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Creating an alpha-numeric string in Perl is easy, but having a quick function you can call is better! This is very useful for things like password generators. To see how to do this in Python, check out this post: &#8230;howto-create-a-random-alpha-numeric-string-in-python &hellip; <a href=\"https:\/\/www.popmartian.com\/tipsntricks\/2013\/12\/27\/howto-create-a-random-alpha-numeric-string-in-perl\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,12,9],"tags":[],"class_list":["post-273","post","type-post","status-publish","format-standard","hentry","category-how-to-do-stuff","category-perl","category-programming"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/posts\/273","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/comments?post=273"}],"version-history":[{"count":7,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/posts\/273\/revisions"}],"predecessor-version":[{"id":280,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/posts\/273\/revisions\/280"}],"wp:attachment":[{"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/media?parent=273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/categories?post=273"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/tags?post=273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}