As choroba correctly mentioned, function calls don't interpolate inside of strings (at least not unless you resort to some ugly trickery). The far better approach is this:
print "Please enter your name:\n";
chomp( $name = <> );
$x = ucfirst $name;
If you have a good reason for not wanting to use ucfirst, then you do have alternatives:
# The \u metacharacter acts only upon the first character.
# No need for substr.
$x = "\u$name";
# Assuming Perl 5.14+
$x = $name =~ s/^(.)/\u$1/r;
$x = $name;
$x =~ s/^(.)/\u$1/;
But why isn't ucfirst available to you? Also, did you read through the code example I provided in my earlier Post? It should have made it reasonably clear that "\u$string" does what you want without resorting to using substr (unless we're not seeing some relevant code from you that would make this approach unsavory).
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||