
ladycygnus
Novice
Aug 22, 2011, 7:57 AM
Post #3 of 9
(14757 views)
|
Re: [FishMonger] 9:5:4 => 09:05:04
[In reply to]
|
Can't Post
|
|
I do not understand. I never want to use $10 - that would not be a proper variable since they should begin with a letter. Here is my complete code, the reg ex is at the end.
use strict; use warnings; my $time = time(); print "Current Time; $time\n"; my $t_Batch1 = 1306416600; print "Time of Batch 1 = $t_Batch1\n"; &printTime($t_Batch1); sub printTime { my $BatchTime = shift(@_); my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($BatchTime); $year += 1900; my @month_abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); my @week_abbr = qw( Sun Mon Tue Wed Thu Fri Sat ); my $string = "$week_abbr[$wday], $mday $month_abbr[$mon] $year $hour:$min:$sec +0000"; print "Before Change: $string\n"; ### HERE IS THE SUBSTITUTION ### $string =~ s/(\D)(\d\D)/$10$2/g; print "After Change: $string\n"; } This is the output I get: Current Time; 1314024736 Time of Batch 1 = 1306416600 Before Change: Thu, 26 May 2011 9:30:0 +0000 Use of uninitialized value in concatenation (.) at C:\Documents and Settings\...\dateTest.pl line 24. Use of uninitialized value in concatenation (.) at C:\Documents and Settings\...\dateTest.pl line 24. After Change: Thu, 26 May 20119:300 +0000
|