Mega Code Archive

 
Categories / Perl / Regular Expression
 

Using tr to retrieve the length of a string

#!/usr/local/bin/perl  $string = "here is a string";  $_ = $string;  $length = tr/a-zA-Z /a-zA-Z /;  print ("the string is $length characters long\n");