Re: How easily I can solve this
- From: usenet@xxxxxxxxxxxxxxx
- Date: 12 Jun 2006 18:21:05 -0700
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)
.
- References:
- How easily I can solve this
- From: pkd
- Re: How easily I can solve this
- From: boyd
- Re: How easily I can solve this
- From: pkd
- Re: How easily I can solve this
- From: pkd
- How easily I can solve this
- Prev by Date: Open Perl IDE not compiling
- Next by Date: Re: Help understand documentation
- Previous by thread: Re: How easily I can solve this
- Next by thread: install problems on HPUX 11.11
- Index(es):