{"id":11816,"date":"2015-08-15T19:13:39","date_gmt":"2015-08-15T19:13:39","guid":{"rendered":"http:\/\/www.oracletutoring.ca\/blog\/?p=11816"},"modified":"2015-08-15T19:13:39","modified_gmt":"2015-08-15T19:13:39","slug":"perl-printing-an-array","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/perl-printing-an-array\/","title":{"rendered":"Perl:  printing an array"},"content":{"rendered":"<h1>The tutor continues about Perl arrays with another trick.<\/h1>\n<p>For background, the reader can look up <a href=\"?p=11805\">yesterday&#8217;s post<\/a>.  The main idea is that an array is a list of values.<\/p>\n<p>Let&#8217;s imagine an array declared as follows:<\/p>\n<p><span style=\"font-family:monospace\">@arr0=(&#8220;milk&#8221;,&#8221;eggs&#8221;,&#8221;bread&#8221;);<\/span><\/p>\n<p>To print <span style=\"font-family:monospace\">@arr0<\/span> one could use the command<\/p>\n<p><span style=\"font-family:monospace\">print @arr0;<\/span><\/p>\n<p>However, the elements would not be spaced apart; the output would be<\/p>\n<p><span style=\"font-family:monospace\">milkeggsbread<\/span><\/p>\n<p>The same command, but with <span style=\"font-family:monospace\">@arr0<\/span> in quotes:<\/p>\n<p><span style=\"font-family:monospace\">print &#8220;@arr0&#8221;;<\/span><\/p>\n<p>will print the items with spaces in between:<\/p>\n<p><span style=\"font-family:monospace\">milk eggs bread<\/span><\/p>\n<p>Source:<\/p>\n<p><a href=\"http:\/\/www.sthomas.net\/roberts-perl-tutorial.htm\">Robert&#8217;s Perl tutorial<\/a><\/p>\n<p>Jack of <a href=\"https:\/\/www.oracletutoring.ca\">Oracle Tutoring by Jack and Diane,<\/a> Campbell River, BC.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The tutor continues about Perl arrays with another trick. For background, the reader can look up yesterday&#8217;s post. The main idea is that an array is a list of values. Let&#8217;s imagine an array declared as follows: @arr0=(&#8220;milk&#8221;,&#8221;eggs&#8221;,&#8221;bread&#8221;); To print &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/perl-printing-an-array\/\"> <span class=\"screen-reader-text\">Perl:  printing an array<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105],"tags":[991,993,994,995],"class_list":["post-11816","post","type-post","status-publish","format-standard","hentry","category-computer-science","tag-perl-array","tag-printing-an-array","tag-printing-elements-of-an-array-as-a-list","tag-printing-elements-of-an-array-separated-by-spaces"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/11816","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/comments?post=11816"}],"version-history":[{"count":9,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/11816\/revisions"}],"predecessor-version":[{"id":11825,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/11816\/revisions\/11825"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=11816"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=11816"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=11816"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}