From owner-freebsd-questions@FreeBSD.ORG Fri Jul 23 16:42:21 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9BB2E16A4CE for ; Fri, 23 Jul 2004 16:42:21 +0000 (GMT) Received: from pearl.ibctech.ca (dev.eagle.ca [209.167.58.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9803343D31 for ; Fri, 23 Jul 2004 16:42:18 +0000 (GMT) (envelope-from iaccounts@ibctech.ca) Received: (qmail 30331 invoked by uid 1002); 23 Jul 2004 16:42:29 -0000 Received: from iaccounts@ibctech.ca by pearl.ibctech.ca by uid 89 with qmail-scanner-1.22 (clamscan: 0.73. spamassassin: 2.63. Clear:RC:1(127.0.0.1):. Processed in 1.199947 secs); 23 Jul 2004 16:42:29 -0000 Received: from unknown (HELO webmail.ibctech.ca) (127.0.0.1) by localhost.ibctech.ca with SMTP; 23 Jul 2004 16:42:27 -0000 Received: from 209.167.16.15 (SquirrelMail authenticated user steve@ibctech.ca); by webmail.ibctech.ca with HTTP; Fri, 23 Jul 2004 12:42:27 -0400 (EDT) Message-ID: <1870.209.167.16.15.1090600947.squirrel@209.167.16.15> In-Reply-To: <20040723130007.V6864@cactus.fi.uba.ar> References: <1718.209.167.16.15.1090596743.squirrel@209.167.16.15> <20040723130007.V6864@cactus.fi.uba.ar> Date: Fri, 23 Jul 2004 12:42:27 -0400 (EDT) From: "Steve Bertrand" To: "Fernando Gleiser" User-Agent: SquirrelMail/1.4.3a X-Mailer: SquirrelMail/1.4.3a MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal cc: freebsd-questions@freebsd.org Subject: Re: Perl split() question (OT)... X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Jul 2004 16:42:21 -0000 > On Fri, 23 Jul 2004, Steve Bertrand wrote: > >> Perl hackers -- Figured someone would have a reasonably quick, easy >> answer >> for this: >> >> I am trying to read through a file, line-by-line, and I want to extract >> the text in between the [ and ] characters. > > This is a job for......capturing parens!!! > > Try this: > > if ($_=~/\[(.+)\]/) { > $var=$1; > } > > $1 would be the string matched by the regex between ( and ) > Absolutely perfect!! This worked excellent: while ($_ = ) { if ($_ =~ /$struct/ && $_ =~ /$structStart/) { if ($_ =~ /\[(.+)\]/) { $string = $1; print "$string -- $struct$structStart\n"; # ... do other stuff, snipped } } else { Thank-you so much! Steve > > > Fer >