>>>>> "AG" == Aruna Goke <myklass@[EMAIL PROTECTED]
> writes:
AG> my $string =
"field1,int,10#field2,string,abc#field3,varchar,abc123";
AG> my @[EMAIL PROTECTED]
= split(/#/,$string);
AG> my %h;
AG> my @[EMAIL PROTECTED]
AG> for (@[EMAIL PROTECTED]
){
AG> @[EMAIL PROTECTED]
= (split/,/)[0,2];
AG> %h = (@[EMAIL PROTECTED]
);
simple one liner (untested) (assumes clean data with no # or , in it):
my %hash = $string =~ /(\w+),\w+,(\w+)/g ;
using a regex to parse out all the key/value pairs is simpler and much
much faster than all those splits and loops. and only 1 (the final)
variable needs to be declared.
uri
--
Uri Guttman ------ uri@[EMAIL PROTECTED]
-------- http://www.sysarch.com
--
----- Perl Code Review , Architecture, Development, Training, Sup****t
------
--------- Free Perl Training --- http://perlhunter.com/college.html
---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com
---------


|