7 skip_all_without_perlio();
13 my $file = tempfile();
17 ok(open(FOO,">:crlf",$file));
18 ok(print FOO 'a'.((('a' x 14).qq{\n}) x 2000) || close(FOO));
19 ok(open(FOO,"<:crlf",$file));
22 { local $/; $text = <FOO> }
23 is(count_chars($text, "\015\012"), 0);
24 is(count_chars($text, "\n"), 2000);
28 { local $/; $text = <FOO> }
29 is(count_chars($text, "\015\012"), 2000);
33 skip_if_miniperl("miniperl can't rely on loading PerlIO::scalar");
34 skip("no PerlIO::scalar") unless $Config{extensions} =~ m!\bPerlIO/scalar\b!;
35 require PerlIO::scalar;
36 my $fcontents = join "", map {"$_\015\012"} "a".."zzz";
37 open my $fh, "<:crlf", \$fcontents;
40 my $pos = tell $fh; # pos must be behind "xxx", before "\nxxy\n"
49 # binmode :crlf should not cumulate.
50 # Try it first once and then twice so that even UNIXy boxes
51 # get to exercise this, for DOSish boxes even once is enough.
52 # Try also pushing :utf8 first so that there are other layers
53 # in between (this should not matter: CRLF layers still should
55 for my $utf8 ('', ':utf8') {
56 for my $binmode (1..2) {
58 # require PerlIO; print PerlIO::get_layers(FOO), "\n";
59 binmode(FOO, "$utf8:crlf") for 1..$binmode;
60 # require PerlIO; print PerlIO::get_layers(FOO), "\n";
65 my $foo = scalar <FOO>;
67 print join(" ", "#", map { sprintf("%02x", $_) } unpack("C*", $foo)),
69 like($foo, qr/\x0d\x0a$/);
70 unlike($foo, qr/\x0d\x0d/);
76 my($text, $chars) = @_;
78 $seen++ while $text =~ /$chars/g;