On Fri, Jun 08, 2001 at 11:03:50AM -0400, Chris Rogers wrote:
> The subject line may not correctly describe the problem but that is probably
> because I don't really understand the problem myself. Here's a brief
> rundown of what I am trying to do:
> I have a string that is delimited by pipes ( | )
> Within each subset of the string there are one or more other value pairs
> Each of those pairs is separated from the others by a semi-colon ( ; )
> The name and value in each pair may be split by a colon ( : ) or an
> equals sign ( = )
>
> I want to create one array that contains all the data parsed out into
> individual pieces
How about:
my @pieces = split(/\|/,$t);
my @foo;
foreach my $i (0 .. $#pieces)
{
@{$foo[$i]} = split(/;/,$pieces[$i]);
}
or even:
my @pieces = split(/\|/,$t);
my @foo = map { [ split(/;/,$_) ] } @pieces;
or even wackier:
my @foo = map { [ split(/;/,$_) ] } split(/\|/,$t);
Apologies for untested code...
--
1 0wn d15 5Igf1l3!!!