Perl crashes at 128KB?

K

Kelvin

Hi, there:

Following is my code, basically I try to simply XOR a 20MB file line by line
with a key
then save it in a file. I am using the lastest ActivePerl in Win2000.

The error I got is,
The instruction at "0x2808698b" referenced memory at "0x00000004".
The memory couldn't be "written".

Click OK to terminate...
Click CANCEL to debug...

What happened?

Thanks.




#!/usr/bin/perl
use POSIX;

open(FIL, "./line_merged.all");
@page_in = <FIL>;
close(FIL);

$key = "This is my key";
$j = 0;
open(FIL, ">./encrypted.all");
binmode FIL;
foreach $line (@page_in) {
if( $j % 100 == 0 ) {
print "\n\n\nLine $j started here: \n";
print "\n" . $line;
}
$j = $j + 1;
$mult = ceil( length( $line ) / length( $key ) ) + 1;
for( $i = 0; $i < $mult; $i = $i + 1) {
$key = $key . $key;
}
$key = substr($key, 0, length($line));
$line = $key ^ $line ;
# print "\n" . $key;
# print "\n\nAfter Encryption\n" . $line;
print FIL $line;

# $line = $key ^ $line ;
# print "\n\nAfter Decryption\n" . $line;
}
close(FIL);
 
E

Ejner Borgbjerg

Hi Kelvin

I've used Active Perl some years on my job. Your code looks quite ordinary
to me. I nearly always use strict and use warnings though.

use POSIX I've never used. What does it do ?

regards Ejner
 
J

Joe Smith

Ejner said:
I've used Active Perl some years on my job. Your code looks quite ordinary
to me. I nearly always use strict and use warnings though.

use POSIX I've never used. What does it do ?

perldoc POSIX

-Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top