On Jan 9, 4:57 am, [EMAIL PROTECTED] (Perlmunky) wrote:
> Hi list,
>
> I am working on a catalyst project and would have been attempting to create
> a user page (form) that allows someone to create an sql query to hammer a
> local DB (all secure-ish - maybe).  I have used a javascript function to
> return the post options and used the catalyst method
> $c->request->parameters() to get at the form information.
>
> The information is contained within a hash (ref to a hash) and the values
> are either scalar or arrays.  What I would like to know is if there is a way
> of testing the type of a variable - as with python:
>
> >>> foo = ["a", "b", "c"]
> >>> type(foo)
>
> <type 'list'>
>
> or if there is a way to convert the scalars into arrays - allowing me to
> skip the check.  I have tried to use a JSON hash in the javascript but this
> has not worked - I also *assume* that I would be presented with the same
> problem - parsing that hash of mixed variables.

I'm having difficulty parsing your question to figure out what you're
asking, but I think what you're looking for is the ref() function,
which returns a true value if given a reference (actually, it returns
a string representing what type of reference it's given: 'ARRAY',
'HASH', 'CODE', 'SCALAR', etc), and returns a false value if given a
non-reference.

ref([EMAIL PROTECTED]) ==> 'ARRAY'
ref(\$foo) ==> 'SCALAR'
ref(\%foo) ==> 'HASH'
ref("foo") ==> ''

perldoc -f ref
for more information

Paul Lalli


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to