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:
In the file to determine the city in which there is more than one buyer

 



SubTerran
New User

Sep 5, 2012, 7:16 AM

Post #1 of 3 (1078 views)
In the file to determine the city in which there is more than one buyer Can't Post

Task: In the file to determine the city in which there is more than one buyer.
I wrote this program to C++, but I need a program in Perl.
Sorry for my english.
Attachments: file.txt (2.79 KB)


Laurent_R
Veteran / Moderator

Sep 5, 2012, 10:23 AM

Post #2 of 3 (1070 views)
Re: [SubTerran] In the file to determine the city in which there is more than one buyer [In reply to] Can't Post

Hi,

you can do the following.

Read the file line by line. Split each line on the ":" into an array and take the fourth element of the array (subscript 3), the city. Trim the white spaces (although not absolutely necessary). Check if the city thus found is in a hash. If it is already there, you've got a city where there is more than one customer; if the city is not in the hash, put the city in the hash.


BillKSmith
Veteran

Sep 5, 2012, 10:36 AM

Post #3 of 3 (1068 views)
Re: [Laurent_R] In the file to determine the city in which there is more than one buyer [In reply to] Can't Post

What if a single "seller" has multiple stores? (In the same city? In different cities?)
Good Luck,
Bill

 
 


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

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