in reply to How to change the scalar value to some other context.

It is difficult to understand what your question or problem is. It might help if you reviewed How do I post a question effectively? and perhaps brian's Guide to Solving Any Perl Problem, then updated your post with a question or statement describing what is preventing you doing what you want to do.

update: rewritten to (I hope) clarify.

update: The eval function may be what you are looking for. Consider the following:

use strict; use warnings; use Data::Dumper; my $x = "[1,'test',[{2=>3,3=>'test_56'},[2],[3],3]]"; my $y = eval $x; print Dumper($y);

Is this what you are wanting to do?

Replies are listed 'Best First'.
Re^2: How to change the scalar value to some other context.
by santhosh_89 (Scribe) on Jul 24, 2009 at 11:52 UTC

    Is it secure method to use eval function.

      Is it secure method to use eval function.

      That is an excellent question. The short answer is: no.

      The eval function will parse and execute arbitrary code. Therefore, it is quite dangerous.

      Your program can still be secure if it ensures that the eval function will only evaluate "safe" code. To do this, you must carefully screen all inputs that go into the code the eval function evaluates. You might find perlsec and the 'taint' mode it describes helpful.