in reply to Re^2: Passing entered value into sub for IO::Prompt
in thread Passing entered value into sub for IO::Prompt

Use:

sub CheckDate { my $date = $_; print "Date: $date\n"; return true; }

and \&CheckDate(), in the -require.

Note that the parameter list to prompt is built when the call to prompt is executed, but that the context that CheckDate is called from is way down in the processing of prompt somewhere. During the parameter processing part of the call to prompt the only thing of interest is the reference to the sub to be called.


Perl is environmentally friendly - it saves trees

Replies are listed 'Best First'.
Re^4: Passing entered value into sub for IO::Prompt
by bowei_99 (Friar) on May 28, 2008 at 01:34 UTC
    I do that, and running the script jumps straight to the subroutine, even before a prompt, where there is nothing entered. Then the prompt follows and doesn't take a valid date. I get:
    $ ./pad_track.pl Date: Enter the day for this event, in format Must be in the format (two digits per value) of MM/DD/YY:

    -- Burvil