Re: How to find regex at specific location on line

2005-01-25 Thread renard
I am a newbie and have been following this thread since I am interested in benchmarking. So I copied the code and ran it on my machine. I have a 3.5 MHz system runing Windows XP. I am using ActivePerl 3.8.6. On my machine, benchmark complained about too few iterations. So I modified the script in

Re: How to find regex at specific location on line

2005-01-25 Thread Jay
On Tue, 25 Jan 2005 14:39:42 -0500, renard [EMAIL PROTECTED] wrote: I am a newbie and have been following this thread since I am interested in benchmarking. So I copied the code and ran it on my machine. I have a 3.5 MHz system runing Windows XP. I am using ActivePerl 3.8.6. On my

Re: How to find regex at specific location on line

2005-01-24 Thread Dave Gray
'plain_regex'= sub { if ( $string =~ /^.{38}\|[BNPG]\|/ ) { my $a = $_ } }, 'plain_regex'= sub { if ( $string =~ /^.{38}\|N\|/ ) { my $a = $_ } }, What was interesting to me was that although, predictably, the substring/regex combo was consistently the best performer for

RE: How to find regex at specific location on line

2005-01-24 Thread Jason Balicki
Thanks to everyone that answered this question. I ended up using (/^.{30}\|[BNPG]\|/). I plan on adding some more checks for | at specific locations (other than just ^ and $, which I have now) for sanity's sake. Thanks again. Would it be helpful to others if I were to post the complete script

RE: How to find regex at specific location on line

2005-01-24 Thread Graeme St. Clair
I knew what I meant, I just didn't write what I meant. Next time, I'll have a coffee first... Of course you're right I forgot to anchor it too. Rgds, GStC. -Original Message- From: John W. Krahn [mailto:[EMAIL PROTECTED] Sent: Saturday, January 22, 2005 8:41 PM To: Perl Beginners

Re: How to find regex at specific location on line

2005-01-24 Thread Jay
On Mon, 24 Jan 2005 10:46:38 -0500, Dave Gray [EMAIL PROTECTED] wrote: 'plain_regex'= sub { if ( $string =~ /^.{38}\|[BNPG]\|/ ) { my $a = $_ } }, 'plain_regex'= sub { if ( $string =~ /^.{38}\|N\|/ ) { my $a = $_ } }, What was interesting to me was that although,

Re: How to find regex at specific location on line

2005-01-23 Thread Jay
On Sat, 22 Jan 2005 13:34:54 -0800, John W. Krahn [EMAIL PROTECTED] wrote: Yes, two ways that I can think of: if ( substr( $_, 30, 3 ) =~ /\|[BNPG]\|/ ) { if ( /^.{30}\|[BNPG]\|/ ) { John -- For the sake of comparison, here is a set of benckmarks for a couple of

How to find regex at specific location on line

2005-01-22 Thread Jason Balicki
Hello, If you would, please consider the following input file: code |6643|Jason Balicki | |0501211243|000:00:00|0| S |0| ||13145551212 |N|| 0|001001|001001| 100| 10|B|A| /code And the following code: code while(){ if (whichline($_)

Re: How to find regex at specific location on line

2005-01-22 Thread John W. Krahn
Jason Balicki wrote: Hello, Hello, If you would, please consider the following input file: code |6643|Jason Balicki | |0501211243|000:00:00|0| S |0| ||13145551212 |N|| 0|001001|001001| 100| 10|B|A| /code And the following code: code while(){

RE: How to find regex at specific location on line

2005-01-22 Thread Graeme St. Clair
Try the {} notation, that says how many whats are required before the which (as it were). Perhaps something like:- if (/.{31,33}\|[BNPG]\|/){ return 2; } Meaning, between 31 33 characters. Untested! HTH, GStC. -Original Message- From: Jason Balicki

Re: How to find regex at specific location on line

2005-01-22 Thread John W. Krahn
Graeme St. Clair wrote: Try the {} notation, that says how many whats are required before the which (as it were). Perhaps something like:- if (/.{31,33}\|[BNPG]\|/){ return 2; } Meaning, between 31 33 characters. Untested! No, that is not what it means. It means match