in reply to How can I use the values which is passed as arguments?

If you are not sure how parameters are passed in and out of a subroutine, you should definitely shy away from prototypes.

perldoc perlsub says:

The Perl model for function call and return values is simple: all functions are passed as parameters one single flat list of scalars, and all functions likewise return to their caller one single flat list of scalars. Any arrays or hashes in these call and return lists will collapse, losing their identities--but you may always use pass-by-reference instead to avoid this. Both call and return lists may contain as many or as few scalar elements as you'd like.
It is customary to pick up the parameters (which are in the @_ array) as the first instruction inside the sub as follows:
sub fun { my ($first, $second, $third) = @_; }
or, if you do not know how many parameters will be passed:
sub fun { my @parameters = @_; }
You can work directly with the @_ array but as its values are an alias to the paramaters passed in, you could unwillingly be changing the original variables and cause some subtle and difficult to trace bugs.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^2: How can I use the values which is passed as arguments?
by anbutechie (Sexton) on Mar 10, 2009 at 07:47 UTC
    Thank you very much for your responce,
    Subroutine definition : sub func(\$@$)
    Subroutine call is : func($a, @b, Sc)
    In this case, how can I get the parameters by the statement
    ($first, $second, $thrid)=@_
    regards,
    Anbarasu

      subroutine prototypes in Perl are much discussed because generally using them is a bad idea. For a recent discussion see subroutine prototypes still bad?.

      The bottom line is: don't do that. And a follow up line is: Always use strictures (use strict; use warnings;).

      Instead of using prototypes consider:

      use strict; use warnings; my $str = 'Welcome'; my @array = qw(to the world of); serious ($str, \@array, 'Perl'); sub serious { my ($str, $arrayRef, $constStr) = @_; print join (' ', $str, @$arrayRef, $constStr), ".\n"; }

      Prints:

      Welcome to the world of Perl.

      True laziness is hard work
        Thank you, I got the solution
        Anbarasu