On Thu, Feb 07, 2002 at 07:09:48PM +0000, Gavin McCullagh wrote:
? my @friends = qw(Peter Paul Mary Jim Tim);
? (my $this,my $that) = shift2(@friends);
You're passing the array to shift2 rather than a reference to the
array. shift2 ( \@friends ); will do what you want. As someone else
pointed out predeclaring the functions will solve the problem because
perl then knows to pass a reference rather than the array.
? sub shift2 (\@) {
? return splice(@{$_[0]}, 0, 2);
? }
Down here $_ [0] == "Peter", rather than a reference to @friends.
? Gavin
--
John
"That would preempt a bunch of problems involved in trying to reconstruct
exactly how the Perl 5 parser thinks, which nobody entirely understands."
Larry Wall, 2001/04/20, perl6-language at perl.org
"Finger to spiritual emptiness underlying everything." -- How a Japanese C
manual referred to a "pointer to void".
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!