Perl string statistic

A very simple Perl-Script that prints some information about the current string, like length numbers and words:

use strict;

print str_stat("123 abc");

sub str_stat {
    my $var = shift;
    my $out .= "length = ".length($var);
    my @text  = ("a-zA-Z","words","0-9","numbers");
    my @reg = ('[a-zA-Z]','\w+','[1-9]','\d+');
       $out .="\n".$text[$_]." = "; 
       $out .=()= $var =~ /$reg[$_]/g; 

Our result:

length = 7 
a-zA-Z = 3 
words = 2 
0-9 = 3   
numbers = 1

4 thoughts on “Perl string statistic”

  1. It’s a shame you don’t have a donate button! I’d withhout a doubt donate to this superb blog!
    I suppose for now i’ll settlle for bookmarking annd adding your RSS feed to mmy Google account.
    I look forward to new updates and wijll share this site with my Facebook group.
    Chat soon!

  2. Great blog here! Also your site loads up fast! What host are you using?
    Can I get your affiliate link to your host?

    I wish my web site loaded up as quickly as yours lol

  3. I am regular reader, how are you everybody? This post posted at this website is
    truly fastidious.

  4. Hi, yup this article is truly fastidious and I have learned
    lot of things from it concerning blogging. thanks.

Leave a Reply

Your email address will not be published.

six + 17 =