Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: A question of logic and syntax

by Trinary (Pilgrim)
on Apr 27, 2001 at 22:20 UTC ( [id://76204]=note: print w/replies, xml ) Need Help??


in reply to A question of logic and syntax

$lastname = ucfirst ($lastname) if ($lastname =~ /^[a-z]/);

as far as the telephone number thing, it depends on how many formats you need to handle (international numbers, etc) Just choose a set of standards and enforce 'em, for example US numbers all look like (123) 456-7890.

So remove whitespace, check for 3 in parens, 3 outside, dash, then 4. If not, check to see if there is the correct number of digits, and if so, split em up and add the extra punctuation yourself. You just need to adopt a similar standard for any number format you might be handling (and extend the US one for extensions, etc).

Trinary

Replies are listed 'Best First'.
Re: Re: A question of logic and syntax
by little (Curate) on Apr 27, 2001 at 22:37 UTC
    ok, but the world is bigger then the US, so betetr get used to the format +CC -AC -number -ext, where the plus implies the numbers you have to dial for international calls which you can ommit if you make an national call, CC is the country code, AC the Area code and the number is the number itself and ext an optional extension.
    If you apply that scheme you don't have to redefine your DB, modify your .ini sections or worst case to rewrite your code all times you have people from other countries. And US and CAnada schemes might be pretty similar but they are not equal, so better take an open format.
    You might also consider to include something alike a code you have to dial before the area code if you make a national call, eg. +CC -(n)AC -number -ext.

    Have a nice day
    All decision is left to your taste
Re: Re: A question of logic and syntax
by Rhandom (Curate) on Apr 27, 2001 at 22:57 UTC
    A little faster. To see how much (quite a bit) you might want to try Benchmark.pm:

    $lastname =~ s/^([a-z])/\u$1/;


    Or if you want a cool one that will init cap an entire string (but without the eval overhead of ucfirst):
    $txt =~ s/\b(\w+)/\u\L$1/g;


    my @a=qw(random brilliant braindead); print $a[rand(@a)];

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://76204]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-26 03:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found