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 it, how do I strip it off? --Errin On Thu, 9 Sep 2004 19:39:34 +0530, Sid <[EMAIL PROTECTED]> wrote: > 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 number between 1 and 31 (yes, a day of the > > month) I am checking to make sure that the number does indeed lie in > > that range. > > > > 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 = "0".$option; > > > > But I can't seem to figure out an easy, clean way to check for it. > > > > --Thanks, > > > > --Errin > > > > -- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > > > > > > -- > http://www.upster.blogspot.com > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>