Unexplained behavior with signal_connect and references



Best way to explain this is with the code. It's simple, and might simply be
a bug somewhere, or maybe I'm not understanding somthing about references.

my $topwin; #the main window
my $name = "foobar"; #it's name

init Gnome $name ;

SetTopWin (\$topwin, $name);
show_all $topwin;
main Gtk;

sub SetTopWin
        {
                my ($app ,$name) = @_; #reference to top window, and it's
name              
                $$app = new Gnome::App $name, $name;

                signal_connect $$app 'delete_event', sub { Gtk->main_quit;
return 0 };
        }

So, up pops a nice little window that doesn't do much, but perl does exit
when I press the close button. The odd bit is, when I run it, I also get
this error message in my console:

String found where operator expected at ./fstabconf.pl line 22, near "$app
'delete_event'"
        (Missing operator before 'delete_event'?)

So, what is it that's going wrong here? If it's me, how do I fix it? It
doesn't stop the code from running, but it's annoying to have any warning
messages at all.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]