http://qs1969.pair.com?node_id=45363


in reply to More than one way to do it???

An immediate improvement that springs to mind is in the regex - change it to simply remove the '/dev/' at the beginning of the string:
perl -we '$tty=qx(tty);$tty=~s!^/dev/!!;print $tty'