[EMAIL PROTECTED] wrote:
> OK here comes the newbie question.
>
> I found this in a template for creating subroutines, this is the base
> that is created when you use the template to create the subroutine.
>
> So now the newbie part, why would you place "my $par1 = shift;" in
> the subroutine template, and what does it do??
>
> Basically I am trying to find out if I need to modify the template or
> not. Any help would be greatly appreciated.
>
> Oh and btw I looked at the shift function and it applies to the @_
> array, which is not being used in this subroutine, and neither is
> @par1 , so my only guess would be that the template is creating a
> verifiably empty variable called $par1 .
>
>
>
> sub Irfan
> {
> my $par1 = shift;
>
> return ;
> } # ---------- end of subroutine Irfan ----------
@_ holds the actual arguments passed to the subroutine call.
So if you call the sub as:
Irfan('foo');
Then inside the sub:
my $par1 = shift;
will assign the first argument ('foo'), to $par1
This is a very common idiom.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>