Thank you very much! :)
aSH
On Sunday, January 18, 2004, at 06:14 PM, Kenton Brede wrote:
On Sun, Jan 18, 2004 at 05:22:46PM +0100, aSH ([EMAIL PROTECTED]) wrote:Hello,
I'm trying to learn and use the patterns. This is my first "serious" try with perl.
I have a long list of words and phrases that I need to find.
Let's take this example. I want to find this patterns anywhere, no matter if there are followed by other characters:
Central PendingCall object PendingCall.getOutputParameter PendingCall.getOutputParameterByName PendingCall.getOutputParameters
I have been trying this:
pattern="m/Central PendingCall object/" pattern="m/PendingCall.getOutputParameter/"
But the last one it shadows PendingCall.getOutputParameterByName
So I tried this, but I'm not sure what this is doing:
pattern="m/\bPendingCall.getOutputParameter\b(?!B)/"
I want to find my patterns always, with repetitions.
I have been following this tutorial http://www.perldoc.com/perl5.6.1/pod/perlretut.html But now I need help with the code because I'm lost and I need to send my code.
First let me say I'm a beginner myself so the following is not necessarily best practice but it works. I'm sure someone will give you a better solution. It would be easier to help if you would have posted code but I've taken a stab at what you are trying to do.
#!/usr/bin/perl use warnings; use strict;
while (<DATA>) { print "$1\n" if m/\b(Central PendingCall object)\b/; print "$1\n" if m/\b(PendingCall.getOutputParameter)\b/; }
__DATA__ Central PendingCall object what the PendingCall.getOutputParameter add this that is the truth PendingCall.getOutputParameterByName Central PendingCall object the PendingCall.getOutputParameters Adding a line here PendingCall.getOutputParameter __END__
I think only one line really needs explanation here.
print "$1\n" if m/\b(Central PendingCall object)\b/;
"$1" contains the matched text in () "\b" defines a word boundary.
Hth, Kent
--
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
