Change 16731: Be more specific in what we're looking for

[email protected] (Chris Nandor) Wed, 22 May 2002 01:16:11 -0400
Newsgroups perl.perl5.changes.mac
Message-ID <p05100305b910da1b6ea3@[10.0.1.177]>
Change 16731 by pudge@pudge-mobile on 2002/05/22 04:18:58

	Be more specific in what we're looking for

Affected files ...

.... //depot/macperl/t/io/crlf.t#3 edit

Differences ...

==== //depot/macperl/t/io/crlf.t#3 (text) ====
Index: macperl/t/io/crlf.t
--- macperl/t/io/crlf.t#2~16255~	Sun Apr 28 12:25:04 2002
+++ macperl/t/io/crlf.t	Tue May 21 21:18:58 2002
@@ -15,29 +15,30 @@
 }
 
 if (find PerlIO::Layer 'perlio') {
- plan(tests => 6);
+ plan(tests => 7);
  ok(open(FOO,">:crlf",$file));
  ok(print FOO 'a'.((('a' x 14).qq{\n}) x 2000) || close(FOO));
  ok(open(FOO,"<:crlf",$file));
- my $seen = 0;
- my $cr = "\r";
- while (<FOO>)
-  {
-   $seen += tr/[\015]//;
-  }
- is($seen,0);
+
+ my $text;
+ { local $/; $text = <FOO> }
+ is(count_chars($text, "\015\012"), 0);
+ is(count_chars($text, "\n"), 2000);
+
  binmode(FOO);
  seek(FOO,0,0);
- $seen = 0;
- while (<FOO>)
-  {
-   $seen += tr/[\015]//;
-  }
- is($seen,2000);
+ { local $/; $text = <FOO> }
+ is(count_chars($text, "\015\012"), 2000);
+
  ok(close(FOO));
 }
 else {
  skip_all("No perlio, so no :crlf");
 }
 
-
+sub count_chars {
+  my($text, $chars) = @_;
+  my $seen = 0;
+  $seen++ while $text =~ /$chars/g;
+  return $seen;
+}
End of Patch.