in reply to Re: Regular Expression
in thread Regular Expression

NetWallah,
$month < 10 and $month = '0' . $month;
guess what's the result if my $month="07";
=)

Replies are listed 'Best First'.
Re^3: Regular Expression
by NetWallah (Canon) on Aug 06, 2004 at 03:51 UTC
    Ack! - this was intended to be a simple case handler.

    If the expression starts getting any more complicated, I'd much prefer the "printf" of "sprintf" solution - that is a lot cleaner.

        Earth first! (We'll rob the other planets later)

Re^3: Regular Expression
by olivierp (Hermit) on Aug 05, 2004 at 20:45 UTC
    Fun :)
    How about:
    substr($month,0,1,"0$month") if ($month<10 && $month!~/^0/);
    Update: Fixed typo, as per tinita

    --
    Olivier
      substr($month,0,1,"0$month") if ($month<10 && $month!=/^0/);
      Use of uninitialized value in pattern match (m//) at -e line 3. 0077

      s/ != / !~ /x
      ;-)