$text->tag('bind','your-tag',''=>sub { my $var = $text->get($text->tagPrevrange('your-tag','current')); # and here do something with $var });