Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > how to shorten ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 7 Topic 11035 of 11065
Post > Topic >>

how to shorten this code ? x occur how many times in variable

by rich.japh@[EMAIL PROTECTED] (Richard Lee) May 7, 2008 at 01:43 AM

Can you please tell me how to shorten this?

my @[EMAIL PROTECTED]
 = split(//);
 my @[EMAIL PROTECTED]
 = grep { $_ eq ':' } @[EMAIL PROTECTED]
 ;

I was trying to see how many : occur in variable but didn't know how to 
do it fast so i did it like above...

I would like to see as many way different ways to get this done if
possible

thank you!!


$var1 = root:x:123:/root:

trying to see how many times : occurs in $var1..... and I could only do 
it above way....




 7 Posts in Topic:
how to shorten this code ? x occur how many times in variable
rich.japh@[EMAIL PROTECTE  2008-05-07 01:43:29 
Re: how to shorten this code ? x occur how many times in variabl
krahnj@[EMAIL PROTECTED]   2008-05-06 23:28:58 
Re: how to shorten this code ? x occur how many times in variabl
rich.japh@[EMAIL PROTECTE  2008-05-07 03:12:03 
Re: how to shorten this code ? x occur how many times in variabl
rob.dixon@[EMAIL PROTECTE  2008-05-07 16:11:07 
Re: how to shorten this code ? x occur how many times in variabl
rich.japh@[EMAIL PROTECTE  2008-05-07 14:07:04 
Re: how to shorten this code ? x occur how many times in variabl
krahnj@[EMAIL PROTECTED]   2008-05-07 18:15:25 
Re: how to shorten this code ? x occur how many times in variabl
rich.japh@[EMAIL PROTECTE  2008-05-08 00:15:37 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu May 15 1:19:43 CDT 2008.