I'm trying to make this simple call:
DataB::testTable::Manager->get_testTable( query => [ id => $id, name => $name ] )
which works perfectly fine. But is it possible to pass a variable for the query. Something like:
$query = "id => $id , name => $name";
DataB::testTable::Manager->get_testTable( query => [ $query ] );
or something similar.
Strings and complex data structures are completely different things.
Strings are a sequence of codepoints/graphemes/bytes (depends how you're looking). Strings are dumb. Strings are not good at containing complex and/or hierarchical data. (Point in case: XML is pure pain)
However, you can put any Perl data structure into a scalar variable, using references. Square brackets create a reference to an anonymous array.
These groups of lines are equivalent except for the fact that a variable name is introduced:
Using references to data structures is better than using strings.
(You could interpret a string as Perl source code via
eval
. This is extremely powerful, but not everything stringifies to a form that can be eval'd into an equivalent data structure. Don't use string-eval, except for well thought out metaprogramming.)For further info on references and complex data structures, perlref, perlreftut and perldsc might be interesting.