Greetings,

I am trying to get name, phone and address in a lexical variable and trying to 
print it, but, I am not getting the expected output. Any help is greatly 
appreciated.

[code]
use strict;
use warnings;

while (<DATA>) {
    my ($name, $phone, $address) = /^([a-zA-Z ]+):([\-\d]+):([\w, ])$/;
    print "Name : $name\n" if defined $name;
    print "Phone : $phone\n" if defined $phone;
    print "Address : $address\n" if defined $address;
}

__DATA__
Sachin Tendulkar:408-724–0140:23, Brooke Street, Sunnyvale,CA 94088
Mahendra Singh Dhoni:408–456–1234:76, Charles Street, Washington, MA 02131
Rahul Dravid:408–253–3122:123, Queens Street, Canberra, Australia
Virendar Sehwag:293–259–5395:15 Hilton Avenue, Sydney, Australia
[/code]


Where am I going wrong?. 
 
best,
Shaji 
-------------------------------------------------------------------------------
Your talent is God's gift to you. What you do with it is your gift back to God.
-------------------------------------------------------------------------------

Reply via email to