{ my $hypertext_tag_name = 't000000'; # candidate for 'static' # returns the tag name, in case there's anytyhing else # you'd like to do with it. sub Tk_Text_insert_active_text { my( $Text, $linktext, %callbacks ) = @_; my $start_index = $Text->index( 'insert' ); $Text->insert( insert => $linktext ); my $end_index = $Text->index( 'insert' ); my $link_tag_name = ++$hypertext_tag_name; $Text->tagAdd( $link_tag_name, $start_index, $end_index ); $Text->tagConfigure( $link_tag_name, -foreground => 'blue', -underline => 1 ); $Text->tagBind( $link_tag_name, $_ => $callbacks{$_} ) for keys %callbacks; $link_tag_name } } # Example: make a real link: sub Tk_Text_insert_hyperlink { my( $Text, $url, $title ) = @_; Tk_Text_insert_active_text( $Text, $title, '' => sub { system $url }, # launch in system browser '' => sub { set_status_bar($url) }, '' => sub { set_status_bar('') }, ); }