I always forget the use strict, use warnings. Thanks again. #!/usr/bin/perl use strict; use warnings; my $dir = "/cert/ImpactServer-5_4/cl9/ctrl_sfm9/sfm9_sched/"; my $dh = "."; my @files = do { opendir my $dh, $dir or die "Cannot open '$dir' $!"; grep /^Completed\.archive\.\d{1,4}$/ && -M "$dir"."$_" > 2, readdir $dh; }; foreach (@files) { system ("compress -v $dir$_") == 0 or die $?; # print "$_\n"; };
-----Original Message----- From: Rob Dixon [mailto:[EMAIL PROTECTED] Sent: Monday, July 14, 2008 5:57 PM To: Perl Beginners Cc: Rob McGinness Subject: Re: Using a Perl script in AIX / Unix Rob McGinness wrote: > > Thanks Rob Dixon and John W. Krahn for your help I really appreciate > it. This is what I came up with based on your examples and the code > works great. Thanks again. > > > #!/usr/bin/perl Always use strict; use warnings; at the start of your program. That way many simple problems will be revealed by Perl itself. > my $dir = "/cert/ImpactServer-5_4/cl9/ctrl_sfm9/sfm9_sched/archives/"; > > my $dh = opendir DIR, "."; This opendir is superfluous. If you had enabled warnings it would have told you Name "main::DIR" used only once: possible typo > my @files = do { > > opendir my $dh, $dir or die "Cannot open '$dir' $!"; > > grep /^Completed\.archive\.\d{1,4}$/ > > && -M "$dir/$_" > 7, readdir $dh; }; You should remove the slash either from the end of your definition of $dir at the top or from the string "$dir/$_". I would prefer the former. > foreach (@files) { > > > > system ("compress -v "."$dir".$_); Those concatenation operators are unnecessary, and you should test the result of the call to system system ("compress -v $dir$_") == 0 or die $?; > # print "$_\n"; > > > > }; This message (and any included attachments) is from Rutland Regional Health Services and is intended only for the addressee(s). The information contained herein may include privileged or otherwise confidential information. Unauthorized review, forwarding, printing, copying, distributing, or using such information is strictly prohibited and may be unlawful. If you received this message in error, or have reason to believe you are not authorized to receive it, please promptly delete this message and notify the sender by e-mail. Thank You -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/