in reply to Re: TAB character as literal in editable prompt
in thread TAB character as literal in editable prompt

Hi TJPride,

It works. Using Term::ReadLine, the first regular expression is unnecessary. This package appears to escape '\' characters as they are input without disturbing the rest of the string. I know this because the first version (which pre-escaped the TABs) also worked.

I now have:

#!/usr/bin/perl use File::Basename; use Term::ReadLine; my $inFile = $ARGV[0]; die "no inFile" unless $ARGV[0]; open (my $in, "<", $inFile) or die "Can't open $inFile for reading."; my $term = new Term::ReadLine(basename($0)); while(my $before = <$in>) { chomp($before); my $after = $before; # Not needed, unless you want to see the escapes. # $after =~ s/\t/\\t/g; for (;;) { print "BEFORE: $before\n"; $after = $term->readline("AFTER: ", $after); my $ans = $term->readline("Accept? (y/n) -> ", "y"); if ( $ans =~ /^[Yy]/ ) { $after =~ s/\\t/\t/g; print "AFTER: $after\n\n"; last; } } }

Thanks!

Larry