From owner-freebsd-questions@FreeBSD.ORG Fri Jul 23 15:32:14 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 C39D716A4CE for ; Fri, 23 Jul 2004 15:32:14 +0000 (GMT) Received: from pearl.ibctech.ca (dev.eagle.ca [209.167.58.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id EF02743D53 for ; Fri, 23 Jul 2004 15:32:13 +0000 (GMT) (envelope-from iaccounts@ibctech.ca) Received: (qmail 19217 invoked by uid 1002); 23 Jul 2004 15:32:24 -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.205412 secs); 23 Jul 2004 15:32:24 -0000 Received: from unknown (HELO webmail.ibctech.ca) (127.0.0.1) by localhost.ibctech.ca with SMTP; 23 Jul 2004 15:32:22 -0000 Received: from 209.167.16.15 (SquirrelMail authenticated user steve@ibctech.ca); by webmail.ibctech.ca with HTTP; Fri, 23 Jul 2004 11:32:23 -0400 (EDT) Message-ID: <1718.209.167.16.15.1090596743.squirrel@209.167.16.15> Date: Fri, 23 Jul 2004 11:32:23 -0400 (EDT) From: "Steve Bertrand" To: freebsd-questions@freebsd.org 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 Subject: 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 15:32:14 -0000 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. I would normally half the line by split() - ing the line first by [ as follows: if ($logLine =~ /$struct$structStart/) { @lineArray = split (/[/, $logLine); and then further, half again later using the ]. However, Perl does not like it when I search for [, as it thinks I am trying to use a regex. I have tried to escape the pattern, to no avail. Is there a 'special' escape for this, and more importantly, is there an easier way to extract data from a line of a file without having to split it up twice? An example of the line I'm trying to get the contents out of is this: | "LRED[Conversation started on 03 Feb 21:51:11] and I need the data between [ ... ]. I know it's OT, but hopefully someone can help me out. Tks! Steve