File::Copy warning 
Author Message
 File::Copy warning

I got the following when using File::Copy  (version 1.5)

  Use of uninitialized value at
  /usr/local/mhg/sparc-sun-sunos4.1/lib/perl-5.003/File/Copy.pm line 84.

This comes from the following sections of code:

33>    my $to = shift;
34>    my $recsep = $\;
35>    my $closefrom=0;
36>    my $closeto=0;
37>    my ($size, $status, $r, $buf);
38>    local(*FROM, *TO);
39>
40>    $\ = '';

<*skip*>

83>    close(FROM) || goto fail_open1 if $closefrom;
84>    $\ = $recsep;
85>    return 1;

This warning also occured only once, though the copy command was
invoked multiple times. I attempted to get around this, assuming
that the fault was that the value of $/ was undef, by using the
following in my own code:

    $/ = '';
    if (!copy($source,$dest)) {
        print STDERR "Copy of $source to $dest failed: $!\n";
    }

It didn't help. Anybody know why this warning is occuring and what
I should do about it?

In case it's useful, I'm using perl-5.003 on a SunOS4.1.3 machine.

--
Andrew D. Arenson            | http://www.*-*-*.com/ :8088/cgi-bin/andy/andy

Genome Sequencing Center, Molecular & Human Genetics Dept.     | W 798-4689
One Baylor Plaza, Room S903, Houston, TX 77030                 | F 798-5386



Fri, 31 Dec 1999 03:00:00 GMT  
 File::Copy warning


Quote:
>I got the following when using File::Copy  (version 1.5)

>  Use of uninitialized value at
>  /usr/local/mhg/sparc-sun-sunos4.1/lib/perl-5.003/File/Copy.pm line 84.

>This comes from the following sections of code:

>33>    my $to = shift;
>34>    my $recsep = $\;
>35>    my $closefrom=0;
>36>    my $closeto=0;
>37>    my ($size, $status, $r, $buf);
>38>    local(*FROM, *TO);
>39>
>40>    $\ = '';

><*skip*>

>83>    close(FROM) || goto fail_open1 if $closefrom;
>84>    $\ = $recsep;
>85>    return 1;

>This warning also occured only once, though the copy command was
>invoked multiple times. I attempted to get around this, assuming
>that the fault was that the value of $/ was undef, by using the
>following in my own code:

>    $/ = '';
>    if (!copy($source,$dest)) {
>    print STDERR "Copy of $source to $dest failed: $!\n";
>    }

In Perl5.003, if you assign 'undef' to $\, you get that error.
This is a bug.  It doesn't happen in Perl5.004.

Note that your attempted fix is confusing $\ and $/.   I expect that if
you set $\ to '', the error message would go away.

Note also that the code in File::Copy isn't very good style.   Saving
and restoring like that runs the risk of forgetting to restore on some
error route, quite apart from provoking bugs.    Much better is to
localise the variable with

     local $\ = '';

and the restoring will be done automatically for you.    In fact, that's
what the version of File::Copy in Perl5.004 does.

Mike Guy



Fri, 31 Dec 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. File::Copy warning

2. Warning using copy from File::Copy

3. warning from File::Copy

4. Using File::Copy and Sockets to copy public files from http addresses

5. File::Copy, copying files problem.

6. Bug in Copy.pm (produces warning message)

7. Semantics of File::Copy::copy(,)

8. unwanted UNIX file permissions after using File::Copy::syscopy

9. File::Copy WIn32 bad file descriptor

10. How do copy files based on pattern on original file namnes

11. File::Copy bug - copying over same file zeroes file?

12. warnings::register, no warnings, and inheritance

 

 
Powered by phpBB® Forum Software