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 bookmarked this site...
    20,106

    iLoveTheCode.com
    Perl > Perl Tutorials How To Easy > Get the Length of a Word or String in Perl

    Get the Length of a Word or String in Perl



    To get the length of a word or string in Perl:

    $dr="This is a short sentence";

    $ft=length($dr);

    print $ft;

    Which prints:
    24


    -We create a variable and name it $dr because we are lazy typers.
    -We use Perl's built-in length function on our variable $dr and store it in our newly created variable $ft.
    -We print $ft.


    We could have also done:

    $ft=length("Hiyas");

    print $ft;

    Which prints:
    5


    -This time we just put the word/sentence right into the length function.
    -Since our word/sentence is not a variable, we must enclose it in quotation marks.



    Copy and Paste Perl Code:

    #!/usr/bin/perl

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

    $dr="This is a short sentence";

    $ft=length($dr);

    print "$ft ";

    $ft=length("Hiyas");

    print $ft;

    exit;



    Resources:
    Use the Perl PRINT FUNCTION
    Finding the Length (Index Numbers) of an Array in Perl


    Click HERE to comment or discuss at iLoveTheCode GOOGLE Group
    Previous Article: Add, Subtract, Multiply, and Divide in Perl
    Next Article: Undefine an Array in Perl





    CSSCSS

    David McFarland

    New $23.09

    DojoDojo

    Matthew A. Russell...

    New $26.39

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

    Elizabeth Castro

    New $23.09

    Bulletproof Web DesignBulletproof Web Design

    Dan Cederholm

    New $26.39

    Dreamweaver CS3Dreamweaver CS3

    David McFarland

    New $29.69

    Struts 2 in ActionStruts 2 in Action

    Don Brown, Chad Da...

    New $29.69

    jQuery in ActionjQuery in Action

    Bear Bibeault, Yeh...

    New $26.39

    Learning Web DesignLearning Web Design

    Jennifer Niederst ...

    New $29.69


    Of Interest:
  • Use the Perl PRINT FUNCTION
  • Splitting an ARRAY in Perl
  • Undefine an Array in Perl
  • Write a FOR LOOP in Perl
  • Splitting an Array using Javascript
  • Javascript Reset Form
  • Javascript Subscript Text
  • Javascript Reverse - Use Reverse on Items in an Array in Javascript
  • HTML Color Chart
  • HTML Body Tag
  • HTML Tables
  • HTML Image

  • More Articles:
  • Undefine an Array in Perl
  • Getting Server Time in Perl
  • Add to the Beginning of an Array with Unshift in Perl
  • Use the Perl PRINT FUNCTION
  • onClick Javascript
  • Increment a Variable in Javascript
  • Call your Function in Javascript
  • Setting a Cookie using Javascript
  • Use onClick in Javascript
  • HTML Tags
  • HTML Color Codes
  • Make a New Paragraph Using HTML
  • HTML Center

  • 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


    316,846
    Counter by iLoveTheCode.com


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