vladb has asked for the wisdom of the Perl Monks concerning the following question:
would return '\U' escape character. I may then use it (or so I hope to) to format any other string (either uppercase or lowercase it) by simply prepending the escape character in an expression like this:my $esc_char = get_escape_case("S");
In this example (where $esc_char is '\U') $case_formatted_string should become 'FOOBAR' (since "S" is in uppercase).my $case_formatted_string = $esc_char ."FoobAr";
I guess I might have to use a special 'code' for the escape character? Could anyone lead me in the right path? Thank you. ;-)use strict; # determine case of a character # and return appropriate 'control' code. sub get_escape_case { my ($char) = @_; if ($char eq "\U$char") { return '\U'; } else { return '\L'; } } # this wouldn't work... print get_escape_case("S")."stuff\n"; # while this works.. print "\Ustuff\n";
| "There is no system but GNU, and Linux is one of its kernels." -- Confession of Faith |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: case escape characters
by I0 (Priest) on Mar 02, 2002 at 05:13 UTC | |
by jeffa (Bishop) on Mar 02, 2002 at 13:51 UTC | |
|
Re: case escape characters
by synapse0 (Pilgrim) on Mar 02, 2002 at 03:40 UTC | |
by vladb (Vicar) on Mar 02, 2002 at 04:18 UTC |