azadian has asked for the wisdom of the Perl Monks concerning the following question:

perl -MIO::Prompter -e '$ret = prompt -num,"number:" ; prompt -num,-de +f=>$ret, "another:"'
IO::Prompter returns an object which gets auto-stringified, except when it doesn't...

How can I explicitly extract the string/number from the object?

Replies are listed 'Best First'.
Re: IO::Prompter return object
by TheDamian (Vicar) on Feb 18, 2026 at 08:59 UTC
    Alternatively, add the -v option:

    perl -MIO::Prompter -e '$ret = prompt -v, -num,"number:" ; prompt -num,-def=>$ret, "another:"'

Re: IO::Prompter return object
by ikegami (Patriarch) on Feb 17, 2026 at 21:56 UTC

    You can force stringification using "$ret", if that's what you're asking.

      Apparently not, as I'm using $ret in the second call to prompt, which crashes.

      Update:

      Ah, so I need the quotes. Thanks.



      Original content restored by janitors.

        Update: You have materially changed the post to which this post replies, that's not cool. See How do I change/delete my post?.

        As ikegami said, you need to wrap the scalar in double quotes to explicitly force stringification. Literally "$ret".

        $ perl -MIO::Prompter -e '$ret = prompt -num,"number:" ; prompt -num,- +def=>"$ret", "another:"' number: 42 another: 43


        The way forward always starts with a minimal test.