Re: Leading zero in a string

2004-09-09 Thread Daniel Staal
--As of Thursday, September 9, 2004 9:24 AM -0500, Errin Larsen is alleged to have said: Excellent! Thank you. I knew it was something easy, just hadn't kick-started my brain yet this morning. But I've got another one. What if the user input, say, '007' on the command line? How can I strip th

Re: Leading zero in a string

2004-09-09 Thread Jeff 'japhy' Pinyan
On Sep 9, Errin Larsen said: >However, I need to pass that variable to another system command which >expects any "day" value less than 10 to have a leading zero, so 7th >day of the month should say '07'. How can I check for that leading >zero? If it's missing, I know I could easily: > >$option =

Re: Leading zero in a string

2004-09-09 Thread Wiggins d Anconia
Please bottom post > Use the following: > > $option = "0" . $option if ($option / 10 < 1 && $option !~ /^0/); > Why divide by 10 first? Why not just check less than 10? Of course I would probably drop the maths completely and use C, perldoc -f sprintf $option = sprintf('%02d', $option);

Re: Leading zero in a string

2004-09-09 Thread Errin Larsen
Excellent! Thank you. I knew it was something easy, just hadn't kick-started my brain yet this morning. But I've got another one. What if the user input, say, '007' on the command line? How can I strip that off? I think I can check for it with something like this: /^0?[1-9]/ But If I find i

Re: Leading zero in a string

2004-09-09 Thread Sid
Use the following: $option = "0" . $option if ($option / 10 < 1 && $option !~ /^0/); ~Sid On Thu, 9 Sep 2004 08:58:36 -0500, Errin Larsen <[EMAIL PROTECTED]> wrote: > Hi All, > > I have a variable I'm reading off of the command line: > > my $option = shift; > > That variable should hold a num