In the Perl script, I want to invite the user to enter and offer him an editable default value. So far I have this:
#!/usr/bin/perl print "what your name? [John Doe]: "; $name = <STDIN>; chomp $name; if (!$name) { $name = "John Doe"; } print "hello $name.\n";
What I'm looking for is a solution where I can have "John Doe" on STDIN before the user starts typing. Thus, this is a practically editable input by default. For instance. the user can press backspace 3x and then enter “Wayne” to get “John Wayne” rather than entering the entire string “John Wayne” from the beginning. I tried typing on STDIN , but that didn't work.
source share