text: I'm doing a division of a number by 3 and I always want to round to the next greater number. If the result is e.g. 3.3 or 3.6 I want to report 4. Same with 3003.3 etc. How can I do this in perl? Thanks! C
  thanks to everyone! it works now :) the oneliners are quite neat.
  perldoc -q round
  [download]
  use warnings;
  use strict;
  use POSIX;
  for (3.3, 3.6, 3003.3) {
  print $_, "\t", ceil($_), "\n";
  }
  __END__
  3.3 4
  3.6 4
  3003.3 3004
  [download]
  Or if you do not want to import a mass of functions into your namespace from the POSIX module, just do this:
  my $n = 3.3;
  my $ceiling = int($n + 1);
  [download]
  (Update) Above is incorrect, as pointed out by others. This works:
  my $n1 = 3.3;
  my $n2 = 4;
  print int($n1 + 1)," ",int($n2 + 1), "\n";
  [download]
  That fails if $n is allready an integer. You would need something like:
  my $n = 3.0;
  my $ceiling = int($n);
  $ceiling += 1 if $ceiling != $n;
  [download]
  Or as a one liner:
  my $ceiling = int($n) + ($n != int($n));
  [download]
  if you do not want to import a mass of functions into your namespace from the POSIX module
  use warnings;
  use strict;
  use POSIX qw(ceil);
  for (3.3, 3.6, 3003.3) {
  print $_, "\t", ceil($_), "\n";
  }
  __END__
  3.3 4
  3.6 4
  3003.3 3004
  [download]
  Alternately, you could import nothing and call the function using POSIX::ce