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
    Hmm... welp, the reason I was not seeing eval doing what I expected was because I was doing this:
    eval { $line };
    not this:
    eval $line;

    And I wholeheartedly agree... doing it this way is stupid. It was just the first thing I thought of, and got grumpy when things weren't behaving as I expected. eval EXPR != eval BLOCK. Right.

    Thanks for the assists...