From owner-freebsd-questions@FreeBSD.ORG Sun Jun 7 20:55:01 2009 Return-Path: Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CA07E106564A for ; Sun, 7 Jun 2009 20:55:01 +0000 (UTC) (envelope-from vogelke@hcst.com) Received: from beta.hcst.com (beta.hcst.com [192.52.183.241]) by mx1.freebsd.org (Postfix) with ESMTP id 6EAAC8FC08 for ; Sun, 7 Jun 2009 20:55:01 +0000 (UTC) (envelope-from vogelke@hcst.com) Received: from beta.hcst.com (localhost [127.0.0.1]) by beta.hcst.com (8.13.8/8.13.8/Debian-3) with ESMTP id n57Kt0ST003532 for ; Sun, 7 Jun 2009 16:55:00 -0400 Received: (from vogelke@localhost) by beta.hcst.com (8.13.8/8.13.8/Submit) id n57Kt0iE003531; Sun, 7 Jun 2009 16:55:00 -0400 Received: by kev.msw.wpafb.af.mil (Postfix, from userid 32768) id 5A2AFBED4; Sun, 7 Jun 2009 16:52:10 -0400 (EDT) To: freebsd-questions@FreeBSD.ORG In-reply-to: <20090607012158.GA14286@thought.org> (message from Gary Kline on Sat, 6 Jun 2009 18:22:00 -0700) Organization: Oasis Systems Inc. X-Disclaimer: I don't speak for the USAF or Oasis. X-GPG-ID: 1024D/711752A0 2006-06-27 Karl Vogel X-GPG-Fingerprint: 56EB 6DBF 4224 C953 F417 CC99 4C7C 7D46 7117 52A0 References: <20090607012158.GA14286@thought.org> Message-Id: <20090607205210.5A2AFBED4@kev.msw.wpafb.af.mil> Date: Sun, 7 Jun 2009 16:52:10 -0400 (EDT) From: vogelke+unix@pobox.com (Karl Vogel) Cc: Subject: Re: enclose code and testfile. X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: vogelke+unix@pobox.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jun 2009 20:55:02 -0000 >> On Sat, 6 Jun 2009 18:22:00 -0700, >> Gary Kline said: G> I'm encloseing a brief C program that skips over php delimiters and a G> 74-byte test file. Am wondering if there is a better way. #!/usr/bin/perl -w # skip PHP stuff in a file use strict; my ($prev, $match); # slurp up the entire file. undef $/; $_ = <>; while (s/ (.*?) # get text that doesn't include delimiters... (<\?.*?\?>) # ... plus text in ONE set of delimiters... //xsm) # ... matching across multiple lines { $prev = $1; # text before print "$prev"; } print "$_\n"; # whatever's left over. exit(0); -- Karl Vogel I don't speak for the USAF or my company Programming is like sex: one mistake and you have to support for a lifetime. --unknown