blueflashlight has asked for the wisdom of the Perl Monks concerning the following question:
The above code works perfectly (and is basically no more than what merlyn spoon-fed me.)#!/usr/bin/perl -w use strict; package TieTimeScalar; sub TIESCALAR { bless {}, shift } sub FETCH { scalar localtime } package main; my $now; tie ($now, "TieTimeScalar"); while (1) { print "$now\n"; sleep 1 }
... I get the error ...#!/usr/bin/perl -w use strict; package TieTimeArray; sub TIEARRAY { bless {}, shift } sub FETCH { my @self = localtime ; return @self } sub FETCHSIZE { my $self = shift ; return scalar @{$self->{@self}} } package main; my @now; tie (@now, "TieTimeArray"); while (1) { print "@now\n"; sleep 1 }
Obviously, I'm missing something fundamental to the concept of tying arrays (and probably just tying in general.)Can't use an undefined value as an ARRAY reference at ./TieTimeArray l +ine 8.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: more on tying localtime
by stefp (Vicar) on Sep 28, 2001 at 05:40 UTC | |
by blueflashlight (Pilgrim) on Oct 02, 2001 at 07:16 UTC | |
Re: more on tying localtime
by jryan (Vicar) on Sep 28, 2001 at 05:44 UTC | |
by stefp (Vicar) on Sep 28, 2001 at 06:01 UTC | |
by jryan (Vicar) on Sep 28, 2001 at 06:46 UTC |