in reply to List as a string, eval'd back to the list?
As long as you're certain that the data lines are as (more or less) simple as the ones you've posted (ie, the keys to the hash are never strings that contain a '='), why can't you just eval the RHS?
$line = '@{ $blah{ foo } } = ( 100 .. 104 , 105 , 106 .. 123 );'; $line =~ s/^[^=]+=//; @list = eval $line;
Of course, this uses string-eval (on "user" data, even!), which is a Bad Thing. It's also easy to break. I think you really would be better off if you can get the other script to print the list as a CSV string. It'd be easy to do, and then you could just split said string and avoid all this eval-evil.
bbfu
Seasons don't fear The Reaper.
Nor do the wind, the sun, and the rain.
We can be like they are.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: List as a string, eval'd back to the list?
by markguy (Scribe) on Mar 30, 2001 at 08:07 UTC |