We help IT Professionals succeed at work.

# Count number of numbers in line

on
227 Views
Hello,

How to count the number of numbers in the folling line.

\$test = "1232344556";

The result has to be 10!

How to do that!!

greetings Michel
Comment
Watch Question

## View Solution Only

Commented:
This one is on us!
(Get your first solution completely free - no credit card required)

Commented:
Of course,

\$number_of_numbers = length \$test;

as well....

(which is a faster way...).

Commented:
Not what I do is the
following

example!!

\$number_of_numbers = "60";

\$number_of_numbers = \$number_of_numbers/40;

The result is 1.5

What I now need is that number will be roundoff up.

\$number_of_numbers has to become 2.

But this roundoff has to be done not as we normal round off a number, but by the following way!!

0.5 becomes 1
0.2 becomes 1
1.2 becomes 2
4.7 becomes 5
3.02 becomes 4

How to do that!!

Commented:
That's another question, dude :-)

Commented:

Commented:
Of course, but can you help me??

Commented:

Commented:
for example:
\$number=56987658.09728794645;

\$number=~m/(\d+)(\.)?(\d+)?/; \$number=\$1;
if (\$2 && \$3) {
\$number++ if \$3>0;
}
print "\$number\n";

Commented:

Commented:
I increaded the point to 100!!

Thank you again!!

Commented:
Welcome.
Unlock the solution to this question.

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.