use IO::Interactive qw( interactive ); # and later... print {interactive} $PROMPT;