From James.FitzGibbon at target.com Thu May 2 16:57:26 2002 From: James.FitzGibbon at target.com (James.FitzGibbon) Date: Thu Aug 5 00:29:37 2004 Subject: [mplspm]: overloading <> Message-ID: Does anyone have experience overloading iterators? I'm having a hell of a time trying to create a subclass of IO::File. I started out with just getline overridden. That works fine for this: my $fh = new IO::File::Derived; while( $_ = $fh->getline ) { print; } But now I want to be able to do this for simplicity: my $fh = new IO::File::Derived; while( <$fh> ) { print; } When I overload <> to point to my class's getline method, I get stuck in a loop. The IO::File::Derived class does conditional evaluation of it's input, so several lines may be read from the file and discarded before a single line gets returned to the caller. As such, I need to call $self->SUPER::getline from inside of my getline method. The problem is that IO::Handle::getline does this: return scalar <$this> Which gets dispatched to my getline, which calls $self->SUPER::getline, which calls my getline ad infinitum. Any ideas? I'll refrain from posting the whole class unless someone wants to go over the details with me... Thanks. -- j. James FitzGibbon Consultant, Ajilon Services, TTS-3D@TPN4H james.fitzgibbon@target.com voice/fax 612-761-6121/4277 -------------------------------------------------- Minneapolis Perl Mongers mailing list To unsubscribe, send mail to majordomo@pm.org with "unsubscribe mpls" in the body of the message.