UnevenGuy has asked for the wisdom of the Perl Monks concerning the following question:

I'm printing a line with some text, then a variable, then some text with a capital U with no spaces between the variable and the capital U. it looks like

print "Something$variable\Unselected.gif";

but this makes everything after the \U in caps. The only solution I came up with to do this is by using a \E to separate the variable like this

print "Something$variable\EUnselected.gif";

is there a better way I should be using to do this while maintaining the capitalization I want? Thanks for the help!

Replies are listed 'Best First'.
Re: Escaping \U
by Athanasius (Archbishop) on Nov 26, 2016 at 07:42 UTC

    Hello UnevenGuy, and welcome to the Monastery!

    Just put the variable name (but not the sigil) into curly brackets:

    17:39 >perl -wE "my $variable = 'abc'; say qq[Something${variable}Unse +lected.gif];" SomethingabcUnselected.gif 17:40 >

    Hope that helps,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Re: Escaping \U
by Corion (Patriarch) on Nov 26, 2016 at 08:23 UTC

    If you don't want a \U there, don't put it there?

    print "Something$variable\\Unselected.gif";

    Or maybe you don't want the backslash there?

    print "Something{$variable}Unselected.gif";

    I'm unclear on what your goal is...