Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Using maths in print statement..

Expand Messages
  • Gordon Stewart
    Is this a school assignment ? $count = 5; $temp=($count-1); print The desired value is ($temp) n ; G ...
    Message 1 of 5 , Oct 28, 2003
    • 0 Attachment
      Is this a school assignment ?

      $count = 5;
      $temp=($count-1);
      print "The desired value is ($temp) \n";

      G

      >Hi,
      > Suppose $count=5;
      > I would like to print a value that is 1 less that $count.. but the
      >$count value must not change.
      > I tried this..
      > print "The desired value is ($count -1) \n";
      > But the result I obtained was:
      > The desired value is (5-1);
      > But I was expecting 4!!!
      > How can this be achieved?
      >
      > Please help.
      >
      >Thanks,
      >Sreeram

      _________________________________________________________________
      Gaming galore at http://xtramsn.co.nz/gaming !
    • Sreeram B S
      Hi, Thanks for the answer.. but this method was known !!! This method uses an extra variable.. $temp in the example quoted.. I just wanted a means of avoiding
      Message 2 of 5 , Oct 28, 2003
      • 0 Attachment
        Hi,

        Thanks for the answer.. but this method was known !!!
        This method uses an extra variable.. $temp in the example quoted.. I just wanted a means of avoiding this extra variable.

        Thanks,
        Sreeram


        Gordon Stewart <gordy@...> wrote:

        Is this a school assignment ?

        $count = 5;
        $temp=($count-1);
        print "The desired value is ($temp) \n";

        G

        >Hi,
        > Suppose $count=5;
        > I would like to print a value that is 1 less that $count.. but the
        >$count value must not change.
        > I tried this..
        > print "The desired value is ($count -1) \n";
        > But the result I obtained was:
        > The desired value is (5-1);
        > But I was expecting 4!!!
        > How can this be achieved?
        >
        > Please help.
        >
        >Thanks,
        >Sreeram

        _________________________________________________________________
        Gaming galore at http://xtramsn.co.nz/gaming !


        Yahoo! Groups SponsorADVERTISEMENT

        Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html

        Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


        ---------------------------------
        Do you Yahoo!?
        Exclusive Video Premiere - Britney Spears

        [Non-text portions of this message have been removed]
      • Charles K. Clarkson
        ... Almost all answers you ll find here are known methods. ... How about using printf . Just replace your variable with %s and move it to the end. Later, you
        Message 3 of 5 , Oct 28, 2003
        • 0 Attachment
          Sreeram B S <sreeramabsc@...> wrote:
          :
          : Thanks for the answer.. but this method was known !!!

          Almost all answers you'll find here are known
          methods.


          : This method uses an extra variable.. $temp in the
          : example quoted.. I just wanted a means of avoiding
          : this extra variable.

          How about using 'printf'. Just replace your variable
          with %s and move it to the end. Later, you can dig into
          the documentation to find out how to use formats beyond
          %s. BTW, there is no need to put a space at the end of
          a line.


          my $count = 5;
          printf "The desired value is (%s)\n", $count - 1;


          HTH,

          Charles K. Clarkson
          --
          Head Bottle Washer,
          Clarkson Energy Homes, Inc.
          Mobile Home Specialists
          254 968-8328
        • cgiperl
          How about using eval() printf The desired value is .eval($count - 1); Aman Raheja AGF Technologies http://www.agftech.com ... -- Your favorite stores,
          Message 4 of 5 , Nov 4, 2003
          • 0 Attachment
            How about using eval()
            printf "The desired value is ".eval($count - 1);

            Aman Raheja
            AGF Technologies
            http://www.agftech.com


            Charles K. Clarkson wrote:

            > Sreeram B S <sreeramabsc@...> wrote:
            > :
            > : Thanks for the answer.. but this method was known !!!
            >
            > Almost all answers you'll find here are known
            > methods.
            >
            >
            > : This method uses an extra variable.. $temp in the
            > : example quoted.. I just wanted a means of avoiding
            > : this extra variable.
            >
            > How about using 'printf'. Just replace your variable
            > with %s and move it to the end. Later, you can dig into
            > the documentation to find out how to use formats beyond
            > %s. BTW, there is no need to put a space at the end of
            > a line.
            >
            >
            > my $count = 5;
            > printf "The desired value is (%s)\n", $count - 1;
            >
            >
            > HTH,
            >
            > Charles K. Clarkson
            > --
            > Head Bottle Washer,
            > Clarkson Energy Homes, Inc.
            > Mobile Home Specialists
            > 254 968-8328
            >
            >
            > Yahoo! Groups Sponsor
            > ADVERTISEMENT
            > click here
            > <http://rd.yahoo.com/M=194081.4074964.5287182.1261774/D=egroupweb/S=1705006951:HM/A=1732163/R=0/SIG=11n0nglqg/*http://www.ediets.com/start.cfm?code=30510&media=zone>
            >
            >
            >
            > Unsubscribing info is here:
            > http://help.yahoo.com/help/us/groups/groups-32.html
            >
            > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
            > <http://docs.yahoo.com/info/terms/>.


            --
            Your favorite stores, helpful shopping tools and great gift ideas.
            Experience the convenience of buying online with Shop@Netscape!
            http://shopnow.netscape.com/

            --
            Your favorite stores, helpful shopping tools and great gift ideas.
            Experience the convenience of buying online with Shop@Netscape!
            http://shopnow.netscape.com/



            [Non-text portions of this message have been removed]
          • Charles K. Clarkson
            ... I assume you mean print not printf. You re leaving the newline off the end in your solution. But why use eval()? What purpose does it serve? What advantage
            Message 5 of 5 , Nov 4, 2003
            • 0 Attachment
              For some reason Aman <amancgiperl@...> wrote:

              : Charles K. Clarkson wrote:
              :
              : > Sreeram B S <sreeramabsc@...> wrote:
              : > :
              : > : This method uses an extra variable.. $temp in the
              : > : example quoted.. I just wanted a means of avoiding
              : > : this extra variable.
              : >
              : > How about using 'printf'. Just replace your variable
              : > with %s and move it to the end. Later, you can dig into
              : > the documentation to find out how to use formats beyond
              : > %s. BTW, there is no need to put a space at the end of
              : > a line.
              : >
              : >
              : > my $count = 5;
              : > printf "The desired value is (%s)\n", $count - 1;
              :
              : How about using eval()
              : printf "The desired value is ".eval($count - 1);

              I assume you mean print not printf. You're leaving
              the newline off the end in your solution. But why use
              eval()? What purpose does it serve? What advantage is
              there over not using it?


              print 'The desired value is ', $count - 1, "\n";


              Charles K. Clarkson
              --
              Head Bottle Washer,
              Clarkson Energy Homes, Inc.
              Mobile Home Specialists
              254 968-8328
            Your message has been successfully submitted and would be delivered to recipients shortly.