Loading ...
Sorry, an error occurred while loading the content.

27407Re:[PBML] adding trailing zeros

Expand Messages
  • Huangj
    Nov 8, 2012
    • 0 Attachment
      my $value = 3;

      sub suffix_0 {
      my $c = $_[0] - length($_[1]);
      if ($c>0) {
      my $result = $value . '0'x$c;
      return $result;
      return $_[1];

      print suffix_0(5, $value);

      At 2012-11-08 07:07:53,Noah <noah-list@...> wrote:

      Hi there,

      I am hoping to make the following changes to integers.
      I would like to do something like the following sprintf command Below
      but instead of leading zeros I would like to add trailing zeros.

      $value = sprintf ("%04d", $value);

      but instead I would like

      1 to become 1000
      23 to become 2300

      is there a way to do that with the sprintf command.

      [Non-text portions of this message have been removed]
    • Show all 6 messages in this topic