Re: [Templates] constructing named parameters for subroutines

[prev] [thread] [next] [Date index for 2004/05/17]

From: merlyn (Randal L. Schwartz)
Subject: Re: [Templates] constructing named parameters for subroutines
Date: 14:55 on 17 May 2004
>>>>> "Matthias" == Matthias Dillier <Matthias.Dillier@xxx.xx> writes:

Matthias> [%
Matthias> value1=1
Matthias> value2="xxx"
Matthias> test = mysubroutine(param1 => value1, param2 => value2)
Matthias> %]

This is untested, but named parameters are merely passed as a hashref
as the last element in the list.  So, you should be able to simulate
that example with:

    myhash = {};
    myhash.value1 = 1;
    myhash.value2 = "xxx";
    test = mysubroutine(myhash);

with no difference perceptible to the subroutine.  If I'm wrong,
someone will correct me. :)

        -- 
        Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@xxxxxxxxxx.xxx> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

Re: [Templates] constructing named parameters for subroutines
merlyn (Randal L. Schwartz) 14:55 on 17 May 2004

Generated at 08:56 on 15 Mar 2005 by mariachi v0.52