Perl
  Home arrow Perl arrow Page 4 - Perl: Releasing Your Inner Textuality
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM Rational Software Development Conference
 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: Releasing Your Inner Textuality
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-02-25

    Table of Contents:
  • Perl: Releasing Your Inner Textuality
  • Special Characters Don't Need Helmets or Small Buses
  • Printing Variables
  • More Printing Information

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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

    Speeding Shipping, Improving Compliance – Read the ScanCode Systems Case Study

    Perl: Releasing Your Inner Textuality - More Printing Information
    (Page 4 of 4 )

    Another thing to keep in mind is that you must use a backslash to print a $ symbol. Without it, Perl will try to interpret it as a variable. Behold:


    #!/usr/bin/perl

    print "I have $15.00 in my pocket boyee!";

    If you try to run that program you will get an odd result:

      I have .00 in my pocket boyee!

    Very odd indeed. Since we aren't trying to print a variable, the proper way to write this code would be:


    #!/usr/bin/perl

    print "I have \$15.00 in my pocket boyee!";

    Which would give us the correct print out of:

      I have $15.00 in my pocket boyee!

    Similarly, you cannot print out an @ symbol either. The following will not work:


    #!/usr/bin/perl

    print "My email address is james@james.com.";

    If you used this code it would print:

      My email address is james.com.

    To fix this, we again use our good old buddy the backslash:


    #!/usr/bin/perl

    print "My email address is james\@james.com.";

    Which prints out:

      My email address is james@james.com .

    And lastly, we can also use escape characters and special characters on our variables. Here is an example:


    #!/usr/bin/perl

    $color="black";

    $number="eight";

    print "\n\nPlease find my favorite color and number below:\n\n";

    print "\tMy favorite color:\t\t\t$color\n";

    print "\tMy favorite number is:\t\t\t$number\n\n";

    This will print out our text and variables so that they appear like this on the user's screen:

      Please find my favorite color and number below"


      My favorite color:               black

      My favorite number is:       eight

    Well that's all the time we have for this exciting episode. Join us next time when we continue this intriguing, gut wrenching discussion on Perl text manipulation. I look forward to seeing you.

    Till then...


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Thank you for dropping by to read my article on working with Perl Text. This is the...
       · In your second example you missed your backslash.print "My email address is...
       · Hey thanks for catching that; our CMS gobbles up the backslashes sometimes. I'll be...
       · Nice article for beginners, but in the example with the $ you're missing the...
       · Hey, thanks for the comment, and for catching that missing backslash. The CMS we use...
     

       

    PERL ARTICLES

    - Perl: Another Round with Hashes
    - Perl Hashes
    - Perl Lists: A Final Look at List::Util
    - Perl Lists: Utilizing List::Util
    - Perl Lists: The Split() Function
    - SQL and CGI with Perl and DBI
    - Perl Lists: More Functions and Operators
    - SELECT Queries and Perl
    - Perl Lists: More on Manipulation
    - Creating a Database with Perl and DBI
    - Perl: Sailing the List(less) Seas
    - Perl and DBI
    - Perl: Concatenating Text and More
    - Perl Text: Quoting Without Quote Marks
    - Perl: Releasing Your Inner Textuality




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway