473,395 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Regular Experession - Hashes

aphro2178
I know that this is an easy peasy question, but I am a beginner at PERL, could someone please help me....

What would be displayed by the Perl statements shown below if you were to type the following list of words, each separated by a return keypress, on input? <STDIN> = dog, cat, dog, turtle, cat, dog, end

print "Insert words to count: "
$line = <STDIN>;
while ($line !~ m/^ENDS/i) {
while ($line =~ a/(\w+) (.*)/$2/) {
$word = $1;
$wordHash{$word}++;
}
print "Insert words to count: ";
$line = <STDIN>;
}
print "\nWord counts: \n";
while ( ($word, $count) = each(%wordHash)) {
@wordArray[$1] = $word\t\t$count";
$i++;
print ("@wordArray\n");
}

I would like to understand how this works, I am really lost, any help would be surely appreciated. Thanks
Nov 9 '06 #1
2 1540
GunnarH
83
I know that this is an easy peasy question, but I am a beginner at PERL,
How can you tell it's easy if you are a beginner?

What would be displayed by the Perl statements shown below if you were to type the following list of words, each separated by a return keypress, on input? <STDIN> = dog, cat, dog, turtle, cat, dog, end
Nothing useful, since the code doesn't compile. Please make sure that your code compiles before posting.
Nov 9 '06 #2
hai

first you should chomp the input u r taking check the code and see it will work











venu..................
Nov 21 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Carl S. in 't Veld | last post by:
I am trying to generate tiger tree hashes the same way as directconnect does, but I am failing. I checked the output from php with the reference vectors from...
2
by: Michael McGarry | last post by:
Hi, Are there hashes in Python? Michael
8
by: Ben Holness | last post by:
Hi All, I want to create a hash array, based on values in a database. Basically, I want a hash array for each database key and I want to use a sub to get the hash array, but I am having a great...
2
by: Bogdan Zamfir | last post by:
Hi, I want to use RegularExpressionValidator to validate a date I want to let user to enter date in the following format one or two digits for day one or two digits for month two or four...
2
by: MartyNg | last post by:
I am running a system that has both Classic ASP applications and a smattering of ASP.NET applications. We want to store passwords on a SQL Server table as their MD5 hashes. What is the safest...
34
by: Antoine De Groote | last post by:
Hello, Can anybody tell me the reason(s) why regular expressions are not built into Python like it is the case with Ruby and I believe Perl? Like for example in the following Ruby code line =...
0
by: HalfCoded | last post by:
hi everyone, I am kind of stuck and therefore would really appreciate some clues: I actually have to run a script which has to compare two elements from two different files which are a blast...
1
by: pavanponnapalli | last post by:
hi , I have come across a code as below in the perldoc: %hash = map { get_a_key_for($_) => $_ } @array; Could anybody tell me the meaning of the above line? please explain map ...
10
by: aurekha | last post by:
Hi I have hashes with arrays to its keys like, %h1 = ('a'=>, 'b'=>, 'c'=> ); %h2 = ('a'=>, 'b'=>); then, how can i compare the 2 hashes(based on values. not keys) and get...
6
KevinADC
by: KevinADC | last post by:
This snippet of code provides several examples of programming techniques that can be applied to most programs. using hashes to create unique results static variable recursive function...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.