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

Dear Monks,

Could you help me:
I wanna put some default text to STDIN which is "editable". There should be something like this:

>$\HEAD\some_dir_from_a_scalar_value

where the red text is just a prompt, and the rest is the default input text, which one should be editable by the user

Thanks: Vasek

Replies are listed 'Best First'.
Re: Writing to STDIN
by almut (Canon) on Dec 19, 2009 at 13:38 UTC

    In case you have Term::ReadLine::Gnu installed, you can do:

    #!/usr/bin/perl use Term::ReadLine; my $term = new Term::ReadLine 'Demo'; my $prompt = '$\\HEAD\\'; my $dir = "foo/bar"; # user-editable default input my $user_input = $term->readline($prompt, $dir); print "user_input: $user_input\n";

    (BTW, what you refer to as STDIN is usually called the terminal/console's prompt, strictly speaking...)