in reply to Splitting on double quotes
First things first: the line split (/"/,$line) by itself doesn't do much. split returns a list, so you should do something like
my @elements=split (/"/,$line)That gives you 'type=','car','make=' etc...
Not what you wanted? Thought so. In order to also strip the "="-signs, you'll want to add them to the regex in the split:
my @elements=split (/=?"/,$line)Added bonus: If you then do my %hash = (@elements);, you get a nice little hash:
%hash = { type => 'car', ofmake => 'Ford', color => 'red'};
Hope that helps,
BrotherAde
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Splitting on double quotes
by mirod (Canon) on Aug 12, 2002 at 09:06 UTC |