in reply to Help with argument to a subroutine
Perl passes a list of copies of things to a subroutine in the special array @_.
There are a couple of things to note here. First off a list is passed, always. It may be empty (@_ == 0) or contain a single item (@_ == 1), but it is still a list and is passed in @_. So the answer to your question is $_[0] or my $headerCopy = shift; (which removes the item from @_), or some similar construct.
The other thing to notice thought is that Perl passes a copy of the original string. If you wanted to update the original string then you have either to assign a new (returned) version of the string back into the variable ($header = parse_header ($header);) or pass the string by reference (parse_header (\$header);).
However, in most things Perlish, it pays to let other people do the work. In this case you should take a look at MIME::Tools and MIME::Parser in particular.
Update: Struck stuff was just plain wrong! @_ contains aliases to the parameters so changing the contents of the elements of @_ changes the matching actual parameter.
|
|---|