Understand::Gui::selection()
Returns the selected text in the current file being edited. Returns 0 (zero) if no file is being edited or no text is selected.
my $selection = Understand::Gui::selection();