Date: Mon, 05 Apr 1999 15:38:42 -0700
Message-Id: <3.0.6.32.
19990405153842.0367b650@ous.edu>
Subject: Re: chomp fails with $/ in fixed-length record mode
--
From: Roderick Schertler <roderick@argon.org>
Date: Tue, 06 Apr 1999 21:11:37 -0400
Message-ID: <2795.
923447497@eeyore.ibcinc.com>
Subject: Re: chomp fails with $/ in fixed-length record mode
p4raw-id: //depot/perl@3319
if (RsSNARF(PL_rs))
return 0;
+ if (RsRECORD(PL_rs))
+ return 0;
count = 0;
if (SvTYPE(sv) == SVt_PVAV) {
register I32 i;
remove the newline from the end of an input record when you're worried
that the final record may be missing its newline. When in paragraph
mode (C<$/ = "">), it removes all trailing newlines from the string.
-If VARIABLE is omitted, it chomps C<$_>. Example:
+When in slurp mode (C<$/ = undef>) or fixed-length record mode (C<$/> is
+a reference to an integer or the like, see L<perlvar>) chomp() won't
+remove anything. If VARIABLE is omitted, it chomps C<$_>. Example:
while (<>) {
chomp; # avoid \n on last field
#!./perl
-# $RCSfile: chop.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:40 $
-
-print "1..28\n";
+print "1..30\n";
# optimized
$/ = "yy";
print chomp() == 0 ? "ok 27\n" : "not ok 27\n";
print $_ eq "axx" ? "ok 28\n" : "not ok 28\n";
+
+# This case once mistakenly behaved like paragraph mode.
+$_ = "ab\n";
+$/ = \3;
+print chomp() == 0 ? "ok 29\n" : "not ok 29\n";
+print $_ eq "ab\n" ? "ok 30\n" : "not ok 30\n";