Friday, November 4, 2011

Length Function in Perl

Length Function :

Length:
The length function simply gives you back the number of characters in a string variable.

This is handy when you don't know the value of the variable but would like to know the number of characters it has.
It is useful with arrays, conditional statements, loops, and such things.

$ cat length.pl
#!/usr/bin/perl
use strict;
my $test="sriram";
#my $len = length ($test);
my $ti = length($test);
print "The lengh of variable is $ti \n";


$ ./length.pl
The lengh of variable is 6
$

No comments:

Post a Comment