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

hi i'm actually still new with perl. So, could somebody try to to xplain me how this code works

$fungsi1 = $query->param('fungsi1');

2005-09-26 Retitled by holli, as per Monastery guidelines
Original title: 'working with database'

Replies are listed 'Best First'.
Re: What does $query->param() do?
by monarch (Priest) on Sep 26, 2005 at 01:38 UTC
    The odds are good that this is code from a module that has, somewhere, the line use CGI;.. check out the documentation on the CGI module. If this is the case, and $query is a CGI object (look for my $query = new CGI; or something similar in your code) then this line is taking a web form parameter called 'fungsi1'.

    Of course I could be wrong..

Re: What does $query->param() do?
by jZed (Prior) on Sep 26, 2005 at 03:28 UTC
    Without further context, monarch's guess is a good one. About all that can be said with certainty is that the snippet you provided follows this general format:
    $variable = $object->method(parameter);
    In other words, you are running the method called param() of the object called $query using the parameter named 'fungsi1' and assigning the results to the variable called $fungsi1.
Re: What does $query->param() do?
by davidrw (Prior) on Sep 26, 2005 at 02:20 UTC
    If you need to work with a database and you were hoping that that's what "query" here meant (as opposed to probably being CGI-related as monarch suggester), then take a look at the Tutorials in the database section (especially Before asking a database related question ...)
Re: What does $query->param() do?
by pg (Canon) on Sep 26, 2005 at 03:09 UTC

    There are a few ways to explain this, as you didn't provide much detail. One short example could be:

    use CGI; use strict; use warnings; my $query = new CGI({fungsil=>"123", foo=>"bar"}); print $query->param('fungsil'), "\n"; print $query->param('foo');

    This will print:

    123 #the value for parameter fungsil bar