iLTC Home
Bookmark iLTC!

Categories

Perl
  • Perl Tutorials Beginners

  • Javascript
  • Javascript Tutorials
  • Javascript Tutorials Beginners

  • HTML
  • HTML Tutorials

  • Command Line
  • Command Line Tutorials

  • How Tos
  • Other Tips and Tricks



  • for($i;$i < 1000;$i++) { }
    1721515

    iLoveTheCode.com

    Use the Perl PRINT FUNCTION

    There are two ways to PRINT to your browser or terminal. Luckily, whether you are using a CGI script for the web, or you are running Perl on the command line, PRINT works the same way.

    The PRINT FUNCTION Example 1:


    $city2="Paris";

    print "I saw \"London\", and it cost me \$40.00 to take the Chunnel to $city2.<br>chris\@ilovethecode.com";

    Which prints:
    I saw "London", and it cost me $40.00 to take the Chunnel to Paris.
    chris@ilovethecode.com


    Inside of the double quotations, COMMENT OUT $ @ and " with backslashes \

    We didn't COMMENT OUT the last $ because we wanted to print $city2 as a variable (Paris).


    The PRINT FUNCTION Example 2:


    $city2="Paris";

    print <<"H";

    I saw "London", and it cost me \$40.00 to take the Chunnel to $city2.<br>
    chris\@ilovethecode.com

    H


    Pretty much the same except... you can write quotation marks to your heart's content! You need not comment them out anymore!

    That might not seem like much, but it really does keep your code neater.

    NOTE: The H can be any letter or set of letters you like as long as the two match and they are followed by line returns.



    Copy and Paste Perl Script:

    #!/usr/bin/perl

    print "Content-type:text/html\n\n";

    $city2="Paris";

    print "I saw \"London\", and it cost me \$40.00 to take the Chunnel to $city2.<br>chris\@ilovethecode.com";

    print <<"H";

    <br><br>
    I saw "London", and it cost me \$40.00 to take the Chunnel to $city2.<br>
    chris\@ilovethecode.com

    H

    exit;




    Perl Print Function - See in Action (new window)




    Previous Article: INCREMENT and DECREMENT a Variable in Perl
    Next Article: OPEN and READ a Data File in Perl






    Search iLTC w/ Google




    Recent Articles

  • HTML Font Code
  • Javascript and CSS - Easy Pop Up Help Balloons
  • Use OnMouseOver in Javascript
  • Use onMouseOut in Javascript
  • Use innerHTML to Change Text on a Page
  • Renaming a File with Perl's RENAME Function
  • PRINT to Browser with document.write Command in Javascript
  • Passing an Argument or Variable to a Javascript
  • Opening an Alert Box in Javascript
  • Opening a REMOTE WINDOW in Javascript
  • OPEN and WRITE a Data File in Perl
  • OPEN and READ a Data File in Perl
  • Mimic Typing from a Textfield in a Textarea with Javascript
  • Javascript Reset Form








  • Perl Programming - Javascript Programming - HTML Code - Mac Unix Command Line - Maybe Some PHP - Free Scripts - ILoveTheCode
    All Content © 2006-2009 iLoveTheCode.com


    Contact Chris | About this Site


    1721243
    Counter by iLoveTheCode.com


    Last Modified: Saturday, 10-Jan-2009 05:40:25 EST



    Hosted as well :)
    Home-brewed logo - 1997