From owner-freebsd-questions@FreeBSD.ORG Fri Jul 23 16:06:05 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 5E8B516A4CE for ; Fri, 23 Jul 2004 16:06:05 +0000 (GMT) Received: from mailgate1b.savvis.net (mailgate1b.savvis.net [216.91.182.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1963643D4C for ; Fri, 23 Jul 2004 16:06:05 +0000 (GMT) (envelope-from Lee.Carmichael@savvis.net) Received: from sl6exch3.savvis.ad.savvis.net (sl6exch3.it.savvis.net [10.12.134.21])i6NG5Urk027285; Fri, 23 Jul 2004 11:05:41 -0500 Received: from sl6exch4.savvis.ad.savvis.net ([10.12.134.23]) by sl6exch3.savvis.ad.savvis.net with Microsoft SMTPSVC(5.0.2195.6713); Fri, 23 Jul 2004 11:04:26 -0500 X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Date: Fri, 23 Jul 2004 11:02:28 -0500 Message-ID: <3B33FD3ADBD7054DB410CD9DA314133E02E73D2D@sl6exch4> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Perl split() question (OT)... Thread-Index: AcRwykVCmvFICfKvSq+X56Asy3arRgAA/eNQ From: "Carmichael, Lee" To: "Steve Bertrand" , X-OriginalArrivalTime: 23 Jul 2004 16:04:26.0421 (UTC) FILETIME=[BA4A1E50:01C470CE] X-ECS-MailScanner: No virus is found 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:06:05 -0000 Convert the /[/ to /\[/ and see if that works. Generally brackets mean a character class in perl regexs. You could also use single quotes. E.g. split('[', $line). Good luck, Lee > -----Original Message----- > From: Steve Bertrand [mailto:iaccounts@ibctech.ca] > Sent: Friday, July 23, 2004 10:32 AM > To: freebsd-questions@freebsd.org > Subject: Perl split() question (OT)... >=20 > Perl hackers -- Figured someone would have a reasonably quick, easy answer > for this: >=20 > 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: >=20 > if ($logLine =3D~ /$struct$structStart/) { > @lineArray =3D split (/[/, $logLine); >=20 > 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. >=20 > 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? >=20 > An example of the line I'm trying to get the contents out of is this: >=20 > | "LRED[Conversation started on 03 Feb 21:51:11] >=20 > and I need the data between [ ... ]. >=20 > I know it's OT, but hopefully someone can help me out. >=20 > Tks! >=20 > Steve >=20 > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions- > unsubscribe@freebsd.org"