diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1999-05-07 08:07:02 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-05-07 08:07:02 +0000 |
commit | 4c5a6083a6f92a8003034d6119c72e8d828e4613 (patch) | |
tree | a4830fa12e559e5ae09e8a508784ae04af935213 | |
parent | 787eafbd5502f34cb6300ce384514251ed273d04 (diff) | |
download | perl-4c5a6083a6f92a8003034d6119c72e8d828e4613.tar.gz |
From: Dan Sugalski <sugalskd@osshe.edu>
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
-rw-r--r-- | doop.c | 2 | ||||
-rw-r--r-- | pod/perlfunc.pod | 4 | ||||
-rwxr-xr-x | t/op/chop.t | 10 |
3 files changed, 12 insertions, 4 deletions
@@ -831,6 +831,8 @@ do_chomp(register SV *sv) if (RsSNARF(PL_rs)) return 0; + if (RsRECORD(PL_rs)) + return 0; count = 0; if (SvTYPE(sv) == SVt_PVAV) { register I32 i; diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index c973d0c367..b2231a3a87 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -546,7 +546,9 @@ number of characters removed from all its arguments. It's often used to 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 diff --git a/t/op/chop.t b/t/op/chop.t index 77263ad3ad..6723ca3f1b 100755 --- a/t/op/chop.t +++ b/t/op/chop.t @@ -1,8 +1,6 @@ #!./perl -# $RCSfile: chop.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:40 $ - -print "1..28\n"; +print "1..30\n"; # optimized @@ -85,3 +83,9 @@ $_ = "axx"; $/ = "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"; |