You are here: Home Programming Perl How to use the string length() function in Perl

How to use the string length() function in Perl

 

 

 

Perl string length() function

 $RESULT = length(EXPRESSION); 


Perl's length() function simply returns the length of a perl string in characters.

Problem

 $myString = 'Welcome to length function in Perl';
 $myLength = length($myString);
print "MyString : $myLength";

Solution

 MyString : 34 


In this example, we've created a string with the value "Welcome to length function in Perl". When we run the length function on the string, it will return 34, or the total number of characters in the string. Note that this does not count the size of the string in bytes - just the length in characters.


Clientele

 

SIGN UP RIGHT NOW FOR EMAIL UPDATES

Share this post


blog comments powered by Disqus

Print PDF

HTML Codes
opinions powered by SendLove.to

Our valuable member Khabza has been with us since Thursday, 08 July 2010.

Show Other Articles Of This Author

Back to top
SA Topsites :: Simphiwe - Find me on Bloggers.com

Copyright © Green IT Web - Blog by Khabza in Cape Town 2012

Template by Joomla 1.7 Templates & Szablony Joomla.