in reply to Re^3: line by line Encryption fun with Crypt::CBC and Rijndael? File Ownership issues? (code)
in thread line by line Encryption fun with Crypt::CBC and Rijndael? File Ownership issues?

Trying to understand what is going on here:
sub read_bytes { my ($fh, $to_read) = @_; $buf = ''; while ($to_read) { <b>my $bytes_read = read($FH_decrypted, $buf, length($buf));</b> die("$!\n") if !defined($bytes_read); die("Unexpected end of file\n") if !$bytes_read; $to_read -= $bytes_read; } return $buf; }

Should $FH_decrypted be $fh instead? Otherwise the value in $fh being passed to the function is seemingly never used.
Why is the value of $buf set to an empty string? Won't length($buf) be zero and therefore nothing would ever be read?


I learn more and more about less and less until eventually I know everything about nothing.
  • Comment on Re^4: line by line Encryption fun with Crypt::CBC and Rijndael? File Ownership issues? (code)
  • Select or Download Code

Replies are listed 'Best First'.
Re^5: line by line Encryption fun with Crypt::CBC and Rijndael? File Ownership issues? (code)
by ikegami (Patriarch) on Dec 06, 2007 at 18:39 UTC
    my $bytes_read = read($fh, $buf, $to_read, length($buf));

    Sorry, so many mistakes. I went and tested the code, made a couple more fixes. See the original post with the code.