[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Grepping only text files



On Tue, Jun 29, 1999 at 05:46:14PM -0400, Bill Jones wrote:
> Is there a 'strings'-equivalent function in perl?

>From the Perl Power Tools reconstruction of strings:
http://language.perl.com/ppt/src/strings/index.html

$length = 4;  # minimum length of a printable string.
$pat = qq{[\\011\\012\\040-\\176]{$length,}};
$/ = "\0";
while (<>) {
  while (/$pat/og) {
    print $&, "\n" ;
  }
  $l += length;
} continue { $l = 0 if eof }

-- 

Michael G Schwern                                           schwern@pobox.com
                    http://www.pobox.com/~schwern
     /(?:(?:(1)[.-]?)?\(?(\d{3})\)?[.-]?)?(\d{3})[.-]?(\d{4})(x\d+)?/i

==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org