Perl crashes at 128KB?

Discussion in 'Perl' started by Kelvin, Sep 14, 2004.

  1. Kelvin

    Kelvin Guest

    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);
    Kelvin, Sep 14, 2004
    #1
    1. Advertising

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


    On Tue, 14 Sep 2004 10:24:56 +0800, Kelvin wrote:

    > 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);
    Ejner Borgbjerg, Sep 20, 2004
    #2
    1. Advertising

  3. Kelvin

    Joe Smith Guest

    Ejner Borgbjerg wrote:

    > 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
    Joe Smith, Sep 20, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dpackwood
    Replies:
    3
    Views:
    1,767
  2. Steve Butler

    Perl crashes

    Steve Butler, Dec 4, 2004, in forum: Perl Misc
    Replies:
    7
    Views:
    114
    Steve Butler
    Dec 4, 2004
  3. PerlFAQ Server

    FAQ 1.4 What are Perl 4, Perl 5, or Perl 6?

    PerlFAQ Server, Jan 23, 2011, in forum: Perl Misc
    Replies:
    0
    Views:
    286
    PerlFAQ Server
    Jan 23, 2011
  4. PerlFAQ Server
    Replies:
    0
    Views:
    653
    PerlFAQ Server
    Feb 3, 2011
  5. PerlFAQ Server

    FAQ 1.4 What are Perl 4, Perl 5, or Perl 6?

    PerlFAQ Server, Feb 27, 2011, in forum: Perl Misc
    Replies:
    0
    Views:
    276
    PerlFAQ Server
    Feb 27, 2011
Loading...

Share This Page