José nyimi wrote:
> 
> Hello All,

Hello,

> The Perl slogan is: "There Is More Than One Way To Do It".
> 
> I'm interested to see how you will do the small convertion below.
> 
> Here is one of mine: probably not the best one :-).
> 
> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> my $out=&convert('abCdE');
> print "$out\n";
> 
> sub convert {
>  my($in)=@_;
>  $in=~/(.)(.*)/;
>  $in=uc($1).lc($2);

You should _never_ use the numeric scalars $1, $2, etc. without testing
that the regular expression was successful.

$ perl -le'
$_ = q(abCdE);
/(.)(.*)/;   print "$1 $2";
$_ = "\n";
/(.)(.*)/;   print "$1 $2";
'
a bCdE
a bCdE


>  return $in;
> }
> 
> The task is simply to upercase the first char of a given string and lowercase the 
>rest.

my $out = 'abCdE';

$out = "\u\L$out";



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to