in reply to Re: Re: stringification
in thread stringification
>perl -e ' sub string_to_struct { my $string = shift; my @refs = split /__/, $string; $string = "\$$refs[0]"; for (1 .. $#refs) { $string .= "-> {q/$refs[$_]/}" }; return eval "\\$string"; } print string_to_struct "foo__`rm xxx`"; ' SCALAR(0x8056ba4) >ls ... xxx ... >perl -e ' sub string_to_struct { my $string = shift; my @refs = split /__/, $string; $string = "\$$refs[0]"; for (1 .. $#refs) { $string .= "-> {$refs[$_]}" }; return eval "\\$string"; } print string_to_struct "foo__`rm xxx`"; ' SCALAR(0x8056bb0) > ls [argh! xxx has been removed]
Anyway, I'll check the refs and consider making sure all my configs get written in a safe way. It still wouldn't be nice to let them set any variable, I guess....
update:
Great reference. That solves it. Once again, chromatic sorts me out.
update 2:
Well, not completely. Chromatics solution in the thread referred to above will traverse a hash and show all the keys (and values). I'll have a think how to hack it to go just to the key and value you want.
update 3:
And by the way, my claim that the code above would be safe is not true - see replies to this post for why.
David
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: stringification
by chipmunk (Parson) on Feb 28, 2001 at 20:28 UTC | |
by dash2 (Hermit) on Mar 01, 2001 at 14:21 UTC | |
|
Re: stringification (perl command line trivia)
by deprecated (Priest) on Feb 28, 2001 at 17:48 UTC |