Re: "\!" appears on new line



this one finally worked! thanks you two!

#! c:\perl
my $input;
print "Enter a phrase and convert the first letter to upper case and
add a ! at end: ";
chomp( $input = <STDIN> );
my $firststinput = ucfirst( $input );
print $firststinput, "\!", "\n";


On Oct 10, 9:53 am, April <xiaoxia20...@xxxxxxxxx> wrote:
thanks, however after the recommended change the script hangs
forllowing keyboard entry:

#! c:\perl
print "Enter a phrase and convert the first letter to upper case and
add a ! at end: ";
my $input = <STDIN>;
chomp( $input = <STDIN> );
my $firststinput = ucfirst($input);
print $firststinput, substr($input, 1), "\!", "\n";

C:\Perl\Exercise1>perl new3-6d.pl
Enter a phrase and convert the first letter to upper case and add a !
at end: thank you

On Oct 10, 9:42 am, Peter Makholm <pe...@xxxxxxxxxxx> wrote:



April <xiaoxia20...@xxxxxxxxx> writes:
print "Enter a phrase and convert the first letter to upper case and
add a ! at end: ";
my $input = <STDIN>;

Here you string will have an newline at the end. You'll have to chomp it.

my $firststinput = uc( substr($input, 0, 1) );
print $firststinput, substr($input, 1), "\!", "\n";

Uhmmm, and use ucfirst if that is what you need to do.

//Makholm- Hide quoted text -

- Show quoted text -

.



Relevant Pages

  • Re: "!" appears on new line
    ... this is more concise: ... print "Enter a phrase and convert the first letter to upper case and ...
    (comp.lang.perl.misc)
  • Re: "!" appears on new line
    ... Enter a phrase and convert the first letter to upper case and add a! ...
    (comp.lang.perl.misc)
  • Re: "!" appears on new line
    ... print "Enter a phrase and convert the first letter to upper case and add a! ... can special-order certain sorts of tools at low cost and ...
    (comp.lang.perl.misc)
  • Re: "!" appears on new line
    ... print "Enter a phrase and convert the first letter to upper case and add ...
    (comp.lang.perl.misc)
  • Re: Upper Case on second thought
    ... I want to force upper case just for the first letter in each word. ... do this in either the table design/format field or in the append query. ... What is the expression (like ">" that forces capitalization) to forced ...
    (microsoft.public.access.tablesdbdesign)