http://qs321.pair.com?node_id=73658


in reply to Dereference an array reference

I would like to put either $_ or $name at the end of the query string but I keep getting an array reference.

Sorry about that. I should have written that when I try to view the concatenated SQL query, the $thangsname is missing, because it's an array reference

Replies are listed 'Best First'.
Re: Re: Dereference an array reference
by suaveant (Parson) on Apr 19, 2001 at 18:05 UTC
    You mean the name of the array? Or a value within the array?
                    - Ant
      I am trying to create a new object and fill its name property with a value from the array/list.(I really don't know anymore) The name is actually supposed to be a database-wide key. I want to extract the information from the database and put it into the object.

      Here's the story that I didn't want to bore anyone with.

      When an "extract" is performed here at present, they perform too many steps. (create temp table in database, populate temp table, use "DataJunction" to export temp table info to file, clean up database)

      My idea was since they are using Perl already to parse data from outside sources, we could use Perl to do the "extracts." Perl would be perfect for that.

      Since the Product that I support will be going away (we hope), and changing to an OO thing, Ifigured that we could use OO in Perl to do "extracts" and the converse which is "Loads." This way our objects could WDDX all their information over to the new objects. Also the database would be left alone to do what it does best.

      My "extract" object gets the database-wide key, and creates a "profile" object that contains all the fields from the database. This is exactly what I wanted. This is exactly what I want because we can take the "profile" and write it to the database or the WDDX or a file and it can be populated from any source like the database, or WDDX or a file.

      If you are still awake, here is where I am slightly stuck. My "extract" opens all the proper files, and retrieves the database-wide key according to the proper parameters. Now I need to take this list(extract_object->list_of_database_wide_keys) and create a "profile" object for each one and then write it to the files.

      I keeping getting a SQL statement like "select * from table where database_wide_key = ARRAY(XXXXXXXX)"
      I just don't know how to properly dereference that array reference. I've gotten SQL errors like cant convert CHAR 'ARRAY(XXXXXXX)' to INT4 field.

      My forehead is flatter and embedded with small shards of busted monitor.

        Ahhh! To dereference an array ref, you can do the following @{$ref} or to get individual numbered elements do $ref->[0] $ref->[3] whatever the index is. So if your name is the first element in the arrayref $name, you would get it by doing $name->[0]

        is that more what you were looking for?
                        - Ant