[31726] in Perl-Users-Digest
Perl-Users Digest, Issue: 2989 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 13 21:09:30 2010
Date: Sun, 13 Jun 2010 18:09:14 -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 Sun, 13 Jun 2010 Volume: 11 Number: 2989
Today's topics:
Re: Convert array into list context <uri@StemSystems.com>
Re: Convert array into list context <xhoster@gmail.com>
Re: Convert array into list context <nospam-abuse@ilyaz.org>
Re: Convert array into list context <uri@StemSystems.com>
Re: debugging regex expression in gui <cwilbur@chromatico.net>
Re: debugging regex expression in gui <pengyu.ut@gmail.com>
Re: debugging regex expression in gui <cwilbur@chromatico.net>
How to convert a literal string to regex <pengyu.ut@gmail.com>
Re: How to convert a literal string to regex <willem@turtle.stack.nl>
Re: How to convert a literal string to regex <tadmc@seesig.invalid>
Re: How to grep using an array of patterns? <willem@turtle.stack.nl>
Re: How to grep using an array of patterns? <tadmc@seesig.invalid>
Re: How to grep using an array of patterns? <john@castleamber.com>
Re: How to grep using an array of patterns? <cwilbur@chromatico.net>
Re: How to grep using an array of patterns? <john@castleamber.com>
Re: How to grep using an array of patterns? <uri@StemSystems.com>
Re: How to return the line number that right next to a <derykus@gmail.com>
Re: How to return the line number that right next to a <derykus@gmail.com>
Matching block of nested brace pairs <pengyu.ut@gmail.com>
Re: Matching block of nested brace pairs <cwilbur@chromatico.net>
Re: Matching block of nested brace pairs <pengyu.ut@gmail.com>
Re: Negative Lookbehind and Wildcards sln@netherlands.com
Re: Negative Lookbehind and Wildcards <derykus@gmail.com>
Re: Where is -e (file test operator) in man? <tadmc@seesig.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 13 Jun 2010 12:40:09 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Convert array into list context
Message-Id: <87ocfesx7a.fsf@quad.sysarch.com>
>>>>> "RC" == Ryan Chan <ryanchan404@gmail.com> writes:
RC> Consider the simple code.
RC> ============
RC> my @a = (1,2,'c');
RC> my $s = ('a' , @a);
regardless, that is throwing away 'a'. if you had warnings enabled, that
would be flagged. so why are you doing that? there is no benefit to that
construct.
RC> print $s;
RC> ============
RC> How to print out 'c' instead of 3?
why are you trying to do it the wrong and hard way? arrays in scalar
context return their count.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Sun, 13 Jun 2010 12:20:14 -0700
From: Xho Jingleheimerschmidt <xhoster@gmail.com>
Subject: Re: Convert array into list context
Message-Id: <4c15309c$0$29228$ed362ca5@nr5-q3a.newsreader.com>
Uri Guttman wrote:
>>>>>> "RC" == Ryan Chan <ryanchan404@gmail.com> writes:
>
> RC> Consider the simple code.
> RC> ============
> RC> my @a = (1,2,'c');
>
> RC> my $s = ('a' , @a);
>
> regardless, that is throwing away 'a'. if you had warnings enabled, that
> would be flagged. so why are you doing that? there is no benefit to that
> construct.
Of course not. But it did what he wanted, then there would be.
Xho
------------------------------
Date: Sun, 13 Jun 2010 23:45:33 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Convert array into list context
Message-Id: <slrni1arct.b0p.nospam-abuse@powdermilk.math.berkeley.edu>
On 2010-06-13, Ryan Chan <ryanchan404@gmail.com> wrote:
>> my $s = ('a' , @a)[-1];
> Yes, this work. Thanks.
> But it is ambiguous that we don't know when the array is being
> flattened, e.g. why not @a is being taken out.
The only thing ambiguous is who is "we" in this sentence. Scalar vs
List context is on of the few parts of Perl which has pretty good
documentation.
Yours,
Ilya
------------------------------
Date: Sun, 13 Jun 2010 20:51:30 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Convert array into list context
Message-Id: <87y6eiphbh.fsf@quad.sysarch.com>
>>>>> "XJ" == Xho Jingleheimerschmidt <xhoster@gmail.com> writes:
XJ> Uri Guttman wrote:
>>>>>>> "RC" == Ryan Chan <ryanchan404@gmail.com> writes:
>>
RC> Consider the simple code.
RC> ============
RC> my @a = (1,2,'c');
>>
RC> my $s = ('a' , @a);
>>
>> regardless, that is throwing away 'a'. if you had warnings enabled, that
>> would be flagged. so why are you doing that? there is no benefit to that
>> construct.
XJ> Of course not. But it did what he wanted, then there would be.
me thinks you have a grammar mistake or i don't get your second sentence
at all.
and the OP's need is still silly.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Sun, 13 Jun 2010 15:24:09 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: debugging regex expression in gui
Message-Id: <86ljai68iu.fsf@mithril.chromatico.net>
>>>>> "PY" == Peng Yu <pengyu.ut@gmail.com> writes:
PY> I want to debug regex to make sure that my regex is correct. A
PY> google search give me several debuggers, but I'm not sure which
PY> one best fit my needs.
We aren't either, since we don't know your needs. Try several of them
out for yourself and see.
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Sun, 13 Jun 2010 16:05:11 -0700 (PDT)
From: Peng Yu <pengyu.ut@gmail.com>
Subject: Re: debugging regex expression in gui
Message-Id: <612d4821-e7d5-41a2-9ed4-0182fc819f5e@a30g2000yqn.googlegroups.com>
On Jun 13, 2:24=A0pm, Charlton Wilbur <cwil...@chromatico.net> wrote:
> >>>>> "PY" =3D=3D Peng Yu <pengyu...@gmail.com> writes:
>
> =A0 =A0 PY> I want to debug regex to make sure that my regex is correct. =
A
> =A0 =A0 PY> google search give me several debuggers, but I'm not sure whi=
ch
> =A0 =A0 PY> one best fit my needs.
>
> We aren't either, since we don't know your needs. =A0Try several of them
> out for yourself and see.
I need something similar to http://kodos.sourceforge.net/, which is
python. But I don't see which perl tool is like it.
------------------------------
Date: Sun, 13 Jun 2010 20:07:51 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: debugging regex expression in gui
Message-Id: <8639wqsch4.fsf@mithril.chromatico.net>
>>>>> "PY" == Peng Yu <pengyu.ut@gmail.com> writes:
>> We aren't either, since we don't know your needs. Try several of
>> them out for yourself and see.
PY> I need something similar to http://kodos.sourceforge.net/, which
PY> is python. But I don't see which perl tool is like it.
Which ones have you tried? What didn't you like about them?
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Sun, 13 Jun 2010 08:39:03 -0700 (PDT)
From: Peng Yu <pengyu.ut@gmail.com>
Subject: How to convert a literal string to regex
Message-Id: <15151c59-9645-4397-83ff-10cf7d4b6968@d8g2000yqf.googlegroups.com>
Suppose I have $string='().',
If I want grep such string, I should use regex /\(\)\./. Is there a
subroutine to convert '().' to '\(\)\.'?
------------------------------
Date: Sun, 13 Jun 2010 15:55:17 +0000 (UTC)
From: Willem <willem@turtle.stack.nl>
Subject: Re: How to convert a literal string to regex
Message-Id: <slrni19vr5.2lbg.willem@turtle.stack.nl>
Peng Yu wrote:
) Suppose I have $string='().',
)
) If I want grep such string, I should use regex /\(\)\./. Is there a
) subroutine to convert '().' to '\(\)\.'?
You should read the docs for regular expressions.
Especially the bit about the \Q operator.
I'm sure it will be most helpful.
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
------------------------------
Date: Sun, 13 Jun 2010 11:04:40 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: How to convert a literal string to regex
Message-Id: <slrni1a021.agg.tadmc@tadbox.sbcglobal.net>
Peng Yu <pengyu.ut@gmail.com> wrote:
> Suppose I have $string='().',
>
> If I want grep such string, I should use regex /\(\)\./. Is there a
> subroutine to convert '().' to '\(\)\.'?
Please refrain from asking us to read the docs to you, it
is getting tiresome...
perldoc perlreref
Has a section named "FUNCTIONS".
That would probably be a good place to look for functions
having to do with regular expressions.
perldoc -f quotemeta
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
Date: Sun, 13 Jun 2010 15:23:58 +0000 (UTC)
From: Willem <willem@turtle.stack.nl>
Subject: Re: How to grep using an array of patterns?
Message-Id: <slrni19u0e.2ktu.willem@turtle.stack.nl>
Peng Yu wrote:
) On Jun 13, 9:46?am, Willem <wil...@turtle.stack.nl> wrote:
)> That depends on a number of things, such as how many items and times you
)> will be matching with the same set of patterns, how complex these patterns
)> are, and if you value maintainability over execution speed.
)
) Let's say I have only 10 simple patterns (just have non-special
) characters, a-z, A-Z, _, and \.) and they are mutually exclusive (if a
) file match one pattern it can not match another).
In that case you could probably join them into one regex quite easily:
my $patt = join('|', @patterns);
grep { /$patt/ } @array;
)> Possibilities I can think of offhand:
)> - Nested greps (two possible ways to nest)
)
) It seems that the above one is the simplest solution for this
) particular problem. Would you pleas show me some code on how to use
) nested greps?
grep { my $x = $_; grep { $x =~ /$_/ } @patterns } @array;
)> - Nested greps with precompiled regexes
)> - Combining search patterns into one big regex
)>
)> And there are probably more.
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
------------------------------
Date: Sun, 13 Jun 2010 11:08:02 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: How to grep using an array of patterns?
Message-Id: <slrni1a08b.agg.tadmc@tadbox.sbcglobal.net>
Peng Yu <pengyu.ut@gmail.com> wrote:
> If I only have a small number of patterns(say 3), I can just spell out
> the matching code as below.
>
> grep {/$pattern1$/ or /$pattern2$/ or /$pattern3$/} @array;
>
> But if I have @patterns with many patterns that I want grep, the above
^^^^
> way doesn't work. I'm wondering what is the best way to grep many
> patterns.
Please refrain from re-asking Frequently Asked Questions, it
is getting tiresome...
perldoc -q many
How do I efficiently match many regular expressions at once?
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
Date: Sun, 13 Jun 2010 13:01:10 -0500
From: John Bokma <john@castleamber.com>
Subject: Re: How to grep using an array of patterns?
Message-Id: <87ocfezuah.fsf@castleamber.com>
Tad McClellan <tadmc@seesig.invalid> writes:
> Peng Yu <pengyu.ut@gmail.com> wrote:
>> If I only have a small number of patterns(say 3), I can just spell out
>> the matching code as below.
>>
>> grep {/$pattern1$/ or /$pattern2$/ or /$pattern3$/} @array;
>>
>> But if I have @patterns with many patterns that I want grep, the above
> ^^^^
>> way doesn't work. I'm wondering what is the best way to grep many
>> patterns.
>
>
> Please refrain from re-asking Frequently Asked Questions, it
> is getting tiresome...
So do ivory towers reply.
> perldoc -q many
>
> How do I efficiently match many regular expressions at once?
Where is the example using grep as the OP asked? Oh, wait...
Again Tad, you DON'T HAVE TO POST. Control that smartass urge of yours,
thanks. It will make this group way more friendly.
--
John Bokma j3b
Hacking & Hiking in Mexico - http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
------------------------------
Date: Sun, 13 Jun 2010 15:25:26 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: How to grep using an array of patterns?
Message-Id: <86hbl668gp.fsf@mithril.chromatico.net>
>>>>> "JB" == John Bokma <john@castleamber.com> writes:
JB> Again Tad, you DON'T HAVE TO POST. Control that smartass urge of
JB> yours, thanks. It will make this group way more friendly.
Likewise, NOBODY REQUIRES YOU TO READ EVERY POST.
I'd rather the group be expert-friendly than lazy-newbie-friendly,
myself.
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Sun, 13 Jun 2010 19:05:39 -0500
From: John Bokma <john@castleamber.com>
Subject: Re: How to grep using an array of patterns?
Message-Id: <87mxuyfpgs.fsf@castleamber.com>
Charlton Wilbur <cwilbur@chromatico.net> writes:
>>>>>> "JB" == John Bokma <john@castleamber.com> writes:
>
> JB> Again Tad, you DON'T HAVE TO POST. Control that smartass urge of
> JB> yours, thanks. It will make this group way more friendly.
>
> Likewise, NOBODY REQUIRES YOU TO READ EVERY POST.
Well, the problem is, one has to open a post to see what is in it. And
since Tad does now and then post something interesting, I still consider
it worth to open his posts. In short, while true, your statement is
somewhat pointless.
> I'd rather the group be expert-friendly than lazy-newbie-friendly,
> myself.
I prefer something in the middle [1]. Also, try to keep in mind that a
lazy-newbie question can result in an interesting discussion that people
who are not lazy and who want to learn might cherish. I am sure you are
able to recall several examples of this.
Personally I wouldn't mind if everybody stopped replying to lazy-newbies
and have the FAQ bot post daily a message:
If you wonder why you don't get a reply...
with the usual pointers.
I am sure that it would improve the readability and the friendliness of
this group. And as since this sounds reasonable (at least to me) it will
never see the light of day.
[1] I hate it when regulars can get away with stuff they wouldn't let
any newbie get away with.
--
John Bokma j3b
Hacking & Hiking in Mexico - http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
------------------------------
Date: Sun, 13 Jun 2010 20:55:13 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: How to grep using an array of patterns?
Message-Id: <87typ6ph5a.fsf@quad.sysarch.com>
>>>>> "JB" == John Bokma <john@castleamber.com> writes:
JB> [1] I hate it when regulars can get away with stuff they wouldn't let
JB> any newbie get away with.
that is why they are called regulars. they have (usually) earned some
reputation points or have external (like cpan and other perl community)
experience worth listening too. teaching a newbie to use the FAQ is a
good thing. how that is done may be your issue but i like tad's way as
it hits hard and that is usually needed for newbies to get off the track
of asking FAQs. perl's faq collection is massive and written and edited
(here) very well. it is the best way to leverage the learning curve. i
always recommend to newbies to scan/skim the entire faq as soon as they
can. then read it in more depth as needed.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Sun, 13 Jun 2010 16:13:50 -0700 (PDT)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: How to return the line number that right next to a match?
Message-Id: <4ef66b9d-9197-4a59-9621-dff5eecc2a66@a16g2000prg.googlegroups.com>
On Jun 11, 8:57=A0pm, Peng Yu <pengyu...@gmail.com> wrote:
> After I did a regex match, I want to figure out what the line number
> is after the match in (). =A0Is there an easy way to do it?
>
> $string =3D~ /xxxx(somepattern)yyyy/;
The pre-match variable greatly simplifies the
solution, and with 5.10's /p switch, doesn't
incur a global performance penalty:
if ( $string =3D~ /somepattern/p ) {
my $linenum =3D {^PREMATCH} =3D~ tr/\n//;
}
--
Charles DeRykus
------------------------------
Date: Sun, 13 Jun 2010 16:15:50 -0700 (PDT)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: How to return the line number that right next to a match?
Message-Id: <865afa7f-85e8-487c-b3fb-2f3a72b762a7@11g2000prw.googlegroups.com>
On Jun 13, 4:13=A0pm, "C.DeRykus" <dery...@gmail.com> wrote:
> ...
>
> The pre-match variable greatly simplifies the
> solution, and with 5.10's /p switch, doesn't
> incur a global performance penalty:
>
> if ( $string =3D~ /somepattern/p ) {
> =A0 =A0my $linenum =3D {^PREMATCH} =3D~ tr/\n//;
^^^^^^^^^^^
${^PREMATCH}
------------------------------
Date: Sun, 13 Jun 2010 15:50:22 -0700 (PDT)
From: Peng Yu <pengyu.ut@gmail.com>
Subject: Matching block of nested brace pairs
Message-Id: <afab8de5-73e7-45d7-ab27-22c5e62c9549@w31g2000yqb.googlegroups.com>
Suppose I have some C++ code like the following, I want to match the
whole namespace x block.
namespace x
{
namespace y
{
....
}
}
The following webpage shows brace-matching for perl regex. But I don't
find the matchpairs module. (I'm using perl 5.10.1). Would you please
let me know if there is a way to match block of nested braces in perl?
http://dev.perl.org/perl6/rfc/145.html
------------------------------
Date: Sun, 13 Jun 2010 20:07:15 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: Matching block of nested brace pairs
Message-Id: <867hm2sci4.fsf@mithril.chromatico.net>
>>>>> "PY" == Peng Yu <pengyu.ut@gmail.com> writes:
PY> Would you please let me know if there is a way to match block of
PY> nested braces in perl?
Yes, there is. What did you find when you consulted the FAQ?
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Sun, 13 Jun 2010 18:00:21 -0700 (PDT)
From: Peng Yu <pengyu.ut@gmail.com>
Subject: Re: Matching block of nested brace pairs
Message-Id: <c43e34d3-2f20-4d65-9117-a74008f13e18@z8g2000yqz.googlegroups.com>
On Jun 13, 7:07=A0pm, Charlton Wilbur <cwil...@chromatico.net> wrote:
> >>>>> "PY" =3D=3D Peng Yu <pengyu...@gmail.com> writes:
>
> =A0 =A0 PY> Would you please let me know if there is a way to match block=
of
> =A0 =A0 PY> nested braces in perl?
>
> Yes, there is. =A0What did you find when you consulted the FAQ?
http://faq.perl.org/perlfaq6.html#Can_I_use_Perl_regul
The example on this link is daunting to me. I have read perlre.
$re =3D qr{ ( # paren group 1
(full function)
foo
( # paren group 2
(parens)
\(
( # paren group 3
(contents of parens)
(?:
(?> [^()]+ ) # Non-parens without
backtracking
|
(?2) # Recurse to start
of paren group 2
)*
)
\)
)
)
}x;
I still don't understand it how it works. What doesn't "Recurse to
start of paren group 2"?
For my specific problem (C++ namespace), would you please show me how
to do it and explain it to me how it works? Thank you!
------------------------------
Date: Sun, 13 Jun 2010 09:05:29 -0700
From: sln@netherlands.com
Subject: Re: Negative Lookbehind and Wildcards
Message-Id: <fvs916l8mr09gh90c0ugtkkfaeef4mvj9v@4ax.com>
On Sun, 13 Jun 2010 05:20:42 -0700 (PDT), Peng Yu <pengyu.ut@gmail.com> wrote:
>I try to match .cpp files that doesn't start with 'main'. But the grep
>command below match all the .cpp files. I know that \w* tries to match
>as long as possible. Do you know how to fix the regex to get all
>the .cpp files that doesn't start with 'main'?
>
>#!/usr/bin/env perl
>
>use strict;
>use warnings;
>
>my @array=qw(main.cpp main_xx.cpp uuu.cpp vvv.cpp);
>
>my @non_main_cpp=grep /(?<!main)\w*.cpp/, @array;
>print join(', ', @non_main_cpp), "\n";
The form was close but it won't work this way.
This concept is hard to grasp.
You can do it 1 of 2 ways:
With a negative look behind:
@non_main_cpp = grep /^(?:\w(?<!main))*\.cpp$/, @array;
This is what you tried to do.
Looking behind must be "visualized" as if YOU were the
current character as you traverse the string.
Each \w that is found in the accumulating match
must be immediatly tested that ^main isin't behind us.
Using ^ (?: \w (?<!main) )* on "main_xx.cpp" we see the
match progression:
main_xx.cpp
^ at the beginning, no ^main behind us
m^ still ok
ma^ ok
mai^ ok
main^ failed, ^main is behind us
Yours didn't work because the look behind was done
before the first \w was found. It then wen't on to
find all the \w* without even checkin the assertion.
Or, with a negative look ahead:
@non_main_cpp = grep /^(?!main)\w*\.cpp$/, @array;
This is a look ahead. As usual the object were looking
ahead of is to the left of the assertion.
In this case, its the begining of the line ^, before \w*.
The check is done once. If success, \w* will try to match,
but the assertion is never checked.
main_xx.cpp
^ at the beginning, failed ^main is ahead of us
For your circumstances, this is the preferred method.
----
What helps when you write regular expressions is to "be" the
character as you traverse the string. Make it a personal exercise.
I am a 9, I don't want 'a' or 'b' next to me, I want a space or
digit, I need this done five times from the beginning with
only the end of string in front of "us".
Yeah well, something like that..
-sln
------------------------------
Date: Sun, 13 Jun 2010 16:50:14 -0700 (PDT)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: Negative Lookbehind and Wildcards
Message-Id: <925baad0-16a4-4ea8-a887-3dafaaee1bf7@23g2000pre.googlegroups.com>
On Jun 13, 5:20=A0am, Peng Yu <pengyu...@gmail.com> wrote:
> I try to match .cpp files that doesn't start with 'main'. But the grep
> command below match all the .cpp files. I know that \w* tries to match
> as long as possible. Do you know how to fix the regex to get all
> the .cpp files that doesn't start with 'main'?
>
> #!/usr/bin/env perl
>
> use strict;
> use warnings;
>
> my @array=3Dqw(main.cpp main_xx.cpp uuu.cpp vvv.cpp);
>
> my @non_main_cpp=3Dgrep /(?<!main)\w*.cpp/, @array;
> print join(', ', @non_main_cpp), "\n";
Another option using /p and the ${^PREMATCH} variable:
my @non_main_cpp =3D
grep {/\.cpp$/p and ${^PREMATCH} !~ /^main/ }
@array;
--
Charles DeRykus
------------------------------
Date: Sun, 13 Jun 2010 11:48:44 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Where is -e (file test operator) in man?
Message-Id: <slrni1a2km.agg.tadmc@tadbox.sbcglobal.net>
Peng Yu <pengyu.ut@gmail.com> wrote:
> -e is discussed in operator section in Programming Perl. But I don't
> find it in man perlop. Would you please let me know where it is
> document in man or perldoc?
perldoc -f -e
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
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 2989
***************************************