in reply to (jeffa) Re: How to open sub FH when filename is passed to sub?
in thread How to open sub FH when filename is passed to sub?


Thank you for your help jeffa!


I am a beginner for perl. My new hash keys I can read in
from a file, but my values I have to get them from my main
hash.Why you use shift? Does it mean it can change
different filename everytime you call sub? if it is so,
that is what I want.
Please help

  • Comment on Re: (jeffa) Re: How to open sub FH when filename is passed to sub?

Replies are listed 'Best First'.
More than you ever wanted to know about shift @_
by jeffa (Bishop) on May 05, 2002 at 16:56 UTC
    You are most welcome. Yes, that is exactly why i use shift. shift returns the first value from an array, in this case it is the implied array @_ which is used by Perl to store the arguments passed to a given subroutine. I could have used this instead:
    my $filename = shift @_; # or even my ($filename) = @_; # multiple arguments are best caught this way: my ($first,$second,$third) = @_; # but some folks prefer my $first = shift; my $second = shift; my $third = shift;
    Most (if not all...) other languages use an argument list to specify what a subroutine can be 'passed', as well as a return type (together these form the 'signature'). For example, in Java, these: