Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the perlfaq CPAN distribution.

Report information
The Basics
Id: 74215
Status: resolved
Priority: 0/
Queue: perlfaq

People
Owner: Nobody in particular
Requestors: perlbug-followup [...] perl.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



CC: bug-perlfaq [...] rt.cpan.org, perl5-porters [...] perl.org
Subject: [perl #108712] documentation bug in perlfaq5 (To delete lines, ...)
Date: Sat, 21 Jan 2012 10:54:30 -0800
To: "OtherRecipients of perl Ticket #108712":;
From: "Father Chrysostomos via RT" <perlbug-followup [...] perl.org>
Download (untitled) / with headers
text/plain 5.6k
Thank you for your report. The perl faq are now maintained separately on CPAN, so I’m forwarding your message to the CPAN ticket. On Sat Jan 21 08:14:05 2012, sdziegie@stronglg.demon.co.uk wrote: Show quoted text
> > This is a bug report for perl from sdziegie@stronglg.demon.co.uk, > generated with the help of perlbug 1.39 running under perl 5.12.1. > > Hello, > > I think that I have found a bug in the perlfaq5 documentation, namely > the > text: > > To delete lines, only print the ones that you want. > > perl -ni -e 'print unless /d/' inFile.txt > > ... or ... > > perl -pi -e 'next unless /d/' inFile.txt > > I think that the first method using -ni should read: > > perl -ni -e 'print if /d/' inFile.txt > > I do not think that the second method can ever work and should be > removed > from the documentation altogether. Reading the 3rd edition of the > Camel > Book it states that the -p switch has an implied: > > continue { > print or die "-p destination: $!\n"; > } > > at the end. I believe that the 'next' can never bypass this continue > block and > hence the example will always print every line. > > Here is how I tested this out: > > cat > inFile.txt.orig << EOT > This should stay > this goes > as should this > bye > keep dis > bye > EOT > > # Method 1 as per perlfaq5 (I believe the documentation is wrong) > cp inFile.txt.orig inFile.txt; perl -ni -e 'print unless /d/' > inFile.txt; cat inFile.txt > > # Proposed documentation fix for Method 1 (see above) > cp inFile.txt.orig inFile.txt; perl -ni -e 'print if /d/' inFile.txt; > cat inFile.txt > > # Method 2 as per perlfaq5 (I believe that this should be struck from > the > # documentation altogether as it cannot delete anything) > cp inFile.txt.orig inFile.txt; perl -pi -e 'unless /d/' inFile.txt; > cat inFile.txt > --- > Flags: > category=docs > severity=low > --- > This perlbug was built using Perl 5.12.1 - Fri May 6 13:30:46 UTC > 2011 > It is being executed now by Perl 5.12.1 - Fri May 6 13:25:31 UTC > 2011. > > Site configuration information for perl 5.12.1: > > Configured by abuild at Fri May 6 13:25:31 UTC 2011. > > Summary of my perl5 (revision 5 version 12 subversion 1) > configuration: > > Platform: > osname=linux, osvers=2.6.32, archname=i586-linux-thread-multi > uname='linux build34 2.6.32 #1 smp 2011-02-21 10:34:10 +0100 i686 > athlon i386 gnulinux ' > config_args='-ds -e -Dprefix=/usr -Dvendorprefix=/usr > -Dinstallusrbinperl -Dusethreads -Di_db -Di_dbm -Di_ndbm -Di_gdbm > -Duseshrplib=true -Doptimize=-fomit-frame-pointer > -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector > -funwind-tables -fasynchronous-unwind-tables -g -Wall -pipe > -Accflags=-DPERL_USE_SAFE_PUTENV' > hint=recommended, useposix=true, d_sigaction=define > useithreads=define, usemultiplicity=define > useperlio=define, d_sfio=undef, uselargefiles=define, > usesocks=undef > use64bitint=undef, use64bitall=undef, uselongdouble=undef > usemymalloc=n, bincompat5005=undef > Compiler: > cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE > -DPERL_USE_SAFE_PUTENV -DDEBUGGING -fno-strict-aliasing -pipe > -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', > optimize='-fomit-frame-pointer -fmessage-length=0 -O2 -Wall > -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables > -fasynchronous-unwind-tables -g -Wall -pipe', > cppflags='-D_REENTRANT -D_GNU_SOURCE -DPERL_USE_SAFE_PUTENV > -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector' > ccversion='', gccversion='4.5.0 20100604 [gcc-4_5-branch revision > 160292]', gccosandvers='' > intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 > d_longlong=define, longlongsize=8, d_longdbl=define, > longdblsize=12 > ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', > lseeksize=8 > alignbytes=4, prototype=define > Linker and Libraries: > ld='cc', ldflags =' -fstack-protector' > libpth=/lib /usr/lib /usr/local/lib > libs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc > perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc > libc=/lib/libc-2.11.2.so, so=so, useshrplib=true, > libperl=libperl.so > gnulibc_version='2.11.2' > Dynamic Linking: > dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E > -Wl,-rpath,/usr/lib/perl5/5.12.1/i586-linux-thread-multi/CORE' > cccdlflags='-fPIC', lddlflags='-shared -fomit-frame-pointer > -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector > -funwind-tables -fasynchronous-unwind-tables -g -Wall -pipe' > > Locally applied patches: > > > --- > @INC for perl 5.12.1: > /usr/lib/perl5/site_perl/5.12.1/i586-linux-thread-multi > /usr/lib/perl5/site_perl/5.12.1 > /usr/lib/perl5/vendor_perl/5.12.1/i586-linux-thread-multi > /usr/lib/perl5/vendor_perl/5.12.1 > /usr/lib/perl5/5.12.1/i586-linux-thread-multi > /usr/lib/perl5/5.12.1 > . > > --- > Environment for perl 5.12.1: > HOME=/home/sdziegie > LANG=en_GB.UTF-8 > LANGUAGE (unset) > LC_COLLATE=POSIX > LD_LIBRARY_PATH=/usr/local/lib:/opt/experimental/lib:/usr/X11R6/lib: > LOGDIR (unset) >
PATH=/home/sdziegie/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/opt/gnome/bin:/usr/lib/qt3/bin:/usr/lib/festival:/usr/local/apache- Show quoted text
> maven-2.0.9/bin:/usr/lib/festival:/usr/local/apache-maven-2.0.9/bin > PERL_BADLANG (unset) > SHELL=/bin/bash
-- Father Chrysostomos --- via perlbug: queue: perl5 status: new https://rt.perl.org:443/rt3/Ticket/Display.html?id=108712
Download (untitled) / with headers
text/plain 275b
Thanks for the report. This has been fixed: https://github.com/perl-doc- cats/perlfaq/commit/9be0139bb81d7ba9645b5366c17685f60ffb419d Please submit pull requests against https://github.com/perl-doc-cats/perlfaq if you have further feedback (which is really appreciated!)


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.