RE: pattern match

2006-07-11 Thread Timothy Johnson
At the moment I can't think of why this makes a difference (somebody help me here), but you aren't specifying a mode for the open() function. Also, you're not checking whether your match succeeded before using $1 (which is what I think you meant on that last line). I personally would write it a li

Re: pattern match

2006-07-11 Thread Mr. Shawn H. Corey
Ryan Dillinger wrote: > Hello, > I had two scripts that were identical, well almost. I ran the two > together, but > straghtened them out. Anyway I have one here, that when ran say's: Use > of uninitialized > value in pattern match (m//) at headline.pl line 7 and 10. I have > changed differernt thi

Re: pattern match

2006-07-11 Thread Mr. Shawn H. Corey
Ryan Dillinger wrote: > Hello, > I had two scripts that were identical, well almost. I ran the two > together, but > straghtened them out. Anyway I have one here, that when ran say's: Use > of uninitialized > value in pattern match (m//) at headline.pl line 7 and 10. I have > changed differernt thi

Re: pattern match

2006-07-11 Thread Mumia W.
Ryan Dillinger wrote: > [...] > #!/usr/bin/perl > use warnings; > use strict; > > open LYNX, "lynx -source http://www.perl.com/ |" or die "Can't open lynx: > $!"; > $_ = ""; > $_ = until /standard\.def/; > If 'standard.def' is not found, this line loops forever. > my $head = ; > $head =~ m|^]

Re: pattern match

2006-07-12 Thread Rob Dixon
Ryan Dillinger wrote: > > Hello, Hi Ryan > I had two scripts that were identical, well almost. I ran the two together, > but straghtened them out. Anyway I have one here, that when ran say's: Use of > uninitialized value in pattern match (m//) at headline.pl line 7 and 10. I > have changed dif

RE: pattern match

2006-07-13 Thread Ken Foskey
On Tue, 2006-07-11 at 18:48 -0700, Timothy Johnson wrote: > open(LYNX,"<","lynx -source http://www.perl.com/ |") or die("Can't open > lynx: $!"); I am not sure that this is right. open(LYNX,"|-","lynx -source http://www.perl.com/";) or die("Can't open lynx: $!"); I think this is. Ta Ken --

Re: pattern match

2006-07-13 Thread Dr.Ruud
Ken Foskey schreef: > open(LYNX,"|-","lynx -source http://www.perl.com/";) or die("Can't open > lynx: $!"); #!/usr/bin/perl use warnings ; use strict ; my $cmd = 'lynx -source http://www.perl.com/' ; open my $ph, '-|', $cmd or die "\nError opening '$cmd', stopped $!" ; while ( <

Re: Pattern Match

2003-12-09 Thread Rob Dixon
Eric Sand wrote: > > I am very new to Perl, but I sense a great adventure ahead after just > programming with Cobol, Pascal, and C over the last umpteen years. I have > written a perl script where I am trying to detect a non-printing > character(Ctrl@ - Ctrl_) and then substitute a printing AS

RE: Pattern Match

2003-12-09 Thread Tom Kinzer
[mailto:[EMAIL PROTECTED] Sent: Tuesday, December 09, 2003 11:58 AM To: [EMAIL PROTECTED] Subject: Re: Pattern Match Eric Sand wrote: > > I am very new to Perl, but I sense a great adventure ahead after just > programming with Cobol, Pascal, and C over the last umpteen years. I have >

Re: Pattern Match

2003-12-09 Thread James Edward Gray II
On Dec 9, 2003, at 2:37 PM, Tom Kinzer wrote: Rob, can you explain the details of that replace? That's pretty slick. I see you're adding the hex value to get to the appropriate ASCII value, but didn't know you could do some of that gyration inside a regex. The big secret there is the /e modifi

Re: Pattern Match

2003-12-09 Thread Rob Dixon
Tom Kinzer wrote: > > Rob Dixon wrote: > > > > Eric Sand wrote: > > > > > > I am very new to Perl, but I sense a great adventure ahead after just > > > programming with Cobol, Pascal, and C over the last umpteen years. I have > > > written a perl script where I am trying to detect a non-printin

Re: Pattern Match

2003-12-09 Thread Robert Brown
Rob Dixon writes: > Tom Kinzer wrote: > I didn't think it was slick at all. In fact I was disappointed that > it looked such a mess, but I don't see a better way. Yes, it is indeed a mess, not only syntacticly, but also semantically. While it might make a good teaching example to show what y

Re: Pattern Match

2003-12-09 Thread Rob Dixon
Robert Brown wrote: > > Rob Dixon writes: > > > Tom Kinzer wrote: > > > I didn't think it was slick at all. In fact I was disappointed that > > it looked such a mess, but I don't see a better way. > > Yes, it is indeed a mess, not only syntacticly, but also semantically. > While it might make a

Re: Pattern Match

2003-12-09 Thread Robert Brown
Rob Dixon writes: > Robert Brown wrote: > > > > Rob Dixon writes: > > > > > Tom Kinzer wrote: > > > > > I didn't think it was slick at all. In fact I was disappointed that > > > it looked such a mess, but I don't see a better way. > > > > Yes, it is indeed a mess, not only syntacticly,

Re: Pattern Match

2003-12-09 Thread Rob Dixon
Robert Brown wrote: > > Rob Dixon writes: > > Robert Brown wrote: > > > > > > Rob Dixon writes: > > > > > > > Tom Kinzer wrote: > > > > > > > I didn't think it was slick at all. In fact I was disappointed that > > > > it looked such a mess, but I don't see a better way. > > > > > > Yes

Re: Pattern Match

2003-12-09 Thread John W. Krahn
Eric Sand wrote: > > Hi All, Hello, > I am very new to Perl, Welcome. :-) > but I sense a great adventure ahead after just > programming with Cobol, Pascal, and C over the last umpteen years. "Thinking in Perl" may take a while but it is not your grandfather's programming language (sorry

Re: Pattern Match

2003-12-09 Thread John W. Krahn
Rob Dixon wrote: > > I didn't think it was slick at all. In fact I was disappointed that it looked > such a mess, but I don't see a better way. Anyway, the statement is > > s/([\x00-\1F])/'^'.chr(ord($1) + 0x40)/eg > > where the regex is > > ([\x00-\1F]) Oops. That matches the characters

Re: Pattern Match

2003-12-09 Thread Robert Brown
Rob Dixon writes: > I'm sure you have something useful to say. This seems such a waste of > your effort. > > Rob I think we are failing to communicate. What I am asking is: "Does the regular expression mechanism in perl optimize regular expressions such as the one you used earlier in this t

Re: Pattern Match

2003-12-09 Thread Casey West
It was Tuesday, December 09, 2003 when Robert Brown took the soap box, saying: : Rob Dixon writes: : > I'm sure you have something useful to say. This seems such a waste of : > your effort. : > : > Rob : : I think we are failing to communicate. What I am asking is: Thanks for the clarificat

Re: Pattern Match

2003-12-09 Thread Robert Brown
Casey West writes: > : "Does the regular expression mechanism in perl optimize regular > : expressions such as the one you used earlier in this thread so that > : the execution overhead is nearly as good as the C approach I outlined > : earlier in this thread? In other words, for the problem s

Re: Pattern Match

2003-12-10 Thread mcdavis941
Since we're now talking about performance issues, somebody should say something about precompiling the regular expression, when you can, with either /o or qr(). I had a process's running time go from 2min 45sec to just under 24sec simply by using qr on the relevant regular expressions. Robert

Re: Pattern Match

2003-12-10 Thread Rob Dixon
Before I finally burst my cyanide capsule, may I.. ? Rj wrote: > > Rob Dixon writes: > > > > I didn't think it was slick at all. In fact I was > > disappointed that it looked such a mess, but I don't see > > a better way. > > Yes, it is indeed a mess, not only syntacticly, but also > semantically.

Re: Pattern Match

2003-12-10 Thread Jenda Krynicky
From: Robert Brown <[EMAIL PROTECTED]> > Casey West writes: > > : "Does the regular expression mechanism in perl optimize regular > > : expressions such as the one you used earlier in this thread so that > > : the execution overhead is nearly as good as the C approach I > outlined > : earlier i

Re: Pattern Match

2003-12-10 Thread Robert Brown
On Wed, 10 Dec 2003 20:11:26 +0100, "Jenda Krynicky" <[EMAIL PROTECTED]> wrote: > > 1. Perl builtins and especialy the regular expression engine is > heavily optimized. So it might very well be quicker to use a regexp > from Perl than to implement the same stuff in C. Unless you spend a >

Re: Pattern Match

2003-12-10 Thread R. Joseph Newton
Robert Brown wrote: > Casey West writes: > Sorry again for my confusing way of expressing myself. Although I > wrote my example in C, that was because I am a novice perl programmer, > but an experienced C programmer, so I expressed my algorithm in C. > > The idea was to compare the execution effe

Re: Pattern Match

2003-12-10 Thread Robert Brown
R. Joseph Newton writes: > When used consciously, with at least a general awareness of the processing > load being invoked, regexes can do some really incredible things. Thanks! I especially appreciate the example you gave showing how to trim both ends of a string: that it is more efficient to

Re: Pattern Match

2003-12-12 Thread Rob Dixon
Robert Brown wrote: > > R. Joseph Newton writes: > > When used consciously, with at least a general awareness of the processing > > load being invoked, regexes can do some really incredible things. > > Thanks! I especially appreciate the example you gave showing how to > trim both ends of a stri

RE: pattern match

2002-04-12 Thread Timothy Johnson
If word1 and word2 are on the same line, you could do something like this: open(INFILE,"myfile.txt"); open(OUTFILE,">results.txt"); while(){ while($_ =~ /word1(.*)word2/g){ #get all characters between word1 and word2, one match at a time print OUTFILE $1."\n"; } } Someone else might

Re: pattern match

2002-04-12 Thread drieux
On Friday, April 12, 2002, at 12:38 , Raghupathy, Ramesh . wrote: > I am sorry I was not clear in my question. > >The word1 and word2 may occur on different lines of the file and may > occur in different combinations. > > for e.g : > > (not showing the new lines..) > > > word1.word1.

RE: pattern match

2002-04-12 Thread David Gray
> for e.g : > > (not showing the new lines..) > > > word1.word1.word1word2word1...word2wor > d2word2 > . You're gonna want to check out (in the perldoc perlre manpage) (??{ code }), which is an example of a recursive regular expression. They have an exampl

Re: pattern match

2002-04-12 Thread bob ackerman
On Friday, April 12, 2002, at 12:58 PM, David Gray wrote: >> for e.g : >> >> (not showing the new lines..) >> >> >> word1.word1.word1word2word1...word2wor >> d2word2 >> . > > You're gonna want to check out (in the perldoc perlre manpage) (??{ code > }), which

Re: pattern match

2002-04-15 Thread bob ackerman
ll tell me you don't want to read the whole file in at once :) that's when you have to do like what i offered the first time. >> Thanks, >> Ramesh >> >> -Original Message- >> From: bob ackerman [mailto:[EMAIL PROTECTED]] >> Sent: Friday, April

Re: Pattern match

2004-06-21 Thread Gunnar Hjalmarsson
Naser Ali wrote: I have an array which was created by slurrping a whole text file. There are certain element in the array after reading the files which contain only one word. I want to only match those array elements which contain a single word and print it. You need to anchor the word to both the

Re: Pattern match

2004-06-21 Thread Roberto Etcheverry
It's difficult to answer if you do not post the code with some input to test it, but lets suppose you have this: my @array; @array = ; # slurp whole file Then is easy to get what you want: my @lines_with_single_word = grep /^\s*\S+\s*$/,array; # ^\s*\S+\s*$ means beginning of line, 0 or more wh

Re: Pattern match

2004-06-21 Thread Chris Charley
- Original Message - From: "Naser Ali" <[EMAIL PROTECTED]> Newsgroups: perl.beginners To: <[EMAIL PROTECTED]> Sent: Monday, June 21, 2004 3:52 PM Subject: Pattern match > Hello, > > I have an array which was created by slurrping a whole text file. There are > certain element in the arra

RE: Pattern match

2004-06-22 Thread Naser Ali
- From: Roberto Etcheverry [mailto:[EMAIL PROTECTED] Sent: Monday, June 21, 2004 5:44 PM To: Naser Ali Cc: [EMAIL PROTECTED] Subject: Re: Pattern match It's difficult to answer if you do not post the code with some input to test it, but lets suppose you have this: my @array; @array = ;

Re: Pattern match

2004-06-22 Thread Gunnar Hjalmarsson
Naser Ali wrote: It works, What is it that works? The data pattern looks like this; Aword Yep, that's one word. Aword Anotherword That's two words. None of the posted suggestions matches that line. You said in your original post: "I want to only match those array elements which contain a single wo

Re: Pattern match

2004-06-22 Thread John W. Krahn
Naser Ali wrote: > > Naser Ali wrote: > > > >I have an array which was created by slurrping a whole text file. There > >are certain element in the array after reading the files which contain > >only one word. I want to only match those array elements which contain > >a single word and print it. Tr

RE: pattern match

2007-02-12 Thread Wagner, David --- Senior Programmer Analyst --- WGO
> -Original Message- > From: Vladimir Lemberg [mailto:[EMAIL PROTECTED] > Sent: Monday, February 12, 2007 12:33 > To: beginners@perl.org > Subject: pattern match > > Hi, > > I have a script, which suppose to find all *.xml files under > the specified directory then process them. > I'm

Re: pattern match

2007-02-12 Thread Vladimir Lemberg
David, Thanks you very much! It works -) - Original Message - From: "Wagner, David --- Senior Programmer Analyst --- WGO" <[EMAIL PROTECTED]> To: "Vladimir Lemberg" <[EMAIL PROTECTED]>; Sent: Monday, February 12, 2007 12:46 PM Subject: RE: pattern

Re: pattern match

2007-02-12 Thread D. Bolliger
Vladimir Lemberg am Montag, 12. Februar 2007 21:33: > Hi, Hi Vladimir (in addition to Davids post) > I have a script, which suppose to find all *.xml files under the specified > directory then process them. I'm facing the pattern match problem: > > use strict; > use warnings; > use Win32; > use

Re: pattern match

2007-02-12 Thread John W. Krahn
Vladimir Lemberg wrote: > Hi, Hello, > I have a script, which suppose to find all *.xml files under the specified > directory then process them. I'm facing the pattern match problem: > > use strict; > use warnings; > use Win32; > use File::Find; > > @ARGV = Win32::GetCwd() unless @ARGV; Why a

Re: pattern match

2007-02-12 Thread Mumia W.
On 02/12/2007 02:33 PM, Vladimir Lemberg wrote: Hi, I have a script, which suppose to find all *.xml files under the specified directory then process them. I'm facing the pattern match problem: use strict; use warnings; use Win32; use File::Find; @ARGV = Win32::GetCwd() unless @ARGV; my @di

Re: pattern match

2007-02-12 Thread D. Bolliger
Mumia W. am Montag, 12. Februar 2007 21:53: > On 02/12/2007 02:33 PM, Vladimir Lemberg wrote: > > Hi, > > > > I have a script, which suppose to find all *.xml files under the > > specified directory then process them. I'm facing the pattern match > > problem: > > > > use strict; > > use warnings; >

RE: pattern match

2001-12-28 Thread Hanson, Robert
It will match the same text, but it will not grab the same data into $1, $2, and $3. The first one will assign each of these vars while the second will only assign $1 with the last (\s+\d+). Rob -Original Message- From: Srinivas Reddy [mailto:[EMAIL PROTECTED]] Sent: Friday, December 2

Re: Pattern match question

2009-05-27 Thread Alexander Koenig
You wrote on 05/27/2009 10:50 AM: > I want to match one ... pair. > > my code : > > my $pattern = "()"; ... > but I got the whole matches instead of one ... pair each loop. Do need to de-greedify it. my $pattern = "()"; This should do the trick. hth Alex -- To unsubscribe, e-mail: beginner

Re: Pattern match question

2009-05-27 Thread Jenda Krynicky
Date sent: Wed, 27 May 2009 16:50:41 +0800 Subject:Pattern match question From: Á÷Ë(R)`Oô To: beginners@perl.org > Hi, All: > > I want to parse data from a HTML page, data like: > > > > >

Re: Pattern match operator

2013-05-04 Thread Rob Dixon
On 04/05/2013 14:26, Florian Huber wrote: I'm parsing a logfile and don't quite understand the behaviour of m//. From a previous regex match I have already captured $+{'GFP'}: use strict; use warnings; (...) $text =~ m/ (?FILTERS .*? WRT)/x;# I simply have my whole logfile in $text - I

Re: Pattern match operator

2013-05-04 Thread Florian Huber
On 05/04/2013 04:37 PM, Rob Dixon wrote: On 04/05/2013 14:26, Florian Huber wrote: I'm parsing a logfile and don't quite understand the behaviour of m//. From a previous regex match I have already captured $+{'GFP'}: use strict; use warnings; (...) $text =~ m/ (?FILTERS .*? WRT)/x;# I

Re: Pattern match operator

2013-05-04 Thread Jim Gibson
On May 4, 2013, at 11:53 AM, Florian Huber wrote: > On 05/04/2013 04:37 PM, Rob Dixon wrote: >> On 04/05/2013 14:26, Florian Huber wrote: >>> >>> >> >> Hello Florian >> >> First a couple of points >> >> - Don't use named captures for simple regexes like this. They make the >> code harder

[ADMIN] Re: Pattern Match

2003-12-10 Thread Casey West
It was Wednesday, December 10, 2003 when Rob Dixon took the soap box, saying: : Before I finally burst my cyanide capsule, may I.. ? No, you may not. I find walking around the block a good way to cool off. Counting to ten has never done it for me, but you may try. *Both* of you. Thanks for killi

RE: pattern match problem

2003-02-13 Thread Wagner, David --- Senior Programmer Analyst --- WGO
tao wang wrote: > hi, > > I'm trying to write a script to match a pattern like > this: 1.10 > > I wrote [\d.]+, but this also match with pattern ... > , which has no number in it. Could somebody help me > with it? I'm new to perl and scripts. thanks a lot. /^\d+\.\d+/ which says ancho

RE: pattern match problem

2003-02-13 Thread Timothy Johnson
How about something like this? /\d{0,3}\.\d{0,3}/ which should match 0-3 digits followed by a period followed by 0-3 digits. You should be able to see how you can change it if you want to expand how many digits to capture. You could also try: /\d+\.\d+/ Which matches one or more digits follo

Re: pattern match problem

2003-02-13 Thread Wiggins d'Anconia
tao wang wrote: hi, I'm trying to write a script to match a pattern like this: 1.10 I wrote [\d.]+, but this also match with pattern ... , which has no number in it. Could somebody help me with it? I'm new to perl and scripts. thanks a lot. \d.\d+ \d+.\d+ \d*.\d* \d+\.+\d+ \d+\.*\d+ \

Re: pattern match problem

2003-02-13 Thread ktb
On Thu, Feb 13, 2003 at 04:39:17PM -0800, tao wang wrote: > hi, > > I'm trying to write a script to match a pattern like > this: 1.10 > > I wrote [\d.]+, but this also match with pattern ... > , which has no number in it. Could somebody help me > with it? I'm new to perl and scripts. thank

Re: pattern match question

2004-05-05 Thread Jose Alves de Castro
I would do /(?<=Retrieval command for )http:.*?:/ The "Retrieval" part now is contained in a "Look behind section", which is to mean it's not going to be stored as part of the match. I'm not sure what other cases you can get in that log file, but this solves the problem for that particular line

Re: pattern match question

2004-05-05 Thread Graeme McLaren
ROTECTED]> To: Graeme McLaren <[EMAIL PROTECTED]> CC: [EMAIL PROTECTED] Subject: Re: pattern match question Date: 05 May 2004 11:09:19 +0100 MIME-Version: 1.0 Received: from onion.perl.org ([63.251.223.166]) by mc5-f36.hotmail.com with Microsoft SMTPSVC(5.0.2195.6824); Wed, 5 May 2004 03:13:0

Re: pattern match question

2004-05-05 Thread Jose Alves de Castro
/(?<=Retrieval command for )http:.*?:/){ > > It prints off the "Retrieval command for" part as it did before :( > > > any ideas? > > > Cheers, > > Graeme :) > > > > >From: Jose Alves de Castro <[EMAIL PROTECTED]> > >To: Gr

[Correction] Re: pattern match

2007-02-12 Thread D. Bolliger
D. Bolliger am Montag, 12. Februar 2007 23:03: > Mumia W. am Montag, 12. Februar 2007 21:53: > > On 02/12/2007 02:33 PM, Vladimir Lemberg wrote: [snipped] Mumia, please excuse me for my inappropriate correction! > > You probably want to push the filename onto the array if you get a > > successfu

RE: Pattern match woos

2001-12-05 Thread Sonia Patel
Hello, I'm currently working with using regexp to extract XML: Try this: open(F,"$i"); while (defined( $p = )) { chomp($p); # Change statement if ($p=~ /^(.+?)/){ $code=$1; print $code; } -Original Message- From: Dermot Paikkos [mailt

Re: Pattern match woos

2001-12-05 Thread Maxim Berlin
Hello Dermot, Wednesday, December 05, 2001, Dermot Paikkos <[EMAIL PROTECTED]> wrote: DP> Hi there, DP> This is both frustrating and embarrassing. I can't capture the DP> following data into a variable. The line I want is: DP> GIAZUC00 DP> I have tried a multitude of Regex, none seems to be w

Re: Pattern match woos

2001-12-05 Thread Leon
- Original Message - From: "Dermot Paikkos" <[EMAIL PROTECTED]> > Hi there, > This is both frustrating and embarrassing. I can't capture the > following data into a variable. The line I want is: > GIAZUC00 > > I have tried a multitude of Regex, none seems to be working. Here's > my last at

Re: [ADMIN] Re: Pattern Match

2003-12-10 Thread Rob Dixon
Casey West wrote: > > : Before I finally burst my cyanide capsule, may I.. ? > > No, you may not. > > I find walking around the block a good way to cool off. Counting to ten > has never done it for me, but you may try. *Both* of you. > > Thanks for killing the personal tension between you two, on t

Re: [ADMIN] Re: Pattern Match

2003-12-10 Thread Casey West
It was Wednesday, December 10, 2003 when Rob Dixon took the soap box, saying: : Casey West wrote: : > : > : Before I finally burst my cyanide capsule, may I.. ? : > : > No, you may not. : > : > I find walking around the block a good way to cool off. Counting to ten : > has never done it for me, but

Re: [Correction] Re: pattern match

2007-02-12 Thread Mumia W.
On 02/12/2007 04:17 PM, D. Bolliger wrote: D. Bolliger am Montag, 12. Februar 2007 23:03: Mumia W. am Montag, 12. Februar 2007 21:53: On 02/12/2007 02:33 PM, Vladimir Lemberg wrote: [snipped] Mumia, please excuse me for my inappropriate correction! [...] No problem. I'm glad I tested it be