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



  • Perl with cheese...
    123,705

    iLoveTheCode.com
    Perl > Perl Tutorials How To Easy > Create or Put Items into an Array in Perl

    Create or Put Items into an Array in Perl



    To create or put items into an array in Perl:

    @jiji=("Hi","Hello","Hiya");

    print @jiji;

    Which prints:
    HiHelloHiya

    -We named our array jiji because it's fun to type jiji. (Arrays start with @ unlike scalars which start with $)
    -We stored our three items, separated by commas with each enclosed in quotation marks.
    -We printed our array.


    NOTES: Even though we created this array in a very formal manner. Almost anything can be converted into an array and pieced out using Perl's built-in split function. Just slap an @ in front of something!

    Imagine you have a scalar variable $ko...

    $ko="England wins World Cup.";

    @jiji=split(/ /, $ko);

    print $jiji[1];


    Which Prints:
    wins


    -We created a variable named ko and stored some words there.
    -We used Perl's split function on our variable $ko and stored the pieces into our new array jiji. (We split at the spaces / /)
    -We printed the second piece of @jiji. (Index numbers start at 0, so $jiji[0] would equal England.)


    Copy and Paste Perl Code:

    #!/usr/bin/perl

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

    @jiji=("Hi<br>","Hello<br>","Hiya<br>");

    print @jiji;

    $ko="England wins World Cup.";

    @jiji=split(/ /, $ko);

    print $jiji[1];

    exit;



    Resources:
    Perl:
    Use the Perl PRINT FUNCTION
    Splitting an ARRAY in Perl
    Undefine an Array in Perl
    What's in an Array, Index Numbers
    Finding the Length (Index Numbers) of an Array in Perl

    Javascript:
    Splitting an Array using Javascript



    Click HERE to comment or discuss at iLoveTheCode GOOGLE Group
    Previous Article: Undefine an Array in Perl
    Next Article: Add to End of an Array with Push in Perl





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

    Eric Freeman, Elis...

    New $23.99

    HTML & XHTMLHTML & XHTML

    Chuck Musciano, Bi...

    New $29.99

    CSSCSS

    David McFarland

    New $23.09

    Creating Web SitesCreating Web Sites

    Matthew MacDonald

    New $19.77

    Bulletproof Web DesignBulletproof Web Design

    Dan Cederholm

    New $23.99

    Learning Web DesignLearning Web Design

    Jennifer Niederst ...

    New $26.99

    CSSCSS

    Eric Meyer

    New $29.69

    JavaScriptJavaScript

    David Flanagan

    New $31.49

    CSS MasteryCSS Mastery

    Andy Budd, Simon C...

    New $23.85


    Of Interest:
  • And, Or, Equal, Not Equal, Greater Than, Less Than in Perl
  • Create a Subroutine in Perl
  • INCREMENT and DECREMENT a Variable in Perl
  • Finding the Length (Index Numbers) of an Array in Perl
  • Javascript Subscript Text
  • Javascript Shift - Use Shift to Remove Items from the Beginning of an Array in Javascript
  • Use onMouseOut in Javascript
  • Javascript Redirect
  • HTML Center
  • Make Strikethrough Text Using HTML
  • HTML Codes
  • HTML Background

  • More Articles:
  • Add to End of an Array with Push in Perl
  • Redirect to a Different URL in Perl
  • What's in an Array, Index Numbers
  • Add, Subtract, Multiply, and Divide in Perl
  • onClick Javascript
  • Opening a REMOTE WINDOW in Javascript
  • Call your Function in Javascript
  • Get String Length with Javascript
  • Use onMouseOut in Javascript
  • HTML Font Code
  • Make a New Paragraph Using HTML
  • Make Text Bold Using HTML
  • Make Strikethrough Text Using HTML

  • 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,466
    Counter by iLoveTheCode.com


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