[vox-tech] perl question - arrays and lists
Mike Simons
vox-tech@lists.lugod.org
Thu, 08 May 2003 16:20:40 -0400
--mmR5Tf+WJGm+vTLg
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Thu, May 08, 2003 at 01:12:43PM -0700, Peter Jay Salzman wrote:
> what i've found is that @barfoo is no longer an array of lists. the
> lists appear to be "flattened out".
Yes, they should be.
> i know that arrays can hold lists, but i must not be doing it correctly.
> do i need to do this with references?
Yes.
#! /usr/bin/perl -w
sub blah() {
return (["a", "b"], ["c", "d"]);
}
sub foo()
{
foreach (1..3)
{
push @array, ["a", "b"];
}
return @array;
}
@_ =3D foo;
foreach (@_) {
print "$_ -> @$_\n";
}
--=20
GPG key: http://simons-clan.com/~msimons/gpg/msimons.asc
Fingerprint: 524D A726 77CB 62C9 4D56 8109 E10C 249F B7FA ACBE
--mmR5Tf+WJGm+vTLg
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE+urwX4Qwkn7f6rL4RAjvKAJ9N6FsKq1VcZ2r6fLOCySF00SnfKACfZawm
XrAm7aIBeGz/G/GEB5y+FvY=
=CZZp
-----END PGP SIGNATURE-----
--mmR5Tf+WJGm+vTLg--