Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Some help with my project:

by madtoperl (Hermit)
on Jan 17, 2017 at 13:24 UTC ( [id://1179742]=note: print w/replies, xml ) Need Help??


in reply to Re: Some help with my project:
in thread Some help with my project:

In this code also if you add one more if condition before doing this calculation,
it will prevent these kind of error if future
if ($used){ my $monit_percentual = ( $avail / $avail+$used ) * 100 ; my $final_used = $used / 1000 ; my $final_avail = $avail / 1000 ; print "$monit is a $fs_type filesystem who has $final_used space u +sed (in MB) and $final_avail of avalible space (in MB too) \n" ; #comparacion con el porcentaje de $monit_percentual if ($monit_percentual < $warn) { print "Less of the $warn % of the space of the filesystem +$monit is avalible for use, consider uninstall unused software \n" ; } elsif ($monit_percentual eq $warn) { print "Be carefull, exactly the $warn % of the space of $m +onit is usable, consider uninstall unused software \n" ; } else { print "There is a $monit_percentual % of avarible space of + the disk \n" ; } }else{ print "Some message\n"; }

Replies are listed 'Best First'.
Re^3: Some help with my project:
by marto (Cardinal) on Jan 17, 2017 at 14:50 UTC
    my $monit_percentual = (  $avail  /  $avail+$used  ) * 100 ;

    "it will prevent these kind of error if future"

    If you want to prevent errors be aware of perlop "Operator precedence and associativity".

    use strict; use warnings; my $avail = 1; my $used = 1; my $testa = ( $avail / $avail + $used ) * 100; my $testb = ( $avail / ( $avail + $used ) ) * 100; print "testa: $testa\ntestb: $testb\n";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-03-28 16:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found