Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Counting number of characters in a string

by t0mas (Priest)
on Mar 13, 2001 at 12:51 UTC ( #64085=note: print w/replies, xml ) Need Help??


in reply to Counting number of characters in a string

Yet Another Silly Way Of Counting Characters In A String (YASWOCCIAS):
$_="YASWOCCIAS"; s/./+1/g; print eval;


/brother t0mas

Replies are listed 'Best First'.
Re: Re: Counting number of characters in a string
by I0 (Priest) on Mar 13, 2001 at 13:19 UTC
    Shouldn't that be s/./+1/gs;
      $_="YASWOCCIAS"; don't contain any newlines so it doesn't matter in this case. In other cases it might, depending on how you define "character" in your application. For some apps (like word processors), s/\S/+1/g; might be the right choise if you like to use this algorithm in your production environment... :-)

      /brother t0mas

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://64085]
help
Chatterbox?
[Corion]: 1nickt: I bought a 2015 XPS 13, which is a very nice and shiney (and somewhat overpriced) machine, but I think it's still better priced than an Apple machine. Now it just has to hold up 10 years like the old one did ;)
[1nickt]: Ah, you got Linus' fave? With Ubuntu? 4k display?
[1nickt]: ( The 17" monster I just bought is for my wife, who doesn;t leave the house with it...)

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (9)
As of 2017-03-27 13:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (320 votes). Check out past polls.