On Mar 4, suraj rajendran said: >How do I just print only the City and State where >person lives assuming that I have the following data.
It looks like your data is :-delimited. For your purposes, the split() function should do fine: ($name, $phone, $addr, $bday, $n) = split /:/, $record; Of course, you only wanted one of these fields: ($addr) = (split /:/, $record)[2]; And then you'll want to remove the extraneous information. ($city, $state) = $addr =~ /\s*([^,]+),\s*([A-Z]{2})/; >__DATA__ >Tomy Savage:408-724-0140:1222 Oxbow Court, >Sunnyvale,CA 94087:5/19/66:34200 >Lesle Kerstin:408-456-1234:4 Harvard Square, Boston, >MA 02133:4/22/62:52600 -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]