CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [smsh] Printing and Counting words: Edit Log



Nila
User


Mar 30, 2010, 10:25 PM


Views: 6511
Re: [smsh] Printing and Counting words

Try the following code for your second part.


Code
use strict; 
use warnings;

open FH, "file.txt" or die "Can't Open the file : $!";
my $count;
while (<FH>)
{
my @array=split;
unless(/^\s*$/){
for (@array)
{
$count++ if(/^(\w{3})\w*\1$/);
}
}
}
print "No.Of.Words(Start and End with Same Three Characters)=$count\n";



(This post was edited by Nila on Mar 30, 2010, 10:25 PM)


Edit Log:
Post edited by Nila (User) on Mar 30, 2010, 10:25 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives