Re: How easily I can solve this



pkd wrote:
Now I want to make this thing little complex. I have similar string but
if the value has space then I have the value with in single quote ( '
), otherwise there is no quote

It's getting kludgy (because your input data is crap), but consider
something like this:

#!/usr/bin/perl
use strict; use warnings;

my $str1 = "Name='Mr. L. Wall' Address='34 Red Rd' phone=555-5555";
my $str2 = "Name=Pete Address='100 Stand Rd' phone=1-800-321-7764";

foreach my $string ($str1, $str2) {
my ($name, $address, $phone) = ($string =~
m/^Name=\'?(.*?)\'?\s+Address=\'?(.*?)\'?\s+phone=([\d-]*)/
);
print "$name\t$address\t$phone\n"
}

__END__

--
David Filmer (http://DavidFilmer.com)

.