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

Hey monks. I'm having a few problems with my latest project, thanks to pg for all the help, which is here. But i'm getting stuck here.
my $widget = $text2->Subwidget("text") ; tie *STDOUT, ref $widget, $widget;
Now I've never used this kind of code before I got it from the example included in the Module Crypt::CBC. Now from this piece of code Perl produces the error:
Tk::Error: Can't locate object method "TIEHANDLE" via package "" at cb +c.pl line 162.
Now I'm not to sure what this means, and also what is the package that it refers to
via package ""
. I would greatly appreiciate any help you can give as I'm beagáiní confused.

All the Best, Eoin...

If everything seems to be going well, you obviously don't know what the hell is going on.

Edit by tye, change PRE to CODE around long line

Replies are listed 'Best First'.
Re: object method "TIEHANDLE"
by bbfu (Curate) on Oct 21, 2003 at 21:44 UTC

    The problem is that your $text2 widget is actually a Scrolled('TextUndo'), but you're trying to find the Text subwidget. You need to ask for the TextUndo subwidget, like so:

    #!/usr/bin/perl use warnings; use strict; use Tk; use Tk::TextUndo; my $mw = MainWindow->new(); my $text = $mw->Scrolled('TextUndo')->pack; tie *STDOUT, ref($text->Subwidget('textundo')), $text; print "Hello, world.\n"; MainLoop;

    bbfu
    Black flowers blossom
    Fearless on my breath

Re: object method "TIEHANDLE"
by liz (Monsignor) on Oct 21, 2003 at 20:45 UTC
    You're trying to tie a handle to a class named '' (empty string).

    What does this print?

    print ref $widget;
    I bet it doesn't print anything.

    The second parameter to tie() needs to be the name of the package that should exist.

    Hope this helps.

    Liz