Perl
  Home arrow Perl arrow Page 4 - Perl: Concatenating Text and More
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 
 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: Concatenating Text and More
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 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:
      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

    The Web Buyer's Guide is your best source for white papers on a wide range of IT products and services. This Week's Featured White Papers: Building a Virtual Infrastructure from Servers to Storage by Network Appliance

    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...


    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.

       · Hi, thanks for droppingby to read my Perl article. Inside we discuss how to...
     

       

    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




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