Perl
  Home arrow Perl arrow Page 3 - Beginning Programming Perl(s)
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

Beginning Programming Perl(s)
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 9
    2007-10-10

    Table of Contents:
  • Beginning Programming Perl(s)
  • Storing Data in A Variable
  • Quoth the Raven
  • List Data Types

  • 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

    Dell PowerEdge Servers

    Beginning Programming Perl(s) - Quoth the Raven
    (Page 3 of 4 )

    In the above example we worked with a string, or a group of characters. We encased it in single quotes ('), which lets the program know where the string ends and begins. Which is fine and dandy. But what if you come across a contraction? If you try the following code you will get strange results:


    #!/usr/local/bin/perl

    $my_sentence = 'I simply can't do it!';

    print "$my_sentencen";

    Because there is a single quote(') in the contraction can't, the program sees the word can as the end of the string, instead of the word it with an exclamation mark, as we originally intended. To fix this, you escape the quote with the backslash() key.

     

    #!/usr/local/bin/perl

    $my_sentence = 'I simply can't do it!';

    print "$my_sentencen";

    To use special characters like the n or to print a variable, we use the double quotes("). Consider the following:


    #!/usr/local/bin/perl

    $my_sentence = 'I simply can't do it!';

    print "$my_sentencen";

    print '$my_sentencen';

    In the above code, the following would print out:

      I simply can't do it!

      $my_sentencen

    See? You need the double quotes for those special keys, otherwise they will be seen as a normal string of text.

    More Perl Articles
    More By James Payne


       · This is the second article in a series on Perl. It delves into the different Data...
       · ...when I view the article in my browser, in the code, the backslashes...
     

       

    PERL ARTICLES

    - Perl: A Continuing Look at Hashes and Multid...
    - 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

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




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