On Fri, Jan 03, 2003 at 06:32:10PM -0800, John W. Krahn wrote:
> Paul Johnson wrote:
> >
> > On Fri, Jan 03, 2003 at 03:33:30PM -0800, John W. Krahn wrote:
> > > Paul Kraus wrote:
> > > >
> > > > Ok a couple questions on Ref from pg 251 programming Perl.
> > > >
> > > > push @$arrrayref,$filename);
> > > > $$arrayref[0]="January";
> > > > @$arrayref[4..6]=qw/May June July/;
> > > >
> > > > So this is actually creating an anonymous array that it then references
> > > > correct?
> > > > so the assignments January ect are being made to an anonymous array.
> > >
> > > No, an anonymous array is delimited by [ and ]. That is creating an
> > > actual array that is only accessible through an array reference.
> > >
> > > my $ref = [ 1, 2, 3, 4, 5 ];
> > > ^^^^^^^^^^^^^^^^^
> > > anonymous array
> >
> > Not worth picking a fight over, to be sure, but I don't see the
> > difference. Assuming $arrayref didn't exist before, then after each of
> > those three examples it will, and it will be a reference to an array
> > with no name. Seems to me that Paul got it spot on.
>
> You are saying that it has no name but it does: arrayref. If it truly
> had "no name" then there would be no way to access it anywhere else in
> the program.
I am saying that an anonymous array has no name, but it can be accessed
via a reference to it.
I am also saying is that there is no practical difference between
$ perl -MData::Dumper -e '$aref = [1, 2, 3]; print Dumper $aref'
$VAR1 = [
1,
2,
3
];
and
$ perl -MData::Dumper -e '@$aref = (1, 2, 3); print Dumper $aref'
$VAR1 = [
1,
2,
3
];
In each case the array is anonymous and can only be accessed via $aref,
which is a scalar reference to that array.
--
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]