iariza has asked for the wisdom of the Perl Monks concerning the following question:

Hi! I get the next error when trying to test my funtion "create_profile()":

Too many arguments for EDSTools::create_profile at tools-test "$profile_ref ) " Execution of tools-test.pl aborted due to compilation errors.

Function Call:
create_profile( $dbh, $profile_ref )
Hash Ref:
my $profile_ref ={ PROFILE_NAME => "test_profile", SESSIONS_PER_USER => "1", CPU_PER_SESSION => "DEFAULT", PRIVATE_SGA => "UNLIMITED", PASSWORD_LIFE_TIME => "90" };
Function Definition (first lines):
sub create_profile() { my ($dbh, $profile_specs_ref) = @_; my ($sql, $key, $value); my %profile_specs = %{$profile_specs_ref};
... What's wrong? What am I missing? Thanks in advance for your assitance.

Replies are listed 'Best First'.
Re: Can't pass a hash ref to a a subroutine
by Zaxo (Archbishop) on Sep 14, 2004 at 23:43 UTC

    You have given create_profile a prototype which demands it take no arguments. Remove the empty parens and the error will go away.

    sub create_profile { my ($dbh, $profile_specs_ref) = @_; # . . . }

    After Compline,
    Zaxo

Re: Can't pass a hash ref to a a subroutine
by mifflin (Curate) on Sep 14, 2004 at 23:45 UTC
    the definition of your create_profile sub has an empty prototype that says this sub should have no arguments. Get rid of the prototype.
Re: Can't pass a hash ref to a a subroutine
by sintadil (Pilgrim) on Sep 14, 2004 at 23:46 UTC

    my $profile_ref ={

    As was recently stated1 in a previous episode of SoPW, constructing hash references is done with {}s.

    Also, as per Zaxo's and Mifflin's suggestion, remove the prototype. Even if you think it's not directly related, remove it.

    ----

    1 I really should be more careful with my reading. I guess spending 6 hours on PM researching testing practises was bound to cause a silly mistake.