{"id":13226,"date":"2015-11-29T00:26:30","date_gmt":"2015-11-29T00:26:30","guid":{"rendered":"http:\/\/www.oracletutoring.ca\/blog\/?p=13226"},"modified":"2018-02-28T19:28:49","modified_gmt":"2018-02-28T19:28:49","slug":"perl-a-command-line-cube-root-program","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/perl-a-command-line-cube-root-program\/","title":{"rendered":"Perl:  a command-line cube root program"},"content":{"rendered":"<h1>The tutor shows an example program with a few facets to discuss.<\/h1>\n<p>So far as I know, to find the cube root in Perl, you need use the principle<\/p>\n<p><img decoding=\"async\" src=\"\/..\/images\/rat_exp.png\" style=\"display:block;margin:auto\" \/><\/p>\n<p>The following program calculates the cube root of a number given with the command-line function call:<\/p>\n<p><span style=\"font-family:monospace;color:brown\"><br \/>\n$input=$ARGV[0];<br \/>\n<br \/>\nif($input<0){\n<br \/>\n$input*=-1;<span style=\"color:orange\">\u00a0#changes value to positive<\/span><br \/>\n$out=-1*$input**(1\/3);<br \/>\n$input*=-1;<span style=\"color:orange\">\u00a0#restores original value<\/span><br \/>\n}<br \/>\n<br \/>\nelse{<br \/>\n$out=$input**(1\/3);<br \/>\n}<br \/>\n&printout;<br \/>\n<br \/>\nsub printout{<br \/>\nprint &#8220;The cube root of $input is $out\\n\\n&#8221;;<br \/>\n}<br \/>\n<\/span><\/p>\n<p>I&#8217;ll be explaining some ins and outs of this program next post:)<\/p>\n<p>Source:<\/p>\n<p>McGrath, Mike.  <u>Perl in easy steps.<\/u>  Southam:  Computer Step, 2004.<\/p>\n<p><a href=\"http:\/\/www.perlmonks.org\/?node_id=297695\">perlmonks.org<\/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 shows an example program with a few facets to discuss. So far as I know, to find the cube root in Perl, you need use the principle The following program calculates the cube root of a number given &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/perl-a-command-line-cube-root-program\/\"> <span class=\"screen-reader-text\">Perl:  a 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":[1214,524,1215,173,139],"class_list":["post-13226","post","type-post","status-publish","format-standard","hentry","category-computer-science","tag-cube-root","tag-perl-command-line-arguments","tag-perl-power-function","tag-perl-programming","tag-rational-exponents"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/13226","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=13226"}],"version-history":[{"count":26,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/13226\/revisions"}],"predecessor-version":[{"id":30659,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/13226\/revisions\/30659"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=13226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=13226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=13226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}