in reply to
How to change an xterm title on the fly
Of course one could push it further and make the xterm title display the current path. Actually this is no perl code but I really don't see the need for perl here.
# The Prompt
case $TERM in
export PS1 PS2
(to put into your ~/.bashrc - yeah, we're really OT here ;-)
you begin bashing the string with a +42 regexp of confusion