in reply to My little 123.pl application...

The main problem I can see is that except for two places you don't check system calls like open() and sysread() etc.
406 my $buffer_size = 1024; 407 408 my $on = 0; 409 410 while (sysread(ORGINAL, my $buffer, $buffer_size)) { 411 syswrite(ENCRYPTED, $cipher->crypt($buffer)); 412 413 $on += $buffer_size;
sysread() and read() return the number of bytes read and there is no guarantee that the number of bytes read will be the same as the number of bytes requested in $buffer_size so your code is making a possibly invalid assumption.

Replies are listed 'Best First'.
Re^2: My little 123.pl application...
by Ace128 (Hermit) on Apr 22, 2006 at 15:35 UTC
    Alrighty! Thanks. So.. how do you think I should solve that?

    Also, I was wondering... is it possible to move this to "Cool Uses For Perl"? It may be more suitable there...
      Something like:
      my $buffer_size = 1024; my $on = 0; while ( my $bytes_read = sysread ORGINAL, my $buffer, $buffer_size ) { defined $bytes_read or die "Cannot sysread from $filename: $!"; syswrite ENCRYPTED, $cipher->crypt( $buffer ) or die "Cannot syswr +ite to $filename.3nc: $!"; $on += $bytes_read;