in reply to Passing variables
To fix this, you could just print all of the remaining items in @_ inside writeFile, or else you could preserve @file's identity as a distinct list by passing it in as a reference:
Now, as far as writeFile is concerned, $_[1] contains a reference that points to all of @file, not just the first line. To use this correctly, you must also modify the print statement slightly:&writeFile("file.txt", \@file);
'@$_[1]' indicates that the program should access the array or '@' that '$_[1]' is a reference to. It can also be written as @{$_[1]}, if that helps.print FILE @$_[1];
See perldoc perlreftut for a references tutorial, not to mention the various O'Reilly books.
-- Frag.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Passing variables
by Stamp_Guy (Monk) on Jun 15, 2001 at 19:08 UTC |