LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   perl (https://www.linuxquestions.org/questions/linux-newbie-8/perl-4175421530/)

mailmerohit1988 08-11-2012 01:44 AM

perl
 
hie friends

can any1 please tel me the meaning of this line and why is it required

my ($filename) = @_;

thanks

ne pas 08-11-2012 03:24 AM

quoting perldoc perlvar
@ARG
@_

Within a subroutine the array @_ contains the parameters passed to that subroutine. Inside a subroutine, @_ is the default array for the array operators push, pop, shift, and unshift.

See perlsub.
Example:
Code:

my($one, $three, $five) = (1, 3, 5);

print_values($one, $three, $five);

sub print_values {
    my(@values) = @_;    # subroutine argument list

    foreach my $val (@values) {
        print "${val}\n";
    }
}



All times are GMT -5. The time now is 07:03 AM.