Documentation TPIPE /string type code confusion

Aug 28, 2008
100
3
The documentation for the TPIPE /string filter shows the following type codes:
6 Remove lines matching the Perl pattern
7 Retain lines matching the Perl pattern
I'm finding the results I'm seeing a bit confusing, insofar as they seem the opposite of what this describes. Consider the following sample text:
This is George's first line
This is Jimmy's first line
This is George's second line
This is Jimmy's second line
When I type this text through "tpipe /string=6,0,m/George/", I get:
This is George's first line
This is George's second line
But when I type this text through "tpipe /string=7,0,m/George/" I get:
This is Jimmy's first line
This is Jimmy's second line
From the docs, I expected type code 6 to remove the lines with 'George' and code 7 to retain them, but the output suggests the opposite. Is this because TPIPE "filters" things, so from the perspective of retaining in the filter they go away while I guess 'remove' ends up meaning they pass through the filter and are seen? Whatever the case, it seems to me like the documentation might be a little confusing. Thanks in advance!
 
May 20, 2008
9,145
58
Syracuse, NY, USA
I don't know how or why, but the m// is confusing TPIPE.
Code:
v:\> type george.txt
This is George's first line
This is Jimmy's first line
This is George's second line
This is Jimmy's second line

v:\> type george.txt | tpipe /string=6,0,m/foo/
This is George's first line
This is George's second line
I don't think m/pattern/ is, strictly-speaking, a Perl "pattern" (rather a search instruction). All seems OK if I simply specify a pattern.
Code:
v:\> type george.txt | tpipe /string=6,0,"George"
This is Jimmy's first line
This is Jimmy's second line

v:\> type george.txt | tpipe /string=7,0,"George"
This is George's first line
This is George's second line

v:\> type george.txt | tpipe /string=6,0,George
This is Jimmy's first line
This is Jimmy's second line

v:\> type george.txt | tpipe /string=6,0,Ge..ge
This is Jimmy's first line
This is Jimmy's second line
 
May 20, 2008
9,145
58
Syracuse, NY, USA
I'm still not quite sure what TPIPE is doing on my last example. Below, in the first one, apparently TPIPE finds m in "Jimmy" and removes the lines; in the second, it finds g in "George" and removes those. It's just ignoring the "/foo/" in both cases.
Code:
v:\> type george.txt | tpipe /string=6,0,m/foo/
This is George's first line
This is George's second line

v:\> type george.txt | tpipe /string=6,0,g/foo/
This is Jimmy's first line
This is Jimmy's second line
 

rconn

Administrator
Staff member
May 14, 2008
10,885
97
I'm still not quite sure what TPIPE is doing on my last example. Below, in the first one, apparently TPIPE finds m in "Jimmy" and removes the lines; in the second, it finds g in "George" and removes those. It's just ignoring the "/foo/" in both cases.
Code:
v:\> type george.txt | tpipe /string=6,0,m/foo/
This is George's first line
This is George's second line

v:\> type george.txt | tpipe /string=6,0,g/foo/
This is Jimmy's first line
This is Jimmy's second line
TPIPE thinks your /foo/ argument is a new switch for TPIPE. Enclose it in double quotes if you don't want it to be parsed as a switch; i.e.:

Code:
type george.txt | tpipe /string=6,0,"m/foo/"
TPIPE will strip the quotes before parsing the file.