Perl
  Home arrow Perl arrow Page 4 - Perl: Concatenating Text and More
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? 
Google.com  
PERL

Perl: Concatenating Text and More
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 1
    2008-03-10


    Table of Contents:
  • Perl: Concatenating Text and More
  • Making Copies
  • Chomping It Up Pac-Man Style
  • Transformers...More than Meets the Eye

  • 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: Concatenating Text and More - Transformers...More than Meets the Eye
    ( Page 4 of 4 )

    There are a number of built-in Perl functions that allow you to do crazy things with text. Among those are ways to manipulate the case of characters, changing the first letter to upper/lower case, the whole string to upper/lower case, etc. Here they are in a program:


    #!/usr/bin/perl

     

    $thingOne="james";

    $thingtwo="PAYNE";

    print $thingOne . "\n";

    print ucfirst($thingOne);

    print "\n";

    print uc($thingOne);

    print "\n\n";

    print $thingtwo;

    print "\n";

    print lcfirst($thingtwo);

    print "\n";

    print lc($thingtwo);

    This will result in:

      james

      James

      JAMES


      PAYNE

      pAYNE

      payne

    If functions aren't your thing, you can also use special characters to achieve the same effect:


    #!/usr/bin/perl

     

    $thingOne="james";

    $thingtwo="PAYNE";

    print "l$thingtwo";

    print "\n\n";

    print "u$thingOne";

    print "\n\n";

    print "L$thingtwo IS MY LAST NAME E U$thingOneE is the first.";

    This gives us the result:

      pAyne

      James

      payne is my last name JAMES is the first.

    A few things to note: the "l" and "u" act as lcfirst and ucfirst, respectively, while the "L" and "U" make everything following it uppercase until it reaches the "E", which signals an end to the special character.

    Well unfortunately we did not get to cover every bit of string manipulation that I wanted to, but never fear: we'll get to that in another article. Maybe even the next one, where I will also cover ways to manipulate numbers.

    Till then...



     
     
    >>> 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 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek