Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Regular Expression

by tinita (Parson)
on Aug 05, 2004 at 19:28 UTC ( [id://380360]=note: print w/replies, xml ) Need Help??


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
      ;-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-03-29 08:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found