RE: [Boston.pm] Calling regex gurus ..A regex question..

2002-10-11 Thread Ranga Nathan
Thanks for all the contributions. You are a wonderfully helpful bunch! > -Original Message- > From: london [mailto:london] On Behalf Of [EMAIL PROTECTED] > Sent: Friday, October 11, 2002 3:29 PM > To: Uri Guttman > Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: Re: [Boston.pm] Calling

RE: [Boston.pm] Calling regex gurus ..A regex question..

2002-10-11 Thread Ranga Nathan
A bit more to add.. I found that with /^((\d+)\s+(??{ use re 'eval'; my $re = '\S+\s*'x$+; qr($re); }))/ , I get only $1, that is because the paren before ?? Seems to be non-capturing. Bought one more pair of parens and got $2. I already mentioned the use re 'eval'; This is a problem I have

Re: [Boston.pm] Calling regex gurus ..A regex question..

2002-10-11 Thread Anthony R. J. Ball
No problem... well.. there were some problems... but it was mainly because I forgot the last +... hehe On Fri, Oct 11, 2002 at 04:32:51PM -0400, Ranga Nathan wrote: > Sick? It should!!! But gives me the result I want. Thanks a bunch for > that. > Yes the perldoc for perlre says that it is

RE: [Boston.pm] Calling regex gurus ..A regex question..

2002-10-11 Thread Ranga Nathan
Sick? It should!!! But gives me the result I want. Thanks a bunch for that. Yes the perldoc for perlre says that it is 'experimental feature' and 'don't try this at home!'. Honestly, is this going to go away? I was going to escalate this to MJD / Jeffrey Friedl. Wonder what they would suggest?

Re: [Boston.pm] Calling regex gurus ..A regex question..

2002-10-11 Thread Anthony R. J. Ball
Sorry.. rereading this tells me my answers may not have overly helped... are you just trying to verify input, or actually parse it and store it somehow? On Fri, Oct 11, 2002 at 02:20:13PM -0400, Ranga Nathan wrote: > Thanks guys that was quick response; > In the context of Any2XML, which

Re: [Boston.pm] Calling regex gurus ..A regex question..

2002-10-11 Thread GregLondon
Ranga Nathan wrote: > 02 s1n1 s1n2 3 s2n1 s2n2 s2n3 1 s3n1 4 s4n1 s4n2 s4n3 s4n4 if your count of items is alway s\d+ and your items always include non \d, couldn't you pick it off that way? my $cnt = '(\d+)'; my $item = '(s\dn\d)'; $str =~ /$cnt ($item )+/ this should slurp up as many items

Re: [Boston.pm] Calling regex gurus ..A regex question..

2002-10-11 Thread Anthony R. J. Ball
I am coming into this late... but I would use \G $str = '02 s1n1 s1n2 3 s2n1 s2n2 s2n3 1 s3n1 4 s4n1 s4n2 s4n3 s4n4'; while($str =~ /\G\s*(\d+)/g) { my $cnt = $1; my @d; my $re = '\s*(s\dn\d)' x $cnt; if($str =~ /\G$re/g) { @d = ($1,$2,$3,$4,$5,$6,$7,$8,$9);

Re: [Boston.pm] Calling regex gurus ..A regex question..

2002-10-11 Thread GregLondon
> > "RN" == Ranga Nathan <[EMAIL PROTECTED]> writes: > RN> This does not work. The \1, \2 etc are not evaluated as > RN> 'iterators'. I tried the experimental ?{} too. well, if the count range is low, you could always roll out each possible count in the regular expression. my $patt =

RE: [Boston.pm] Calling regex gurus ..A regex question..

2002-10-11 Thread Mark Aisenberg
I don't know. I searched around a bit for you... Perhaps you can't use match variables in {} quantifier brackets? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Ranga Nathan Sent: Friday, October 11, 2002 2:20 PM To: [EMAIL PROTECTED] Subject: RE:

Re: [Boston.pm] Calling regex gurus ..A regex question..

2002-10-11 Thread Uri Guttman
> "RN" == Ranga Nathan <[EMAIL PROTECTED]> writes: others told you that this will be hard with a regex. RN> 02 s1n1 s1n2 3 s2n1 s2n2 s2n3 1 s3n1 4 s4n1 s4n2 s4n3 s4n4 RN> 02 is the count and I need to extract s1n1 and s2n2 RN> 3 is the count and I need to extract s2n1, s2n2 and s2n3

RE: [Boston.pm] Calling regex gurus ..A regex question..

2002-10-11 Thread Ranga Nathan
Thanks guys that was quick response; In the context of Any2XML, which forces me to use a regex for top-down parsing, I need to use regex. Even if the regex is slow, that is fine. If it is impossible to do this in regex, of course, I would resort to split(). Can this be done using regex? Why does

RE: [Boston.pm] Calling regex gurus ..A regex question..

2002-10-11 Thread Mark Aisenberg
Your '\1' question aside: Your solution requires you to know the number of patterns in the string. For long strings, a regex could be slow. Why not just 'split' on whitespace into an array and then use array indices to easily extract the items you want? -Original Message- From: [EMAIL

Re: [Boston.pm] Calling regex gurus ..A regex question..

2002-10-11 Thread darren chamberlain
* Ranga Nathan <[EMAIL PROTECTED]> [2002-10-11 13:42]: > I need to parse a string that has multiple occurrences of a pattern > that is determined by an embeded count. For example: > > 02 s1n1 s1n2 3 s2n1 s2n2 s2n3 1 s3n1 4 s4n1 s4n2 s4n3 s4n4 > > 02 is the count and I need to extract s1n1 and

Re: [Boston.pm] question & puzzle

2002-10-11 Thread Ron Newman
On Friday, October 11, 2002, at 12:05 PM, Mark Aisenberg wrote: > You cite CPAN modules as > a place to find examples of good style; my experience is that many CPAN > modules are poorly written, almost devoid of comments, hard-wired to > assume Unix, etc. One wonderful example of CPAN module

RE: [Boston.pm] question & puzzle

2002-10-11 Thread Mark Aisenberg
I've run across some formatting guidelines, most of which are competent and uncontroversial. But that's the easy stuff. More interesting items include: 1) Modularizing code for OO. Damian's book is useful but unnecessarily esoteric once you get past the basics. A lot of Perl OO discussion

[Boston.pm] a question of style

2002-10-11 Thread GregLondon
John Saylor wrote: > this flies in the face of one of the > greatest strengths [and weaknesses] of perl: TMTOWTDI. I wrote some additions to the Tk::TextUndo module so that it could do "redo" and a bunch of other textedit type features and worked with Nick Ing-Simmons to roll them into the Tk

[Boston.pm] Style

2002-10-11 Thread Donald Leslie {74279}
Look at http://www.cs.umd.edu/users/cml/cstyle/Wildfire-C++Style-endmatter.html This is a good list of C/C++ Style Guides. My favorite style guide is the classic : The Elements of Programming Style, Kernighan and Plauger from 1978 . Don Leslie

Re: [Boston.pm] question & puzzle

2002-10-11 Thread John Tobey
On Thu, Oct 10, 2002 at 10:15:01PM -0400, Matthew Brooks wrote: > GREG: Check out Kurt Starsinic's B::Fathom module > > This is what John Tobey's latest code scores: > > $ perl -MO=Fathom -le'$_=1;for$n(2..9){s/\S+/$&$n $&+$n > $&*$n/g}2002-eval||print for split' >48 tokens >15

Re: [Boston.pm] question & puzzle

2002-10-11 Thread John Saylor
Hi ( 02.10.11 09:27 -0400 ) Mark Aisenberg: > A useful albeit unsexy project that would be interesting to take on > would be to come up with a style and best-practices guide to Perl > coding. Does anyone have any links to starting brief, readable starting > points: guides to Perl formatting, OO

RE: [Boston.pm] question & puzzle

2002-10-11 Thread Mark Aisenberg
Manufacturing folks know that "quality" means "conformance to standards". It is possible therefore to have a high-quality Yugo and a low-quality Mercedes (judging the cars only by how closely they conform to what they are supposed to be). So the key thing is how the standards are written. If

Re: [Boston.pm] puzzle II

2002-10-11 Thread John Saylor
Hi ( 02.10.10 17:56 -0400 ) Chris Devers: > The bigger problem with these is all the extra letters. Look how many > times the letter E shows up in those examples! That would be a property of our language. Cryptographers make use of frequency tables to solve simple encodings and different

Re: [Boston.pm] puzzle II

2002-10-11 Thread John Saylor
Hi ( 02.10.10 17:53 -0500 ) David Turner: > Is, "Colorless green ideas sleep furiously." an English sentence > (parsable, but semantically garbage)? What about "Fry apples the > Stallman." (English words, unparsable). "My three-cornered hat has four > corners." (internally inconsistent) I

Re: [Boston.pm] question & puzzle

2002-10-11 Thread John Saylor
Hi ( 02.10.10 17:16 -0400 ) [EMAIL PROTECTED]: > Someone needs to write a code analysis > tool to measure the complexity and > general unreadability of a piece of > perl code. Of course, these are 2 independent metrics. > Then, when these kinds of puzzles come up, > people can compete to have

Re: [Boston.pm] question & puzzle

2002-10-11 Thread John Saylor
Hi ( 02.10.10 17:09 -0400 ) Chris Devers: > Is it cheating to brute force the puzzle with a computer? :) That's a well known problem solving strategy. Ask RSA ... -- .--- ... ___ Boston-pm mailing list [EMAIL PROTECTED]