Perl
  Home arrow Perl arrow Page 4 - Perl 101 (Part 1) - The Basics
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 101 (Part 1) - The Basics
By: Vikram Vaswani and Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 14
    2000-05-23

    Table of Contents:
  • Perl 101 (Part 1) - The Basics
  • ...And The Little Language That Could!
  • Your First Perl Program
  • To Err Is Human...To Debug, Divine!
  • What's Next?

  • 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

    PCmover - $15 Off with Coupon Code CJPH7Q

    Perl 101 (Part 1) - The Basics - To Err Is Human...To Debug, Divine!
    (Page 4 of 5 )

    Perl also comes with a very powerful debugger, which alerts you to mistakes in your code. As an example, try omitting the last double quote from the example above and run the script again. You should see something like this:
    Can't find string terminator '"' anywhere
    before EOF at ./test.pl line 5.

    As you can see, the error message tells you pretty much all you need to know to find and squash the bug. Of course, all Perl's error messages aren't quite that informative - some of them are liable to sound a lot like Greek spoken backwards, especially if you're a novice. And so it's a good idea to use the "-w" flag when running your program - this flag tells the debugger to print extra warnings when it encounters an error.

    Take a look at the following example, which runs the Perl script above with the "-w" flag:
    #!/usr/bin/perl -w
    # Synthesis
    print ("Hello there! And what are you doing ",
    1+1, "night, baby?n);

    If you run this program, here's what you'll see:
    syntax error at TEST line 5, near "print"
    Unquoted string "doing" may clash with future reserved 
    word at TEST line 5.
    String found where operator expected at TEST line 5, 
    near "doing ", 1+1, ""
    (Do you need to predeclare doing?)
    Bare word found where operator expected at TEST line 
    5, near "", 1+1,
    "night"
    (Missing operator before night?)
    Unquoted string "night" may clash with future reserved 
    word at TEST line 5.
    Unquoted string "baby" may clash with future reserved 
    word at TEST line 5.
    Unquoted string "n" may clash with future reserved 
    word at TEST line 5.
    Execution of TEST aborted due to compilation 
    errors.

    Of course, there is sometimes such a thing as too much data...

    More Perl Articles
    More By Vikram Vaswani and Harish Kamath, (c) Melonfire


     

       

    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 4 hosted by Hostway