• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 209
  • Last Modified:

Count number of numbers in line

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
0
mmcw
Asked:
mmcw
  • 7
  • 4
1 Solution
 
shlomoyCommented:
$test="1232344556";
$test=~s/(\d)/$1 /g;
## 1 2 3 2 3 4 4 5 5 6
@test=split " ", $test;
$number_of_numbers = @test;
0
 
shlomoyCommented:
Of course,

$number_of_numbers = length $test;

as well....

(which is a faster way...).
0
 
mmcwAuthor 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!!






0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
shlomoyCommented:
That's another question, dude :-)
0
 
shlomoyCommented:
Do you accept my answer to your question?
0
 
mmcwAuthor Commented:
Of course, but can you help me??
0
 
shlomoyCommented:
Yes, But please post your new question as a seperate one.
0
 
shlomoyCommented:
for example:
$number=56987658.09728794645;

$number=~m/(\d+)(\.)?(\d+)?/; $number=$1;
if ($2 && $3) {
   $number++ if $3>0;
}
print "$number\n";
0
 
mmcwAuthor Commented:
Adjusted points to 100
0
 
mmcwAuthor Commented:
I increaded the point to 100!!

Thank you again!!
0
 
shlomoyCommented:
Welcome.
Ask more questions :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

  • 7
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now