{"id":13250,"date":"2015-11-29T16:58:58","date_gmt":"2015-11-29T16:58:58","guid":{"rendered":"http:\/\/www.oracletutoring.ca\/blog\/?p=13250"},"modified":"2015-11-29T16:58:58","modified_gmt":"2015-11-29T16:58:58","slug":"perl-some-explanation-of-yesterdays-command-line-cube-root-program","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/perl-some-explanation-of-yesterdays-command-line-cube-root-program\/","title":{"rendered":"Perl:  some explanation of yesterday&#8217;s command-line cube root program"},"content":{"rendered":"<h1>The tutor offers a few points of clarification.<\/h1>\n<p>In <a href=\"?p=13226\">yesterday&#8217;s post<\/a> I showed a Perl program, called from the command line with the input value, to find the cube root of a number.  Here are some points to help a casual reader understand it:<\/p>\n<p><span style=\"font-family:monospace\">$ARGV[0]<\/span> refers to the first command-line argument.  Let&#8217;s imagine the program is stored as <span style=\"font-family:monospace\">cuberoot.txt<\/span>.  If the user wants the cube root of  -64, the program will be called from the command line as follows:<\/p>\n<p><span style=\"font-family:monospace\">perl cuberoot.txt -64<\/span><\/p>\n<p>The <span style=\"font-family:monospace\">if<\/span> statement checks for negativity; my version of Perl isn&#8217;t happy to exponentiate a negative number by 1\/3.  I just make <span style=\"font-family:monospace\">$input<\/span> positive, take that cube root, then multiply the answer by negative 1.  Later I change <span style=\"font-family:monospace\">$input<\/span> back to negative so it&#8217;s correct in the answer statement printed to the screen.<\/p>\n<p><span style=\"font-family:monospace\">printout<\/span> is a subroutine listed at the bottom of the program.  It&#8217;s called by <span style=\"font-family:monospace\">&#038;printout<\/span>.  To my knowledge, a subroutine is called using an ampersand in front of its name.<\/p>\n<p>HTH:)<\/p>\n<p>Source:<\/p>\n<p>McGrath, Mike.  <u>Perl in easy steps<\/u>.  Southam:  Computer Step, 2004.<\/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 offers a few points of clarification. In yesterday&#8217;s post I showed a Perl program, called from the command line with the input value, to find the cube root of a number. Here are some points to help a &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/perl-some-explanation-of-yesterdays-command-line-cube-root-program\/\"> <span class=\"screen-reader-text\">Perl:  some explanation of yesterday&#8217;s command-line cube root program<\/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":[524,1216,173,1217],"class_list":["post-13250","post","type-post","status-publish","format-standard","hentry","category-computer-science","tag-perl-command-line-arguments","tag-perl-cube-root-program","tag-perl-programming","tag-subroutine"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/13250","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=13250"}],"version-history":[{"count":9,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/13250\/revisions"}],"predecessor-version":[{"id":13259,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/13250\/revisions\/13259"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=13250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=13250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=13250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}