RE: Variable definition

2005-10-07 Thread Andy_Bach
To add a zero pad ("printf" if you just want it printed zero padded):
my $padded_name = sprintf("%02d", $month);

the 'zero' is the pad char, the '2' is the number of places to pad to

To get rid of it:
print "The month number is: ", $padded_name + 0, "\n";

that  is, use it as an integer and Perl'll dumber it.

$month = 7;
my $padded_name = sprintf("%02d", $month);

print "The month number was: ", $padded_name, "\n";
print "The month number is: ", $padded_name + 0, "\n";

Andy Bach, Sys. Mangler
Internet: [EMAIL PROTECTED] 
VOICE: (608) 261-5738  FAX 264-5932

" History will have to record that the greatest tragedy of this period of
social transition was not the strident clamor of the bad people, but the
appalling silence of the good people. "
Martin Luther King, Jr.
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Variable definition

2005-10-07 Thread Ken Barker



try: 

 
$month 
= 7;
 
$month 
= sprintf("%02d",$month);
 
 
 
 

This may seem like a simple 
question, but I have a variable $month=7 but I want to represent it as 
$month=07.  How is this done.  I am not sure what to search on to find 
out how to do this, hence I am here.

  
  Thanks in 
  advance,
  Glen.
   
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Variable definition

2005-10-07 Thread Joe Discenza







Pierce, Glen E wrote, on Fri 10/7/2005 09:35


: This may seem like a simple 
question, but I have a variable $month=7 but I want to represent it as 
$month=07.  How is this done. 
 
$month = sprintf("%02d", 
$month);
 
Good luck,
 
Joe
 

==  
Joseph P. Discenza, Sr. 
Programmer/Analyst   
mailto:[EMAIL PROTECTED]   
Carleton Inc.   http://www.carletoninc.com  
574.243.6040 ext. 300    fax: 574.243.6060 Providing 
Financial Solutions and Compliance for over 30 Years
 




___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Variable definition

2005-10-07 Thread Dirk Bremer



$month = '07';
Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. 
Louis MO - USA Central Time Zone636-755-2652 fax 
636-755-2503[EMAIL PROTECTED]www.nisc.coop 
 

  
  
  From: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On Behalf Of 
  Pierce, Glen ESent: Friday, October 07, 2005 
  08:35To: 
  perl-win32-users@listserv.ActiveState.comSubject: Variable 
  definition
  
  
  This may seem like a simple 
  question, but I have a variable $month=7 but I want to represent it as 
  $month=07.  How is this done.  I am not sure what to search on to 
  find out how to do this, hence I am here.
  Thanks in 
  advance,
  Glen.
   
  The Home 
  Depot
  2455 Paces Ferry 
  Rd
  Atlanta 
  30339
   
  What do you call a boomerang that does not come back 
  ?  A stick.
   
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Variable definition

2005-10-07 Thread Ted Schuerzinger
Pierce, Glen E graced perl with these words of wisdom:

> This may seem like a simple question, but I have a variable $month=7 but
> I want to represent it as $month=07.  How is this done.  I am not sure
> what to search on to find out how to do this, hence I am here.

Do you really want the value of $month to be 07, or do you want it 
*displayed* as 07?

If it's the latter, try the PRINTF function:



#! perl

use strict;

my $month=7;

printf ("%02u", $month);



gives the result 
07

while 



#! perl

use strict;

my $month=7;

printf ("%050u", $month);



reults in
07

Not that you want that many 0's in front of the 7, of course.  :-)

Go to the perlfunc page of help and look under PRINTF and SPRINTF for more 
information.

-- 
Ted 
Oh Marge, anyone can miss Canada, all tucked away down there
--Homer Simpson

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Variable definition

2005-10-07 Thread Hicks, Bob
>This may seem like a simple question, but I have a variable $month=7 but I 
>want to >represent it as $month=07.  How is this done.  I am not sure what to 
>search on to find >out how to do this, hence I am here.

If I do:

$month = '07';
print "The month is: $month\n";

I get:

The month is: 07

Was there some specific case you were looking at where it didn't work?

Robert

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs