Perl
  Home arrow Perl arrow Page 2 - Perl: Number Crunching
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PERL

Perl: Number Crunching
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 4
    2008-08-05


    Table of Contents:
  • Perl: Number Crunching
  • Smooth Operator
  • Operator Precedence
  • The Positive and the Negative
  • Proselytizing Numbers into Holy Strings!

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Perl: Number Crunching - Smooth Operator
    ( Page 2 of 5 )

    As was the case in the Perl Text tutorials, some of this information I have skimmed over before. Feel free to skip over any subject you have already read about. Or if you want a refresher, keep reading.

    You should be familiar with some of these math operators. If not well, why don't you let me handle your finances for you? And remember...-$209 is more than $100.

    The first set of mathematical operators I will be forcing upon you are the +,-,*, %, and /. For those of you from the planet Alabama, those roughly translate to addition, subtraction, multiplication, modulo, and division. Here is some code showing each of them in use:


    #!/usr/bin/perl

    $myPay=2400;

    $britneyspay=232000;

    $kfedspay=800;

    $add=9+2;

    $subtract=9-2;

    print "Kevin Federline makes " . $kfedspay . " per month.";

    $combined= $britneyspay+$kfedspay;

    print "\nHe and Britney used to make " . $combined . " per month.";

    print "\nI am underpaid...";

    print "Below is some simple math:\n\n";

    print "\n9+2 equals: " . $add;

    print "\n9-2 equals: " . $subtract;

    print "\n9*2 equals: " . 9*2;

    print "\n9/2 equals: " . 9/2;

    print "\n9%2 equals: " . 9%2;

    This magnanimous code gives us the following result:

      Kevin Federline makes 800 per month

      He and Britney used to make 232800 per month

      I am underpaid...Below is some simple math:

      9+2 equals: 11

      9-2 equals: 7

      9*2 equals: 18

      9/2 equals: 4.5

      9%2 equals: 1

    As you can see, being talentless pays well. You might also be staring at one of those equations and scratching your head (if you are Britney, you may have hired someone to scratch it for you; and it probably itches a lot now that you have shaved it). And that would be my little buddy the modulo (9%2 equals: 1). Modulo, for those who don't know, returns the remainder of a division. For instance, 9/2 equals 4 with a remainder of 1. So the result is...1. Magic, I know.



     
     
    >>> More Perl Articles          >>> More By James Payne
     

       

    PERL ARTICLES

    - More Perl Bits
    - Perl, Bit by Bit
    - Basic Charting with Perl
    - Using Getopt::Long: More Command Line Option...
    - Command Line Options in Perl: Using Getopt::...
    - Web Access with LWP
    - More Templating Tools for Perl
    - Site Layout with Perl Templating Tools
    - Build a Perl RSS Aggregator with Templating ...
    - Looping, Security, and Templating Tools
    - Perl: Bon Voyage Lists and Hashes
    - Templating Tools
    - Perl: Number Crunching
    - Perl Debuggers in Detail
    - Debugging Perl





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    Stay green...Green IT