--- Cristi Ocolisan <[EMAIL PROTECTED]> wrote:

> Does anybody know why this code does NOT copy the file into the
> specified directory?
> 
> After the script is executed, my file is listed into the directory,
> but empty.
> 
> Strange?

You indicate that this script used to work.  That suggests to me that
someone was doing maitenance that broke it.  Find out who and why :)

That being said, the problem appears to be in your while loop:
 
>     if ( length($sigla) > 0  ) { 
>         ( $file_name = $sigla ) =~ s/.*\\//;

<snip>

>         while (my $chars_read = read($sigla, $buffer, 4096)) {
>             print OUT $buffer;
>             $size += $chars_read;
>             if ( $size > $max_size ) {                
>                 last;
>             }
>         }

The first argument to read() should be a filehandle, not a filename. 
>From "perldoc -f read":

  read FILEHANDLE,SCALAR,LENGTH,OFFSET
  read FILEHANDLE,SCALAR,LENGTH
    Attempts to read LENGTH characters of data into variable SCALAR
    from the specified FILEHANDLE.

Cheers,
Ovid

-- 
If this message is a response to a question on a mailing list, please send
follow up questions to the list.

Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/

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