in reply to adding default text to STDIN

Look at something like Term::ReadLine. Or just print the current value in the prompt (print "$property [$record->{$property}]: ") and if $response eq '' ignore it (of course this prevents the user from actually providing a value of "nothing", but for most applications it's probably fine).

Replies are listed 'Best First'.
Re^2: adding default text to STDIN
by bangers (Pilgrim) on Nov 09, 2005 at 18:05 UTC
    Thanks a lot for your help. I used Term::ReadLine and got it working. I found the documentation a little lacking and it took me a little while to get it to work, so for everyone's future reference here is how I got it to work:
    use Term::ReadLine; my $record = { name => ‘joe bloogs’, age => 34, hobby => ‘chess’, }; my $term-> new Term::ReadLine 'user input'; for my $property ( keys %$record ) { my $response = $term->readline($property,$record->{$property}); $record->{$property} = $response; }
    I know that looks - and is - simple but it took a while for me to find the right call. Thanks again for your help