Apparently I can no longer send email to this list
from my work account because of:
The following message to <[email protected]> was
undeliverable.
The reason for the problem:
5.1.0 - Unknown address error 550-'Mail from
cardinal.com rejected because it does not accept
bounces. This violates RFC 821/2505/2821
http://www.rfc-ignorant.org/'



Smith, Derek wrote:
> Why doesn't a copy work on each array element yet a
glob does?

I'm assuming you eman copy() from File::Copy?

because copy()'s source doesn't do that I imagine. Is
there 
documentation for copy() that seems to indicate it
does?

> Is there a way to tell Perl to copy each element of
the array off to
> another file location?

Yes, write code that does it like you are doing below.

> for (my $suffix=0; $suffix <= $#NBlogs2; $suffix++)
{
> 
>  
> 
>               foreach my $logs (@NBlogs2) {
> 
>                   copy ("$logs",
"$oldir/$logs.$suffix") or die "Copy
> failed $!";
> 
>               }
> 
>           }


Be consistent and use Best practives:

for my $n(0..$#NBlogs2) {
     for my $log(@NBlogs2) {
         copy $log, "$olddir/$log.$n" or warn "Copying
$log to 
$olddir/$log.$n failed: $!";
******************************************************************

Thank you for replying. : )
Yes I am using File::Copy and IO::All to store these
files in an array using the recursive
$twoweekdir->all(0); ##traverse down subdirs as far as
you can.
I commented everything else out except for this copy
block.

Yes best practices sorry about that C style code.

use strict;
use warnings;
use diagnostics;
use File::Copy;
#use Logfile::Rotate;
use IO::All;

$ENV{"PATH"} = qq(/usr/local/admin);
delete @ENV{qw (IFS CDPATH ENV KSH_ENV BASH_ENV)};

my $runlog              =
qq(/var/tmp/logroll_for_NB.log);
my $oldir               = qq(/usr/openv/logs/old);
my $oneweekdir          = qq(/usr/openv/logs/);
my $twoweekdir          =
io('/usr/openv/netbackup/logs');
my @twoweekdir_contents = $twoweekdir->all(0);
my (@NBlogs1,@NBlogs2,) = ();
my $i                   = 0;

snip.... { }

## Only retrieve log files under subdirs bpcd, bptm
and bpdbm.

foreach my $log (@twoweekdir_contents) {
    $NBlogs2[$i++] = $log if ($log =~
     /bpcd\/log|bpdbm\/log|bptm\/log.\d+/)
}

if (@NBlogs2) {
  for my $suffix(0..$#NBlogs2) {
    for my $log(@NBlogs2) {
        copy $log, "$oldir/$log.$suffix" or warn
"Copying $log to
        $oldir/$log.$suffix failed: $!";
    }
  }
}

snip ... { }

The errors I am getting: 

Uncaught exception from user code:
        Operation `eq': no method found,
        left argument in overloaded package
IO::All::File,
        right argument has no overloaded magic at
/opt/perl/lib/5.8.3/File/Copy.pm line 76.
        main::__ANON__('Operation `eq\': no method
found,\x{a}\x{9}left argument in overloade...') called
at /opt/perl/lib/5.8.3/File/Copy.pm line 76
       
File::Copy::copy('IO::All::File=GLOB(0x40543378)','/usr/openv/logs/old//usr/openv/netbackup/logs/bpcd/log.082106.0')
called at logroll_for_NB.plx line 98


In File/Copy.pm the code is:

    58  sub copy {
    59      croak("Usage: copy(FROM, TO [,
BUFFERSIZE]) ")
    60        unless(@_ == 2 || @_ == 3);
    61
    62      my $from = shift;
    63      my $to = shift;
    64
    65      my $from_a_handle = (ref($from)
    66                           ? (ref($from) eq
'GLOB'
    67                              ||
UNIVERSAL::isa($from, 'GLOB')
    68                              ||
UNIVERSAL::isa($from, 'IO::Handle'))
    69                           : (ref(\$from) eq
'GLOB'));
    70      my $to_a_handle =   (ref($to)
    71                           ? (ref($to) eq 'GLOB'
    72                              ||
UNIVERSAL::isa($to, 'GLOB')
    73                              ||
UNIVERSAL::isa($to, 'IO::Handle'))
    74                           : (ref(\$to) eq
'GLOB'));
    75
    76      if ($from eq $to) { # works for
references, too
    77          carp("'$from' and '$to' are identical
(not copied)");
    78          # The "copy" was a success as the
source and destination contain
    79          # the same data.
    80          return 1;


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
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