I am having a strange problem while using the Crypt::CBC module. First i wrote a simple test script that encodes and decodes using Crypt::CBC and 'Blowfish'. I encrypted a file and then decrypted the encrypted file. The resulting file was the same as the original file. I then wrote another version of my test script which attempted to decrypt a file and then use the "split" function to break the decrypted data into an array of lines. Although all the data was correctly decrypted, the split function only generated 1 line, not the correct number of lines. Here is the relevant code lines.

use strict; use warnings; use Crypt::CBC; my $cipher; $cipher = Crypt::CBC->new( -key => $secret_key, -cipher => 'Blowfish' ); local $/; unless ( open(INPUT,"<$filename") ) { die("open failed for file '$filename' : $!\n"); } # UNLESS $data = <INPUT>; close(INPUT); $decrypted = $cipher->decrypt($data); @lines = split(/\r\n/,$decrypted); $num_lines = split(/\r\n/,$decrypted);

When I ran the script, the data was correctly decrypted, however the split() function only generated one big line. Why did I not get the correct number of lines ? I am running on a windows 7 laptop using perl 5.16.3


In reply to problem with Crypt::CBC by bugbuster

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.