[32465] in Perl-Users-Digest
Perl-Users Digest, Issue: 3731 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 6 06:09:17 2012
Date: Fri, 6 Jul 2012 03:09:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 6 Jul 2012 Volume: 11 Number: 3731
Today's topics:
Regexp help <mikaelpetterson@hotmail.com>
Re: Regexp help <azra@glop.com>
Re: Regexp help <mikaelpetterson@hotmail.com>
Re: Regexp help <news@lawshouse.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 6 Jul 2012 00:20:55 -0700 (PDT)
From: mike <mikaelpetterson@hotmail.com>
Subject: Regexp help
Message-Id: <81bc6f2b-afc4-472f-8caf-372f48000076@googlegroups.com>
Hi,
I am using the following to find matches in a file.
open( PLUGINS, $pluginsBase ) or die "can't open $pluginsBase, $!\n";
while (<PLUGINS>) {
#Since list command shows both enabled and disabled versions of the plugin. Exclude disabled version in version check.
if ( /\$id/ && !/disable/ ) {
}
}
Problem I have is that when $id is equal to org.erlide it will also match contents of the file like:
org.erlide.trace
org.erlide.debug
How can I match the exact:
org.erlide
Nothing more nothing less.
br,
//mike
------------------------------
Date: Fri, 06 Jul 2012 09:34:48 +0200
From: azrazer <azra@glop.com>
Subject: Re: Regexp help
Message-Id: <jt64em$2er$1@speranza.aioe.org>
Hi,
would /^$id$/ do ?
Cheers,
azra
Le 06/07/2012 09:20, mike a écrit :
> Hi,
>
> I am using the following to find matches in a file.
>
> open( PLUGINS, $pluginsBase ) or die "can't open $pluginsBase, $!\n";
> while (<PLUGINS>) {
>
> #Since list command shows both enabled and disabled versions of the plugin. Exclude disabled version in version check.
> if ( /\$id/ && !/disable/ ) {
>
>
> }
>
> }
>
>
> Problem I have is that when $id is equal to org.erlide it will also match contents of the file like:
>
> org.erlide.trace
> org.erlide.debug
>
> How can I match the exact:
>
> org.erlide
>
> Nothing more nothing less.
>
> br,
>
> //mike
>
------------------------------
Date: Fri, 6 Jul 2012 01:26:35 -0700 (PDT)
From: mike <mikaelpetterson@hotmail.com>
Subject: Re: Regexp help
Message-Id: <dd00fdd8-b2b4-42b1-b87f-fa7d0e420f6a@googlegroups.com>
I tried it but I does not match at all. Here is an example of three lines that I read:
Feature: org.eclipse.equinox.p2.user.ui 2.1.2.R37x_v20110815-1155-6-Bk8pYWZz0qUTX5I15GZWwbXkrl enabled
Feature: org.erlide.tracing 0.2.2.201204301337 enabled
Feature: org.erlide 0.16.0.201204301337
we should only match org.erlide this exactly.
br,
//mike
------------------------------
Date: Fri, 06 Jul 2012 10:22:03 +0100
From: Henry Law <news@lawshouse.org>
Subject: Re: Regexp help
Message-Id: <U6-dnafWq4ymM2vSnZ2dnUVZ8jednZ2d@giganews.com>
On 06/07/12 09:26, mike wrote:
> Feature: org.eclipse.equinox.p2.user.ui 2.1.2.R37x_v20110815-1155-6-Bk8pYWZz0qUTX5I15GZWwbXkrl enabled
> Feature: org.erlide.tracing 0.2.2.201204301337 enabled
> Feature: org.erlide 0.16.0.201204301337
>
> we should only match org.erlide this exactly.
Oh, seeing the actual data would have helped azrazer ...
# assuming that $id is set to "org.erlide", then
if ( /\s$id\s/ && !/disable/ ) {
Or even more explicitly, assuming that all your data is as you've shown
if ( /^Feature: $id\s/ && !/disable/ ) {
BTW you'd coded /\$id/; that will match the string "$id", not the value
of the variable $id;
--
Henry Law Manchester, England
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 3731
***************************************