iLTC Home
Bookmark iLTC!
iLTC Google Boards

Google Groups
Receive The Code in Email!



Categories

Perl
  • Perl Tutorials Beginners

    Javascript
  • Javascript Tutorials
  • Javascript Tutorials Beginners

    HTML
  • HTML Tutorials



  • I love the code... dot com
    123,766

    iLoveTheCode.com
    Perl > Perl Tutorials How To Easy > If, Elsif, and Else in Perl

    If, Elsif, and Else in Perl



    $gygy="London";

    if ($gygy eq "Paris") {
    print "The city is Paris. ";
    }
    elsif ($gygy eq "Tokyo") {
    print "The city is Tokyo. ";
    }
    else {
    print "The city is London. ";
    }


    In plain English:
    -The variable we named gygy equals London.
    -We say: If gygy equals Paris, print one thing.
    -We then say: Else If (elsif) gygy equals Tokyo, print a different thing.
    -We then say: or Else! If all else fails, print this other thing.


    Copy and Paste Perl Code:

    #!/usr/bin/perl

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


    $gygy="London";

    if ($gygy eq "Paris") {
    print "The city is Paris. ";
    }
    elsif ($gygy eq "Tokyo") {
    print "The city is Tokyo. ";
    }
    else {
    print "The city is London. ";
    }


    if ($gygy eq 1) {
    print "One";
    }
    elsif ($gygy eq 2) {
    print "Two";
    }
    else {
    print "Three";
    }

    exit;



    Click HERE to comment or discuss at iLoveTheCode GOOGLE Group
    Previous Article: Redirect to a Different URL in Perl
    Next Article: Getting Server Time in Perl





    jQuery in ActionjQuery in Action

    Bear Bibeault, Yeh...

    New $26.39

    Information Architecture...Information Architecture for the Wor...

    Louis Rosenfeld, P...

    New $26.39

    New Perspectives on Crea...New Perspectives on Creating Web Pag...

    Patrick Carey

    New $69.26

    Dreamweaver CS3Dreamweaver CS3

    David McFarland

    New $29.69

    JavaScriptJavaScript

    David Flanagan

    New $31.49

    Head First HTML with CSS...Head First HTML with CSS & XHTML

    Eric Freeman, Elis...

    New $23.99

    HTML, XHTML, and CSS, Si...HTML, XHTML, and CSS, Sixth Edition ...

    Elizabeth Castro

    New $23.09

    CSS MasteryCSS Mastery

    Andy Budd, Simon C...

    New $23.85

    Creating Web SitesCreating Web Sites

    Matthew MacDonald

    New $19.77


    Of Interest:
  • What's in an Array, Index Numbers
  • Finding the Length (Index Numbers) of an Array in Perl
  • What Environmental Variables are Available
  • INCREMENT and DECREMENT a Variable in Perl
  • Change a Form Field with Javascript
  • Create a Function in Javascript
  • Increment a Variable in Javascript
  • Focus a Window with self.focus in Javascript
  • HTML Color Codes
  • HTML Color Chart
  • Make Italic Text Using HTML
  • HTML Status

  • More Articles:
  • Undefine an Array in Perl
  • Create an Array of Specific Numbers in Perl
  • Opening and Reading a Directory in Perl
  • OPEN and READ a Data File in Perl
  • onClick Javascript
  • Use onClick in Javascript
  • Getting Epoch Time in Javascript
  • Substitute in Javascript Using replace Method
  • Write a For Loop in Javascript
  • HTML Forms
  • Make Strikethrough Text Using HTML
  • Make Text Bold Using HTML
  • HTML Background

  • Search iLTC w/ Google





    Recent Articles

  • Javascript Focus Form Field
  • Javascript Lowercase Text
  • Javascript Uppercase Text
  • Javascript Superscript Text
  • Javascript Subscript Text
  • Make Text Blink Using Javascript
  • Make a String into a Link in Javascript
  • Javascript Italics Text
  • Javascript Bold Text
  • Javascript Redirect
  • HTML Frames
  • HTML Color Chart
  • HTML Link
  • Javascript Status Bar








  • Perl Programming - Javascript Programming - Maybe Some PHP - Free Scripts - ILoveTheCode
    All Content © 2006 iLoveTheCode.com


    Contact Chris | About this Site


    420,527
    Counter by iLoveTheCode.com


    Last Modified: Friday, 23-Jun-2006 07:23:14 EDT