<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic quick perl question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135635#M748089</link>
    <description>Hi&lt;BR /&gt;&lt;BR /&gt;Easy points here&lt;BR /&gt;&lt;BR /&gt;I'm only on chapter2 but strugglng with this little question&lt;BR /&gt;&lt;BR /&gt;I have a scalar variable $total which is 456.5899&lt;BR /&gt;&lt;BR /&gt;I want to use the int operator to give me the integer portion of $total. ie, passing the variable to int then printing the new total.&lt;BR /&gt;&lt;BR /&gt;I have tried a number of permitations but just can't get it right&lt;BR /&gt;&lt;BR /&gt;Can anyone help ?&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;Steve</description>
    <pubDate>Wed, 03 Dec 2003 21:28:35 GMT</pubDate>
    <dc:creator>steven Burgess_2</dc:creator>
    <dc:date>2003-12-03T21:28:35Z</dc:date>
    <item>
      <title>quick perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135635#M748089</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Easy points here&lt;BR /&gt;&lt;BR /&gt;I'm only on chapter2 but strugglng with this little question&lt;BR /&gt;&lt;BR /&gt;I have a scalar variable $total which is 456.5899&lt;BR /&gt;&lt;BR /&gt;I want to use the int operator to give me the integer portion of $total. ie, passing the variable to int then printing the new total.&lt;BR /&gt;&lt;BR /&gt;I have tried a number of permitations but just can't get it right&lt;BR /&gt;&lt;BR /&gt;Can anyone help ?&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Wed, 03 Dec 2003 21:28:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135635#M748089</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2003-12-03T21:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: quick perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135636#M748090</link>
      <description>whoops&lt;BR /&gt;&lt;BR /&gt;I have posted this in the wrong section!&lt;BR /&gt;</description>
      <pubDate>Wed, 03 Dec 2003 21:29:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135636#M748090</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2003-12-03T21:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: quick perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135637#M748091</link>
      <description>my $total = 456.5899;&lt;BR /&gt;print int($total),"\n";&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;printf ("%d\n",int($total));&lt;BR /&gt;</description>
      <pubDate>Wed, 03 Dec 2003 22:12:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135637#M748091</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-12-03T22:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: quick perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135638#M748092</link>
      <description>Hi A.Clay&lt;BR /&gt;&lt;BR /&gt;The problem I'm having is that i'm doing&lt;BR /&gt;&lt;BR /&gt;print "The sum is int($total),"\n";&lt;BR /&gt;&lt;BR /&gt;Which doesn't actually display the integer but the whole total&lt;BR /&gt;&lt;BR /&gt;see where i'm coming from ?&lt;BR /&gt;&lt;BR /&gt;thanks&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Wed, 03 Dec 2003 22:19:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135638#M748092</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2003-12-03T22:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: quick perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135639#M748093</link>
      <description>Okay, perl seems a little wierd until you understand how it handles variables:&lt;BR /&gt;&lt;BR /&gt;print "The sum is : ",int($total),"\n";&lt;BR /&gt;&lt;BR /&gt;By the way, you should note that Perl always uses floating point math unless you specifically tell it not to via the&lt;BR /&gt;use integer; &lt;BR /&gt;staement. &lt;BR /&gt;&lt;BR /&gt;You can put that inside a function and use integer; will only apply to the enclosing function.&lt;BR /&gt;</description>
      <pubDate>Wed, 03 Dec 2003 22:29:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135639#M748093</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-12-03T22:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: quick perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135640#M748094</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;I got to this in the end, which was a suggestion&lt;BR /&gt;&lt;BR /&gt;my $total=int($total);&lt;BR /&gt;chomp $total;&lt;BR /&gt;&lt;BR /&gt;print "After $mons months, at $interest monthly you\n";&lt;BR /&gt;print "will have $total\n";&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;That though is what i considered to be the long way round, i'll give yours a go and respond&lt;BR /&gt;&lt;BR /&gt;thanks again&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Wed, 03 Dec 2003 22:31:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135640#M748094</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2003-12-03T22:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: quick perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135641#M748095</link>
      <description>Thats cool&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Wed, 03 Dec 2003 22:37:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135641#M748095</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2003-12-03T22:37:54Z</dc:date>
    </item>
    <item>
      <title>Re: quick perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135642#M748096</link>
      <description>You almost got it :)&lt;BR /&gt;&lt;BR /&gt;&amp;gt; my $total=int($total);&lt;BR /&gt;&lt;BR /&gt;correct. parens are optional&lt;BR /&gt;&lt;BR /&gt;&amp;gt; chomp $total;&lt;BR /&gt;&lt;BR /&gt;humbug. the chomp operator cuts off the optional line ending (\n on unix) from a string. Now that you've just asigned an integer (numeric) to $total, you can rest asured that it has absolutely no line ending.&lt;BR /&gt;int is a numerec operator, chomp is a string operator&lt;BR /&gt;&lt;BR /&gt;&amp;gt; print "After $mons months, at $interest monthly you\n";&lt;BR /&gt;&amp;gt; print "will have $total\n";&lt;BR /&gt;&lt;BR /&gt;Good. When using double quotes, all *variables* used inside the string are interpolated.&lt;BR /&gt;&lt;BR /&gt;Now for the curious amongst you: it *is* posible to use interpolated functions inside double quoted strings :)&lt;BR /&gt;&lt;BR /&gt;print "will have @{[int$total]}\n";&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Thu, 04 Dec 2003 02:50:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135642#M748096</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2003-12-04T02:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: quick perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135643#M748097</link>
      <description>Just an attempt to explain the reference magic showed to you by procura.&lt;BR /&gt;This is probably the way the Perlians do it but very scaring to Perl newbies.&lt;BR /&gt;Especially they should read the POD because it's all explained therein.&lt;BR /&gt;Here's an excerpt from "perldoc perlref"&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;      Here's a trick for interpolating a subroutine call into a string:&lt;BR /&gt; &lt;BR /&gt;          print "My sub returned @{[mysub(1,2,3)]} that time.\n";&lt;BR /&gt; &lt;BR /&gt;      The way it works is that when the "@{...}" is seen in the double-&lt;BR /&gt;      quoted string, it's evaluated as a block.  The block creates a&lt;BR /&gt;      reference to an anonymous array containing the results of the call to&lt;BR /&gt;      "mysub(1,2,3)".  So the whole block returns a reference to an array,&lt;BR /&gt;      which is then dereferenced by "@{...}" and stuck into the double-&lt;BR /&gt;      quoted string. This chicanery is also useful for arbitrary&lt;BR /&gt;      expressions:&lt;BR /&gt; &lt;BR /&gt;          print "That yields @{[$n + 5]} widgets\n";&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;Just a word of caution.&lt;BR /&gt;Yes, procura is right you can ommit the parentheses of function if they were predeclared (either built-in, or by the "subs" pragma).&lt;BR /&gt;And this you will see in code of frequent Perl hackers.&lt;BR /&gt;But this can be very tricky, and you can easily fall victim to precedence.&lt;BR /&gt;E.g. if you don't distinguish between the "or" and "||" operator this may lead to strange results when you omitted parentheses.&lt;BR /&gt;Precedence itself can get very tricky especially when using convoluted compound statements.&lt;BR /&gt;See "perldoc perlop"&lt;BR /&gt;Moral, when in doubt, be boring and explicit.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 04 Dec 2003 09:58:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135643#M748097</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2003-12-04T09:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: quick perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135644#M748098</link>
      <description>Thanks for that Ralph!&lt;BR /&gt; &lt;BR /&gt;I have to admit, when I see stuff like that my extremly safe and boring side comes to the fore as I think "If I see what I have just written, will I understand it next week".&lt;BR /&gt; &lt;BR /&gt;I have a rather large script that I wrote years ago and I still haven't worked out how one of the lines I wrote works.  I just leave it here becuase I know it does :)</description>
      <pubDate>Thu, 04 Dec 2003 10:11:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135644#M748098</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2003-12-04T10:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: quick perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135645#M748099</link>
      <description>Thanks for the responses everyone&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Thu, 04 Dec 2003 13:58:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-perl-question/m-p/3135645#M748099</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2003-12-04T13:58:12Z</dc:date>
    </item>
  </channel>
</rss>

