Date: Tue, 6 Aug 1996 14:13:08 -0400 (EDT) From: Brian Clapper <bmc@telebase.com> To: nate@mt.sri.com Cc: kline@tera.com, questions@freebsd.org Subject: Re: ``tgrep'' from Unix Power Tools Message-ID: <199608061813.OAA08918@telebase.com.>
next in thread | raw e-mail | index | archive | help
Nate Williams writes: > > > > Has anyone used the short `tgrep' perl script from the UNIX > > > > POWER TOOLS book? It works on my Sun and fails with a strange > > > > error blurb on my FreeBSD machine. > > Ouch, sorry. tgrep always give this error: > > > > p5 8:42 <tao> [316] r 313 ~/tmp/TG/sbin > > ./tgrep the tgrep > > -T and -B not implemented on filehandles at (eval) line 7. > > And for those of us who don't have tgrep we can only guess as to what > line 7 looks like, or the rest of the script for that matter. :) man perlfunc -X A file test, where X is one of the letters listed below. ... -T File is a text file. -B File is a binary file (opposite of -T). ... The -T and -B switches work as follows. The first block or so of the file is examined for odd characters such as strange control codes or characters with the high bit set. If too many odd characters (>30%) are found, it's a -B file, otherwise it's a -T file. Also, any file containing null in the first block is considered a binary file. If -T or -B is used on a filehandle, the current stdio buffer is examined rather than the first block. Both -T and -B return TRUE on a null file, or a file at EOF when testing a filehandle. Because you have to read a file to do the -T test, on most occasions you want to use a -f against the file first, as in next unless -f $file && -T $file. The following test script works (under perl4.036) on Solaris 5.5 and UnixWare 1.1. It produces the `-T and -B not implemented on filehandles' error on FreeBSD (I'm running 2.2-960323-SNAP) using 4.036 or 5.002; it also fails with the same error under perl4.036 on an old Linux (1.2.x) box we have here. open (FH, $ARGV[0]) || die ("Can't open $ARGV[0] -- $!\n"); print "Text\n" if (-T FH); print "Binary\n" if (-B FH); close (FH); The clue is, no doubt, in the perl source. I haven't looked at it yet. ---- Brian Clapper .............................................. bmc@telebase.com http://www.netaxs.com/~bmc/ ............. PGP public key available on request Finagle's Fourth Law: Once a job is fouled up, anything done to improve it only makes it worse.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199608061813.OAA08918>