[Chicago-talk] removing line from file.

Greg Fast gdf at speakeasy.net
Wed Mar 9 13:12:20 PST 2005


On Wed, 9 Mar 2005 14:42:37 -0600, Andy_Bach at wiwb.uscourts.gov wrote:
>      editors.  Each ".." operator maintains its own boolean
>      state.  It is false as long as its left operand is false.
 
Aw, nuts.  'perldoc overload' says ".." isn't overloadable...  I
wanted to see how the context was kicked around :)

Until looking, though, I didn't know that overloadable ops included
dereferencing ("${}", "@{}", etc).  Fun fun.

    package Foo;
    use overload '&{}' => \&do_sub;
    sub new {
      return bless { _s => ["hello, ","world","!"] }, shift;
    }
    sub do_sub {
      my $self = shift;
      my $s = shift( @{$self->{_s}} );
      push( @{$self->{_s}}, $s );
      return sub { print "$s" };
    }
    1;

    package main;
    my $f = Foo->new();
    $f->();
    $f->();
    $f->();



--
Greg Fast
http://cken.chi.groogroo.com/~gdf/


More information about the Chicago-talk mailing list