print, put, say and escape characters

FWIW, I see "del" in both cases, regardless of using print or put, so maybe there is some terminal setting that is affecting the behaviour?

The \b\b only become obvious when you actually put characters after them:

say "del\b\bo the right thing"  # do the right thing

\b only moves the cursor back one position. It does not erase anything by itself. If you want the characters erase, you'd have to have them followed by spaces, and then backspace again if you want any text after that again:

print "del\b\b  \b\b"           # d

To see what's being output, without possible confusion of what the terminal might be doing, you can pipe through xxd (or od)

$ perl6 -e 'say "del\b\b"' | xxd
00000000: 6465 6c08 080a                           del...
$ perl6 -e 'print "del\b\b"' | xxd
00000000: 6465 6c08 08                             del..
$ perl6 -e 'put "del\b\b"' | xxd
00000000: 6465 6c08 080a                           del...

Tags:

String

Raku