On Jul 11, rory oconnor said: >Is it possible to pass a hash into a subroutine to be used as a local >variable? I'm trying to do this:
The arguments sent to a function are flattened into one big list. There's no way to know where your array ends and your hash begins. Furthermore, doing $x = 1; @y = (2,3); %z = (4 => 5); ($a, @b, %c) = ($x, @y, %z); stores 1 in $a, (2, 3, 4, 5) in @b, and nothing in %c. You'll need to send REFERENCES. >($rows, %results) = &Select($mytable, $where_f1, $compare1, $where_v1, >@quick_check, %field_values); > >sub Select { >my($db_table, $where_field, $comparison, $where_value,@fieldlist, >%values) = @_; > >..... > >return $rc, %table; >} ($rows, %results) = Select( $mytable, $where_f1, $compare1, $where_v1, \@quick, \%field ); sub Select { my ($db, $where_field, $comp, $where_value, $flref, $vref) = @_; my @fieldlist = @$flref; my %values = %$vref; ... return $rc, %table; } Or, instead of doing the @$flref and %$vref thing, you can use the references directly in the function. Instead of $fieldlist[$i], you would use $flref->[$i]; instead of $values{key}, you would use $vref->{key}. And you might want to return a reference to the hash instead of the hash itself. Just an idea. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]