in reply to Re^2: Issues with Split
in thread Issues with Split
Here is what afoken was talking about -- instead of this:
you should do this:my ($type, $restofstring) = /^type=(\w+) (.+)$/; for $restofstring (split) { my ($key, $val) = split /=/, $restofstring; $hash{$type}{$key} = $val; }
my ($type, $restofstring) = /^type=(\w+) (.+)$/; for $token ( split ' ', $restofstring ) { my ($key, $val) = split /=/, $token; $hash{$type}{$key} = $val; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Issues with Split
by cipher (Acolyte) on Jun 14, 2016 at 11:24 UTC |
In Section
Seekers of Perl Wisdom