dragonchild has asked for the wisdom of the Perl Monks concerning the following question:

I know that doing "use overload (<>) { ... };" will allow you to treat a given object as a descriptor to read from, but how can you do that for writing?
  • Comment on Creating a class that acts as a descriptor

Replies are listed 'Best First'.
Re: Creating a class that acts as a descriptor
by bikeNomad (Priest) on Jun 29, 2001 at 23:14 UTC
    Why not just tie it to a handle?

    See Tie::Handle, specifically Tie::StdHandle for an easy way. You don't have to overload <> to do this, either.

Re: Creating a class that acts as a descriptor
by japhy (Canon) on Jun 30, 2001 at 00:24 UTC
    Make a print method for it.
    package CanPrint; sub new { ... } sub print { ... } package main; my $x = CanPrint->new; print $x "this\n"; # like $x->print("this\n");


    japhy -- Perl and Regex Hacker