Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Change $/ = "\xff\xfe\xff\xfe" x 16 to undef in t/10-xz.t. (trice).

sandbox/xz-undef.pl shows it is not the underlying IO modules to blame.

$ perl -Mblib -MPerlIO::via::xz -wE'open my $fh, "<:via(xz)", "files/p +lain.xz";print scalar<$fh>' Lorem ipsum dolor sit amet, consectetur adipiscing elit, $ perl -Mblib -MPerlIO::via::xz -wE'open my $fh, "<:via(xz)", "files/p +lain.xz";$/=undef;print scalar<$fh>'

or replace t/10-xz.t with this:

# Tests for PerlIO::via::xz use 5.12.0; use warnings; use Test::More; use File::Copy; use_ok ("PerlIO::via::xz"); my $txz = "test.xz"; END { unlink $txz } my %txt; my %xz; for my $type (qw( plain banner )) { local $/; open my $fh, "<", "files/$type.txt" or die "$type.txt: $!\n"; $txt{$type} = <$fh>; close $fh; open $fh, "<", "files/$type.xz" or die "$type.xz: $!\n"; $xz{$type} = <$fh>; close $fh; } # Check defaults #cmp_ok(PerlIO::via::xz->level, "==", 1, "default worklevel"); my $fh; # Opening/closing ok ( open ($fh, "<:via(xz)", "files/plain.xz"), "open for read +ing"); ok ( close ($fh), "close file"); ok (!open ($fh, "+<:via(xz)", "files/plain.xz"), "read+write is + impossible"); ok ( open ($fh, ">:via(xz)", $txz), "open for writ +e"); ok ( close ($fh), "close file"); ok (!open ($fh, "+>:via(xz)", $txz), "write+read is + impossible"); ok (!open ($fh, ">>:via(xz)", $txz), "append is not + supported"); foreach my $rs ("\xff\xfe\xff\xfe" x 16, undef) { local $/ = $rs; # Decompression for my $type (qw( plain banner )) { ok (open (my $fz, "<:via(xz)", "files/$type.xz"), "Open $type" +); is (scalar <$fz>, $txt{$type}, "$type decompression"); } # Compression for my $type (qw( plain banner )) { my $fh; ok (open ($fh, ">:via(xz)", $txz), "Open $type compress"); ok ((print { $fh } $txt{$type}), "Write"); ok (close ($fh), "Close"); } # Roundtrip for my $type (qw( plain banner )) { my $fh; ok (open ($fh, ">:via(xz)", $txz), "Open $type compress"); ok ((print { $fh } $txt{$type}), "Write"); ok (close ($fh), "Close"); ok (open ($fh, "<:via(xz)", $txz), "Open $type uncompress"); is (scalar <$fh>, $txt{$type}, "Compare"); } } done_testing;

Enjoy, Have FUN! H.Merijn

In reply to Re^2: PerlIO::via::xz by Tux
in thread PerlIO::via::xz by Tux

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-24 01:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found