Ask a Question related to PERL Beginners, Design and Development.
-
James Edward Gray II #1
Re: Case conversions
On Friday, August 15, 2003, at 04:20 PM, Scott Taylor wrote:
Maybe something like:>
> Any one have or know of a function to convert ugly "NAME, USER" to
> "User Name"?
s/^(\w+), ?(\w+)$/ucfirst(lc $2) . ' ' . ucfirst(lc $1)/e
Hope that helps.
James
James Edward Gray II Guest
-
Hebrew Calendar conversions?
Is there a Perl module for Hebrew->Gegorian and Gregorian->Hebrew date conversions? -- Shmuel (Seymour J.) Metz, SysProg and JOAT ... -
batch conversions
how can i use the automate function to convert a number of images from jpg to gif, and resize at 50% of the original? so that they are... -
#23026 [Com]: Make Zend case-sensitive (classes, functions, remove case-insensitive)
ID: 23026 Comment by: nvivo at mandic dot com dot br Reported By: mfischer@php.net Status: Open Bug Type: ... -
ASP/SQLServer character conversions
Hello, I have some rows in a table in a SQLServer database which contain some characters from the greek alphabet. The problem is they are not... -
Date conversions...
I'm creating a new database program, but I need to import some data from an old program (both Acc2000). Howerver, some of the dates stored in the... -
Elias Assmann #2
Re: Case conversions
On Fri, Aug 15, 2003 at 02:20:19PM -0700, Scott Taylor wrote:
$ perl -le '$_ = "NAME"; s/(.)(.*)/$1\L$2/; print'>
> Any one have or know of a function to convert ugly "NAME, USER" to "User
> Name"?
Name
The function to convert a string to lower case is "lc".
HTH,
Elias
--
If you take the fact that a cat always falls on his feets and a toast
always falls on the buttered side, what happens when you tie a toast
on the back of a cat and you throw him out the window?
Elias Assmann Guest
-
Didier Degey #3
RE: Case conversions
$var = 'NAME, USER';
print "$var\n";
@var = reverse split(', ',$var);
print "@var\n";
$var = join(' ',(ucfirst lc $var[0],ucfirst lc $var[1])); # whitout the
comma this time
print "$var\n";
-----Original Message-----
From: Scott Taylor [mailto:scott@dctchambers.com]
Sent: vendredi 15 août 2003 23:20
To: [email]beginners@perl.org[/email]
Subject: Case conversions
Any one have or know of a function to convert ugly "NAME, USER" to "User
Name"?
TIA
Scott.
--
To unsubscribe, e-mail: [email]beginners-unsubscribe@perl.org[/email]
For additional commands, e-mail: [email]beginners-help@perl.org[/email]
Didier Degey Guest
-
Mark Anderson #4
RE: Case conversions
Name"?> Any one have or know of a function to convert ugly "NAME, USER" to "User
timtowtdi:
$str = "User Name" if ($str eq "NAME, USER");
$str =~ s/^NAME, USER$/User Name/;
Mark Anderson Guest
-
Jerry Rocteur #5
Re: Case conversions
I've just used Elias' idea to change a file's content...
Where file name is word:
perl -i -p -e 's/(.)(.*)/$1\L$2/' word
On Friday, Aug 15, 2003, at 23:29 Europe/Brussels, Elias Assmann wrote:
> On Fri, Aug 15, 2003 at 02:20:19PM -0700, Scott Taylor wrote:>>>
>> Any one have or know of a function to convert ugly "NAME, USER" to
>> "User
>> Name"?
> $ perl -le '$_ = "NAME"; s/(.)(.*)/$1\L$2/; print'
> Name
>
> The function to convert a string to lower case is "lc".
>
> HTH,
>
> Elias
>
> --
> If you take the fact that a cat always falls on his feets and a toast
> always falls on the buttered side, what happens when you tie a toast
> on the back of a cat and you throw him out the window?
>
> --
> To unsubscribe, e-mail: [email]beginners-unsubscribe@perl.org[/email]
> For additional commands, e-mail: [email]beginners-help@perl.org[/email]
>Jerry Rocteur Guest
-
Scott Taylor #6
Re: Case conversions
At 02:28 PM 08/15/2003, James Edward Gray II wrote:
Nice, very useful! Only now I have a small problem with names like>On Friday, August 15, 2003, at 04:20 PM, Scott Taylor wrote:
>>>>
>>Any one have or know of a function to convert ugly "NAME, USER" to "User
>>Name"?
>Maybe something like:
>
>s/^(\w+), ?(\w+)$/ucfirst(lc $2) . ' ' . ucfirst(lc $1)/e
"O'CONNELL, BOB"
Scott Taylor Guest
-
James Edward Gray II #7
Re: Case conversions
On Friday, August 15, 2003, at 04:55 PM, Scott Taylor wrote:
Yes you do! :) The ' character isn't covered under my \w above. I'll> At 02:28 PM 08/15/2003, James Edward Gray II wrote:>>> On Friday, August 15, 2003, at 04:20 PM, Scott Taylor wrote:
>>>>>>>
>>> Any one have or know of a function to convert ugly "NAME, USER" to
>>> "User Name"?
>> Maybe something like:
>>
>> s/^(\w+), ?(\w+)$/ucfirst(lc $2) . ' ' . ucfirst(lc $1)/e
> Nice, very useful! Only now I have a small problem with names like
> "O'CONNELL, BOB"
switch it to a character class to show how to fix it, but you may need
to refine it a little further.
s/^([A-Z'] +), ?([A-Z']+)$/ucfirst(lc $2) . ' ' . ucfirst(lc $1)/e
Hope that helps.
James
James Edward Gray II Guest
-
Scott Taylor #8
RE: Case conversions
At 02:46 PM 08/15/2003, Degey, Didier wrote:
Strange email thingy you have, putting the reply inline with the original>-----Original Message-----
>From: Scott Taylor [mailto:scott@dctchambers.com]
>Sent: vendredi 15 août 2003 23:20
>To: [email]beginners@perl.org[/email]
>Subject: Case conversions
>
>Any one have or know of a function to convert ugly "NAME, USER" to "User
>Name"?
and forcing it to the top.
This works well, too, and join seems to fix the problem with names having>$var = 'NAME, USER';
>print "$var\n";
>@var = reverse split(', ',$var);
>print "@var\n";
>$var = join(' ',(ucfirst lc $var[0],ucfirst lc $var[1])); # whitout the
>comma this time
>print "$var\n";
"'"s in them.
Thanks.
Scott Taylor Guest
-
James Edward Gray II #9
Re: Case conversions
On Friday, August 15, 2003, at 05:09 PM, Scott Taylor wrote:
Na, it's the split() that fixed that. ;)>>> $var = 'NAME, USER';
>> print "$var\n";
>> @var = reverse split(', ',$var);
>> print "@var\n";
>> $var = join(' ',(ucfirst lc $var[0],ucfirst lc $var[1])); # whitout
>> the
>> comma this time
>> print "$var\n";
> This works well, too, and join seems to fix the problem with names
> having "'"s in them.
James
James Edward Gray II Guest



Reply With Quote

