Help

I need this variable $time to show last hour (00..23) So if hour is 00, I want 23. If 
hour is 01, I want 00, etc..... 

I can run that awk statement on the command line and it works great, but if I try it 
in the script it fails with an awk syntax error... 

Is there a way to look at last hour with $time1 ?? I would rather keep it all perl.....

#!/usr/bin/perl
use strict;
use POSIX 'strftime';
use warnings;
use Memoize;
 
my $dir = "/opt/week/";
my $dirfiles = "";

#my $time1 = strftime "%y%m%d%H", localtime;

my $time = system("/bin/date +%H | awk -F '{if ($1 == 00) print 23; else if ($1 <= 10) 
print 0$1 -1; else print $1 -1}'");
 
 opendir(DIR, $dir) || die ("Open Dir Failed: $!\n"); 
my @files = grep(!/^\.\.?$/,readdir(DIR));
my @files = grep /ip.$time/, @files;
 closedir(DIR);
 
 
foreach $dirfiles (@files)
 {
@ARGV = $dir.$dirfiles;
print "editing file $dirfiles\n";

  die "Usage: $0 FILES\n" unless @ARGV;
 $^I = '.bak';             # turn on in-place editing with backups
     while (<>) {         # process one line at a time
         s{ ^(\d+) }{ convert($1) }ex; 
         print;
                }
print "Done with $dirfiles\n";
 }
 
memoize('convert');
sub convert { strftime('%Y-%m-%d %T', localtime(shift)) }

thanks
rob


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to