From dmagnuszewski at mandtbank.com Tue Jan 3 14:19:12 2006 From: dmagnuszewski at mandtbank.com (DANIEL MAGNUSZEWSKI) Date: Tue, 03 Jan 2006 17:19:12 -0500 Subject: [Buffalo-pm] Agenda For The January 17th Meeting... Message-ID: Mongers, Here is the information for the January 17th meeting: Time: 7:00 pm Location: TBA Topics/Presenters: Perl & Bioinformatics By: Ganesh Shankar (30 - 45 Minutes) Intro Perl & Cool Tricks - "Map & Grep" By: Kevin Eye (15 - 20 Minutes) "The most underappreciated functions of Perl are map and grep. With them available, I hardly use for loops, and I think the code is clearer, too..." ~ K.E. Intro To Writing Perl Modules By: Kevin Eye (45 - 60 Minutes) We are still trying to confirm the location for the meeting - an update will be sent when it is determined. Let me know if there is any thoughts/comments/concerns. -Dan From dmagnuszewski at mandtbank.com Wed Jan 11 08:31:36 2006 From: dmagnuszewski at mandtbank.com (DANIEL MAGNUSZEWSKI) Date: Wed, 11 Jan 2006 11:31:36 -0500 Subject: [Buffalo-pm] Reminder For Next Week's Meeting... Message-ID: Mongers, I just wanted to send everyone a little reminder about next week's meeting. The meeting is next Tuesday, January 17th. We will announce the location within the next few days. Below is the agenda I recently sent out: Time: 7:00 pm Location: TBA Topics/Presenters: Perl & Bioinformatics By: Ganesh Shankar (30 - 45 Minutes) Intro Perl & Cool Tricks - "Map & Grep" By: Kevin Eye (15 - 20 Minutes) "The most underappreciated functions of Perl are map and grep. With them available, I hardly use for loops, and I think the code is clearer, too..." ~ K.E. Intro To Writing Perl Modules By: Kevin Eye (45 - 60 Minutes) I hope to see everyone next Tuesday! -Dan From dmagnuszewski at mandtbank.com Tue Jan 17 08:19:29 2006 From: dmagnuszewski at mandtbank.com (DANIEL MAGNUSZEWSKI) Date: Tue, 17 Jan 2006 11:19:29 -0500 Subject: [Buffalo-pm] REMINDER - The January Meeting Is Today! Message-ID: Mongers, Just a quick reminder about today's meeting. The location is still not 100%. We are planning on having this meeting in Bell 242 on UB's North Campus. I'm still awaiting a response and need to finalize the details with the computer science department before confirming - if anyone else has any alternate suggestions, please let me know. I will send out the location later this after noon - sorry for the delay. Time: 7:00 PM Location: TBA Topics/Presenters: Perl & Bioinformatics By: Ganesh Shankar (30 - 45 Minutes) "Perl became firmly associated with Biology during the Human Genome Project. The usefulness of Perl for text manipulation and pattern matching has been argued to have saved the genome project. Additionally, Perl is used to locate signal sequences, design primers, and convert data formats. I will talk of the historical ( 6 years ago! ) and current uses of Perl. I'll also point the Mongers to the BioPerl project, which attempts to deal with bioinformatic needs at a more abstract, organized level." Intro Perl & Cool Tricks - "Map & Grep" By: Kevin Eye (15 - 20 Minutes) "The most underappreciated functions of Perl are map and grep. With them available, I hardly use for loops, and I think the code is clearer, too..." ~ K.E. Intro To Writing Perl Modules By: Kevin Eye (45 - 60 Minutes) -Dan From joshj at linuxmail.org Tue Jan 17 09:26:42 2006 From: joshj at linuxmail.org (Josh Johnson) Date: Tue, 17 Jan 2006 12:26:42 -0500 Subject: [Buffalo-pm] regexp returning count of pattern. Message-ID: <20060117172642.5E7A33AA515@ws5-8.us4.outblaze.com> I need a way to get the count of a pattern being matched. I can make up an elaborate function to do this but I wondered if perl had something built in I could use. For example, say I have the string: $string = 'abcdeeeeeefgheeeeijk'; I'd like to replace it with something like: 'abcdE=6fghE=4ijk' Is there any way I can get a regexp to return the number of times that a parameter was matched? -Josh J -- ______________________________________________ Check out the latest SMS services @ http://www.linuxmail.org This allows you to send and receive SMS through your mailbox. Powered by Outblaze From eye at buffalo.edu Tue Jan 17 09:30:41 2006 From: eye at buffalo.edu (Kevin Eye) Date: Tue, 17 Jan 2006 12:30:41 -0500 Subject: [Buffalo-pm] regexp returning count of pattern. In-Reply-To: <20060117172642.5E7A33AA515@ws5-8.us4.outblaze.com> Message-ID: The /g flag on regex substitutions returns the number of substitutions. Try this: $text = 'abcba'; $num_substitutions = $text =~ /b/d/g; $num_substitutions is 2 because two b's were replaced with d's. You can do this without substitutions to count the number of matches, too. - Kevin On 1/17/06 12:26 PM, "Josh Johnson" wrote: > I need a way to get the count of a pattern being matched. I can make up an > elaborate function to do this but I wondered if perl had something built in I > could use. For example, say I have the string: > > $string = 'abcdeeeeeefgheeeeijk'; > > I'd like to replace it with something like: > > 'abcdE=6fghE=4ijk' > > Is there any way I can get a regexp to return the number of times that a > parameter was matched? > > -Josh J -- Kevin Eye Web Applications Developer Marketing and Creative Services University at Buffalo 330 Crofts Hall Buffalo, NY 14260 eye at buffalo.edu phone (716) 645-5000 x1435 fax (716) 645-3765 From john at perlwolf.com Tue Jan 17 10:03:58 2006 From: john at perlwolf.com (John Macdonald) Date: Tue, 17 Jan 2006 13:03:58 -0500 Subject: [Buffalo-pm] regexp returning count of pattern. In-Reply-To: <20060117172642.5E7A33AA515@ws5-8.us4.outblaze.com> References: <20060117172642.5E7A33AA515@ws5-8.us4.outblaze.com> Message-ID: <20060117180358.GC29342@lupus.perlwolf.com> On Tue, Jan 17, 2006 at 12:26:42PM -0500, Josh Johnson wrote: > I need a way to get the count of a pattern being matched. I can make up an elaborate function to do this but I wondered if perl had something built in I could use. For example, say I have the string: > > $string = 'abcdeeeeeefgheeeeijk'; > > I'd like to replace it with something like: > > 'abcdE=6fghE=4ijk' > > Is there any way I can get a regexp to return the number of times that a parameter was matched? (warning: untested) $string =~ s/(([a-z])\1+)/"\U$1=".length($2)/ge; matches a lowercase letter as the first part <<([a-z])>>, repeated at least one more time <<\1+>>. The replacement is eval'ed to uppercase the character <<"\U$1=" and compute the number of total matches <>. The e flag causes the eval, and the g flag repeats the substitution as often as possible in the original string. -- From john at perlwolf.com Tue Jan 17 10:09:13 2006 From: john at perlwolf.com (John Macdonald) Date: Tue, 17 Jan 2006 13:09:13 -0500 Subject: [Buffalo-pm] regexp returning count of pattern. In-Reply-To: <20060117180358.GC29342@lupus.perlwolf.com> References: <20060117172642.5E7A33AA515@ws5-8.us4.outblaze.com> <20060117180358.GC29342@lupus.perlwolf.com> Message-ID: <20060117180913.GD29342@lupus.perlwolf.com> On Tue, Jan 17, 2006 at 01:03:58PM -0500, John Macdonald wrote: > On Tue, Jan 17, 2006 at 12:26:42PM -0500, Josh Johnson wrote: > > I need a way to get the count of a pattern being matched. I can make up an elaborate function to do this but I wondered if perl had something built in I could use. For example, say I have the string: > > > > $string = 'abcdeeeeeefgheeeeijk'; > > > > I'd like to replace it with something like: > > > > 'abcdE=6fghE=4ijk' > > > > Is there any way I can get a regexp to return the number of times that a parameter was matched? > > (warning: untested) > > $string =~ s/(([a-z])\1+)/"\U$1=".length($2)/ge; > > matches a lowercase letter as the first part <<([a-z])>>, > repeated at least one more time <<\1+>>. The replacement is > eval'ed to uppercase the character <<"\U$1=" and compute the > number of total matches <>. The e flag causes > the eval, and the g flag repeats the substitution as often as > possible in the original string. By the way, your encoding is potentially ambiguous if you want to be able to recreate the original input string and the input string might contain digits. "aa1" -> "A=21" "aaaaaaaaaaaaaaaaaaaaa" -> "A=21" -- From eye at buffalo.edu Tue Jan 17 10:06:45 2006 From: eye at buffalo.edu (Kevin Eye) Date: Tue, 17 Jan 2006 13:06:45 -0500 Subject: [Buffalo-pm] regexp returning count of pattern. In-Reply-To: Message-ID: Woah. I totally misinterpreted the question. Sorry. I should have paid more attention to the example. - Kevin On 1/17/06 12:30 PM, "Kevin Eye" wrote: > The /g flag on regex substitutions returns the number of substitutions. > > Try this: > > $text = 'abcba'; > $num_substitutions = $text =~ /b/d/g; > > $num_substitutions is 2 because two b's were replaced with d's. > > You can do this without substitutions to count the number of matches, too. > > - Kevin > > > On 1/17/06 12:26 PM, "Josh Johnson" wrote: > >> I need a way to get the count of a pattern being matched. I can make up an >> elaborate function to do this but I wondered if perl had something built in I >> could use. For example, say I have the string: >> >> $string = 'abcdeeeeeefgheeeeijk'; >> >> I'd like to replace it with something like: >> >> 'abcdE=6fghE=4ijk' >> >> Is there any way I can get a regexp to return the number of times that a >> parameter was matched? >> >> -Josh J -- Kevin Eye Web Applications Developer Marketing and Creative Services University at Buffalo 330 Crofts Hall Buffalo, NY 14260 eye at buffalo.edu phone (716) 645-5000 x1435 fax (716) 645-3765 From dmagnuszewski at mandtbank.com Tue Jan 17 10:22:12 2006 From: dmagnuszewski at mandtbank.com (DANIEL MAGNUSZEWSKI) Date: Tue, 17 Jan 2006 13:22:12 -0500 Subject: [Buffalo-pm] REMINDER - The January Meeting Is Today! (Room Confirmation) Message-ID: I just confirmed the room for tonight. The meeting will be in Bell 242 @ 7PM. -Dan >>> "DANIEL MAGNUSZEWSKI" 01/17/06 11:19 AM >>> Mongers, Just a quick reminder about today's meeting. The location is still not 100%. We are planning on having this meeting in Bell 242 on UB's North Campus. I'm still awaiting a response and need to finalize the details with the computer science department before confirming - if anyone else has any alternate suggestions, please let me know. I will send out the location later this after noon - sorry for the delay. Time: 7:00 PM Location: TBA Topics/Presenters: Perl & Bioinformatics By: Ganesh Shankar (30 - 45 Minutes) "Perl became firmly associated with Biology during the Human Genome Project. The usefulness of Perl for text manipulation and pattern matching has been argued to have saved the genome project. Additionally, Perl is used to locate signal sequences, design primers, and convert data formats. I will talk of the historical ( 6 years ago! ) and current uses of Perl. I'll also point the Mongers to the BioPerl project, which attempts to deal with bioinformatic needs at a more abstract, organized level." Intro Perl & Cool Tricks - "Map & Grep" By: Kevin Eye (15 - 20 Minutes) "The most underappreciated functions of Perl are map and grep. With them available, I hardly use for loops, and I think the code is clearer, too..." ~ K.E. Intro To Writing Perl Modules By: Kevin Eye (45 - 60 Minutes) From joshj at linuxmail.org Tue Jan 17 12:42:51 2006 From: joshj at linuxmail.org (Josh Johnson) Date: Tue, 17 Jan 2006 15:42:51 -0500 Subject: [Buffalo-pm] regexp returning count of pattern. Message-ID: <20060117204251.194D83AA515@ws5-8.us4.outblaze.com> ----- Original Message ----- From: "Kevin Eye" To: "Josh Johnson" , buffalo-pm at mail.pm.org Subject: Re: [Buffalo-pm] regexp returning count of pattern. Date: Tue, 17 Jan 2006 12:30:41 -0500 > > The /g flag on regex substitutions returns the number of substitutions. > > Try this: > > $text = 'abcba'; > $num_substitutions = $text =~ /b/d/g; > > $num_substitutions is 2 because two b's were replaced with d's. > > You can do this without substitutions to count the number of matches, too. I can only get this to work with substitution. How can I do it without? Its not a big deal, I can work around it if needbe. But now I'm running into another problem: How can I match a *string* one or more times? I thought I'd start out with baby-steps with this. But that's not gonna happen. Here's my ultimate goal: To convert multiple  's generated by an html editor into some xml for me. So "    " would become '' or something like that. So the problem is, I don't want to count *all*  's, I just want to count the ones that are in sequence. John: I tried your method. I see where you are going with it, and it seems like it should work, but I can't get it to. If I could match one or more strings I could get something to work. But I only know how to get regex's to match one or more characters. -Josh > > - Kevin > > > On 1/17/06 12:26 PM, "Josh Johnson" wrote: > > > I need a way to get the count of a pattern being matched. I can make up an > > elaborate function to do this but I wondered if perl had > something built in I > > could use. For example, say I have the string: > > > > $string = 'abcdeeeeeefgheeeeijk'; > > > > I'd like to replace it with something like: > > > > 'abcdE=6fghE=4ijk' > > > > Is there any way I can get a regexp to return the number of times that a > > parameter was matched? > > > > -Josh J > > -- > Kevin Eye > Web Applications Developer > Marketing and Creative Services > University at Buffalo > 330 Crofts Hall > Buffalo, NY 14260 > eye at buffalo.edu > phone (716) 645-5000 x1435 > fax (716) 645-3765 -- ______________________________________________ Check out the latest SMS services @ http://www.linuxmail.org This allows you to send and receive SMS through your mailbox. Powered by Outblaze From joshj at linuxmail.org Tue Jan 17 12:45:16 2006 From: joshj at linuxmail.org (Josh Johnson) Date: Tue, 17 Jan 2006 15:45:16 -0500 Subject: [Buffalo-pm] regexp returning count of pattern. Message-ID: <20060117204517.0BE763AA515@ws5-8.us4.outblaze.com> Oh, and if any of you are using html to read your mail, the out-of-place looking blank spaces are &nbsp; -Josh ----- Original Message ----- From: "Josh Johnson" To: buffalo-pm at mail.pm.org Subject: Re: [Buffalo-pm] regexp returning count of pattern. Date: Tue, 17 Jan 2006 15:42:51 -0500 > > > ----- Original Message ----- > From: "Kevin Eye" > To: "Josh Johnson" , buffalo-pm at mail.pm.org > Subject: Re: [Buffalo-pm] regexp returning count of pattern. > Date: Tue, 17 Jan 2006 12:30:41 -0500 > > > > > The /g flag on regex substitutions returns the number of substitutions. > > > > Try this: > > > > $text = 'abcba'; > > $num_substitutions = $text =~ /b/d/g; > > > > $num_substitutions is 2 because two b's were replaced with d's. > > > > You can do this without substitutions to count the number of matches, too. > > I can only get this to work with substitution. How can I do it > without? Its not a big deal, I can work around it if needbe. But > now I'm running into another problem: How can I match a *string* > one or more times? I thought I'd start out with baby-steps with > this. But that's not gonna happen. Here's my ultimate goal: > > To convert multiple 's generated by an html editor into some > xml for me. So " " would become > '' or something like that. So the problem is, I don't > want to count *all* 's, I just want to count the ones that > are in sequence. > > John: I tried your method. I see where you are going with it, and > it seems like it should work, but I can't get it to. > > If I could match one or more strings I could get something to work. > But I only know how to get regex's to match one or more characters. > > -Josh > > > > > - Kevin > > > > > > On 1/17/06 12:26 PM, "Josh Johnson" wrote: > > > > > I need a way to get the count of a pattern being matched. I can make up an > > > elaborate function to do this but I wondered if perl had > > something built in I > > > could use. For example, say I have the string: > > > > > > $string = 'abcdeeeeeefgheeeeijk'; > > > > > > I'd like to replace it with something like: > > > > > > 'abcdE=6fghE=4ijk' > > > > > > Is there any way I can get a regexp to return the number of times that a > > > parameter was matched? > > > > > > -Josh J > > > > -- > > Kevin Eye > > Web Applications Developer > > Marketing and Creative Services > > University at Buffalo > > 330 Crofts Hall > > Buffalo, NY 14260 > > eye at buffalo.edu > > phone (716) 645-5000 x1435 > > fax (716) 645-3765 > > > -- > ______________________________________________ > Check out the latest SMS services @ http://www.linuxmail.org > This allows you to send and receive SMS through your mailbox. > > Powered by Outblaze -- ______________________________________________ Check out the latest SMS services @ http://www.linuxmail.org This allows you to send and receive SMS through your mailbox. Powered by Outblaze From dmagnuszewski at mandtbank.com Tue Jan 17 12:53:24 2006 From: dmagnuszewski at mandtbank.com (DANIEL MAGNUSZEWSKI) Date: Tue, 17 Jan 2006 15:53:24 -0500 Subject: [Buffalo-pm] regexp returning count of pattern. Message-ID: If you plan on attending the meeting tonight, and you are able to bring what you are working on, then I'm confident that we can collectively work on and solve your problem. It may be easier to work through some examples while we're all in the same room. -Dan >>> "Josh Johnson" 01/17/06 3:42 PM >>> ----- Original Message ----- From: "Kevin Eye" To: "Josh Johnson" , buffalo-pm at mail.pm.org Subject: Re: [Buffalo-pm] regexp returning count of pattern. Date: Tue, 17 Jan 2006 12:30:41 -0500 > > The /g flag on regex substitutions returns the number of substitutions. > > Try this: > > $text = 'abcba'; > $num_substitutions = $text =~ /b/d/g; > > $num_substitutions is 2 because two b's were replaced with d's. > > You can do this without substitutions to count the number of matches, too. I can only get this to work with substitution. How can I do it without? Its not a big deal, I can work around it if needbe. But now I'm running into another problem: How can I match a *string* one or more times? I thought I'd start out with baby-steps with this. But that's not gonna happen. Here's my ultimate goal: To convert multiple  's generated by an html editor into some xml for me. So "    " would become '' or something like that. So the problem is, I don't want to count *all*  's, I just want to count the ones that are in sequence. John: I tried your method. I see where you are going with it, and it seems like it should work, but I can't get it to. If I could match one or more strings I could get something to work. But I only know how to get regex's to match one or more characters. -Josh > > - Kevin > > > On 1/17/06 12:26 PM, "Josh Johnson" wrote: > > > I need a way to get the count of a pattern being matched. I can make up an > > elaborate function to do this but I wondered if perl had > something built in I > > could use. For example, say I have the string: > > > > $string = 'abcdeeeeeefgheeeeijk'; > > > > I'd like to replace it with something like: > > > > 'abcdE=6fghE=4ijk' > > > > Is there any way I can get a regexp to return the number of times that a > > parameter was matched? > > > > -Josh J > > -- > Kevin Eye > Web Applications Developer > Marketing and Creative Services > University at Buffalo > 330 Crofts Hall > Buffalo, NY 14260 > eye at buffalo.edu > phone (716) 645-5000 x1435 > fax (716) 645-3765 -- ______________________________________________ Check out the latest SMS services @ http://www.linuxmail.org This allows you to send and receive SMS through your mailbox. Powered by Outblaze _______________________________________________ Buffalo-pm mailing list Buffalo-pm at pm.org http://mail.pm.org/mailman/listinfo/buffalo-pm From joshj at linuxmail.org Tue Jan 17 13:06:00 2006 From: joshj at linuxmail.org (Josh Johnson) Date: Tue, 17 Jan 2006 16:06:00 -0500 Subject: [Buffalo-pm] regexp returning count of pattern. Message-ID: <20060117210600.010973AA515@ws5-8.us4.outblaze.com> Good call. I get out a bit late tonight, but I'll try and make it over as soon as I get out. I don't have a laptop with this on it or anything. But I do have a perl interpreter in my head. -Josh ps. It will match strings now a-la: my $string = "hello world cowcowcowcow what cowcowcow"; $string =~ s/(cow)\1+/vampire/; print "$string\n"; this will replace the first set of cowcowcowcow. but now I can't get the count via Kevin's suggestion. But I think this might be getting close to working out as John proposed. ----- Original Message ----- From: "DANIEL MAGNUSZEWSKI" To: joshj at linuxmail.org, buffalo-pm at mail.pm.org Subject: Re: [Buffalo-pm] regexp returning count of pattern. Date: Tue, 17 Jan 2006 15:53:24 -0500 > > If you plan on attending the meeting tonight, and you are able to bring > what you are working on, then I'm confident that we can collectively > work on and solve your problem. It may be easier to work through some > examples while we're all in the same room. > > -Dan > > >>> "Josh Johnson" 01/17/06 3:42 PM >>> > > ----- Original Message ----- > From: "Kevin Eye" > To: "Josh Johnson" , buffalo-pm at mail.pm.org > Subject: Re: [Buffalo-pm] regexp returning count of pattern. > Date: Tue, 17 Jan 2006 12:30:41 -0500 > > > > > The /g flag on regex substitutions returns the number of > substitutions. > > > > Try this: > > > > $text = 'abcba'; > > $num_substitutions = $text =~ /b/d/g; > > > > $num_substitutions is 2 because two b's were replaced with d's. > > > > You can do this without substitutions to count the number of matches, > too. > > I can only get this to work with substitution. How can I do it > without? Its not a big deal, I can work around it if needbe. But > now I'm running into another problem: How can I match a *string* > one or more times? I thought I'd start out with baby-steps with > this. But that's not gonna happen. Here's my ultimate goal: > > To convert multiple 's generated by an html editor into some > xml for me. So " " would become > '' or something like that. So the problem is, I don't > want to count *all* 's, I just want to count the ones that > are in sequence. > > John: I tried your method. I see where you are going with it, and it > seems like it should work, but I can't get it to. > > If I could match one or more strings I could get something to work. But > I only know how to get regex's to match one or more characters. > > -Josh > > > > > - Kevin > > > > > > On 1/17/06 12:26 PM, "Josh Johnson" wrote: > > > > > I need a way to get the count of a pattern being matched. I can > make up an > > > elaborate function to do this but I wondered if perl had > > something built in I > > > could use. For example, say I have the string: > > > > > > $string = 'abcdeeeeeefgheeeeijk'; > > > > > > I'd like to replace it with something like: > > > > > > 'abcdE=6fghE=4ijk' > > > > > > Is there any way I can get a regexp to return the number of times > that a > > > parameter was matched? > > > > > > -Josh J > > > > -- > > Kevin Eye > > Web Applications Developer > > Marketing and Creative Services > > University at Buffalo > > 330 Crofts Hall > > Buffalo, NY 14260 > > eye at buffalo.edu phone (716) 645-5000 x1435 > > fax (716) 645-3765 > > > -- > ______________________________________________ > Check out the latest SMS services @ http://www.linuxmail.org > This allows you to send and receive SMS through your mailbox. > > Powered by Outblaze > _______________________________________________ > Buffalo-pm mailing list > Buffalo-pm at pm.org > http://mail.pm.org/mailman/listinfo/buffalo-pm -- ______________________________________________ Check out the latest SMS services @ http://www.linuxmail.org This allows you to send and receive SMS through your mailbox. Powered by Outblaze From eye at buffalo.edu Tue Jan 17 13:10:08 2006 From: eye at buffalo.edu (Kevin Eye) Date: Tue, 17 Jan 2006 16:10:08 -0500 Subject: [Buffalo-pm] regexp returning count of pattern. In-Reply-To: <20060117204251.194D83AA515@ws5-8.us4.outblaze.com> Message-ID: Looks like I lied in my first answer. According to the perlop man page, pattern matching (not substitution) with or without the /g flag in scalar context returns whether there is a match or not; not how many. In list context, it returns each match with the /g flag, so you can use that to get how many if you count the number of items in the list like this: @matches = $text =~ /regexp/g; $num_matches = @matches; So, your whole thing could be done like this: my $text = 'abc  def'; $text =~ s{((?: )+)}{ my @matches = $1 =~ / /g; my $num_spaces = @matches; qq{} }eg; - Kevin On 1/17/06 3:42 PM, "Josh Johnson" wrote: > > ----- Original Message ----- > From: "Kevin Eye" > To: "Josh Johnson" , buffalo-pm at mail.pm.org > Subject: Re: [Buffalo-pm] regexp returning count of pattern. > Date: Tue, 17 Jan 2006 12:30:41 -0500 > >> >> The /g flag on regex substitutions returns the number of substitutions. >> >> Try this: >> >> $text = 'abcba'; >> $num_substitutions = $text =~ /b/d/g; >> >> $num_substitutions is 2 because two b's were replaced with d's. >> >> You can do this without substitutions to count the number of matches, too. > > I can only get this to work with substitution. How can I do it > without? Its not a big deal, I can work around it if needbe. But > now I'm running into another problem: How can I match a *string* > one or more times? I thought I'd start out with baby-steps with > this. But that's not gonna happen. Here's my ultimate goal: > > To convert multiple  's generated by an html editor into some > xml for me. So "    " would become > '' or something like that. So the problem is, I don't > want to count *all*  's, I just want to count the ones that > are in sequence. > > John: I tried your method. I see where you are going with it, and it seems > like it should work, but I can't get it to. > > If I could match one or more strings I could get something to work. But I only > know how to get regex's to match one or more characters. > > -Josh > >> >> - Kevin >> >> >> On 1/17/06 12:26 PM, "Josh Johnson" wrote: >> >>> I need a way to get the count of a pattern being matched. I can make up an >>> elaborate function to do this but I wondered if perl had >> something built in I >>> could use. For example, say I have the string: >>> >>> $string = 'abcdeeeeeefgheeeeijk'; >>> >>> I'd like to replace it with something like: >>> >>> 'abcdE=6fghE=4ijk' >>> >>> Is there any way I can get a regexp to return the number of times that a >>> parameter was matched? >>> >>> -Josh J >> >> -- >> Kevin Eye >> Web Applications Developer >> Marketing and Creative Services >> University at Buffalo >> 330 Crofts Hall >> Buffalo, NY 14260 >> eye at buffalo.edu >> phone (716) 645-5000 x1435 >> fax (716) 645-3765 > -- Kevin Eye Web Applications Developer Marketing and Creative Services University at Buffalo 330 Crofts Hall Buffalo, NY 14260 eye at buffalo.edu phone (716) 645-5000 x1435 fax (716) 645-3765 From joshj at linuxmail.org Tue Jan 17 13:31:10 2006 From: joshj at linuxmail.org (Josh Johnson) Date: Tue, 17 Jan 2006 16:31:10 -0500 Subject: [Buffalo-pm] regexp returning count of pattern. Message-ID: <20060117213110.49C0A3AA515@ws5-8.us4.outblaze.com> That is beautiful and works quite well. Thanks Kevin! -Josh ----- Original Message ----- From: "Kevin Eye" To: "Josh Johnson" , buffalo-pm at mail.pm.org Subject: Re: [Buffalo-pm] regexp returning count of pattern. Date: Tue, 17 Jan 2006 16:10:08 -0500 > > Looks like I lied in my first answer. According to the perlop man page, > pattern matching (not substitution) with or without the /g flag in scalar > context returns whether there is a match or not; not how many. In list > context, it returns each match with the /g flag, so you can use that to get > how many if you count the number of items in the list like this: > > @matches = $text =~ /regexp/g; > $num_matches = @matches; > > So, your whole thing could be done like this: > > my $text = 'abc def'; > $text =~ s{((?: )+)}{ > my @matches = $1 =~ / /g; > my $num_spaces = @matches; > qq{} > }eg; > > > - Kevin > > > > On 1/17/06 3:42 PM, "Josh Johnson" wrote: > > > > > ----- Original Message ----- > > From: "Kevin Eye" > > To: "Josh Johnson" , buffalo-pm at mail.pm.org > > Subject: Re: [Buffalo-pm] regexp returning count of pattern. > > Date: Tue, 17 Jan 2006 12:30:41 -0500 > > > >> > >> The /g flag on regex substitutions returns the number of substitutions. > >> > >> Try this: > >> > >> $text = 'abcba'; > >> $num_substitutions = $text =~ /b/d/g; > >> > >> $num_substitutions is 2 because two b's were replaced with d's. > >> > >> You can do this without substitutions to count the number of matches, too. > > > > I can only get this to work with substitution. How can I do it > > without? Its not a big deal, I can work around it if needbe. But > > now I'm running into another problem: How can I match a *string* > > one or more times? I thought I'd start out with baby-steps with > > this. But that's not gonna happen. Here's my ultimate goal: > > > > To convert multiple 's generated by an html editor into some > > xml for me. So " " would become > > '' or something like that. So the problem is, I don't > > want to count *all* 's, I just want to count the ones that > > are in sequence. > > > > John: I tried your method. I see where you are going with it, and it seems > > like it should work, but I can't get it to. > > > > If I could match one or more strings I could get something to > > work. But I only > > know how to get regex's to match one or more characters. > > > > -Josh > > > >> > >> - Kevin > >> > >> > >> On 1/17/06 12:26 PM, "Josh Johnson" wrote: > >> > >>> I need a way to get the count of a pattern being matched. I can make up an > >>> elaborate function to do this but I wondered if perl had > >> something built in I > >>> could use. For example, say I have the string: > >>> > >>> $string = 'abcdeeeeeefgheeeeijk'; > >>> > >>> I'd like to replace it with something like: > >>> > >>> 'abcdE=6fghE=4ijk' > >>> > >>> Is there any way I can get a regexp to return the number of times that a > >>> parameter was matched? > >>> > >>> -Josh J > >> > >> -- > >> Kevin Eye > >> Web Applications Developer > >> Marketing and Creative Services > >> University at Buffalo > >> 330 Crofts Hall > >> Buffalo, NY 14260 > >> eye at buffalo.edu > >> phone (716) 645-5000 x1435 > >> fax (716) 645-3765 > > > > -- > Kevin Eye > Web Applications Developer > Marketing and Creative Services > University at Buffalo > 330 Crofts Hall > Buffalo, NY 14260 > eye at buffalo.edu > phone (716) 645-5000 x1435 > fax (716) 645-3765 -- ______________________________________________ Check out the latest SMS services @ http://www.linuxmail.org This allows you to send and receive SMS through your mailbox. Powered by Outblaze From dmagnuszewski at mandtbank.com Tue Jan 17 13:51:19 2006 From: dmagnuszewski at mandtbank.com (DANIEL MAGNUSZEWSKI) Date: Tue, 17 Jan 2006 16:51:19 -0500 Subject: [Buffalo-pm] REMINDER - The January Meeting Is Today! (Room Confirmation) Message-ID: Just incase anyone is unsure of how to get to Bell Hall or UB, these links may be of some use: To get to UB: http://www.buffalo.edu/directions/ Bell Hall within UB: http://www.buffalo.edu/buildings/building?id=bell -Dan >>> "DANIEL MAGNUSZEWSKI" 01/17/06 1:22 PM >>> I just confirmed the room for tonight. The meeting will be in Bell 242 @ 7PM. -Dan >>> "DANIEL MAGNUSZEWSKI" 01/17/06 11:19 AM >>> Mongers, Just a quick reminder about today's meeting. The location is still not 100%. We are planning on having this meeting in Bell 242 on UB's North Campus. I'm still awaiting a response and need to finalize the details with the computer science department before confirming - if anyone else has any alternate suggestions, please let me know. I will send out the location later this after noon - sorry for the delay. Time: 7:00 PM Location: TBA Topics/Presenters: Perl & Bioinformatics By: Ganesh Shankar (30 - 45 Minutes) "Perl became firmly associated with Biology during the Human Genome Project. The usefulness of Perl for text manipulation and pattern matching has been argued to have saved the genome project. Additionally, Perl is used to locate signal sequences, design primers, and convert data formats. I will talk of the historical ( 6 years ago! ) and current uses of Perl. I'll also point the Mongers to the BioPerl project, which attempts to deal with bioinformatic needs at a more abstract, organized level." Intro Perl & Cool Tricks - "Map & Grep" By: Kevin Eye (15 - 20 Minutes) "The most underappreciated functions of Perl are map and grep. With them available, I hardly use for loops, and I think the code is clearer, too..." ~ K.E. Intro To Writing Perl Modules By: Kevin Eye (45 - 60 Minutes) _______________________________________________ Buffalo-pm mailing list Buffalo-pm at pm.org http://mail.pm.org/mailman/listinfo/buffalo-pm From john at perlwolf.com Tue Jan 17 14:32:10 2006 From: john at perlwolf.com (John Macdonald) Date: Tue, 17 Jan 2006 17:32:10 -0500 Subject: [Buffalo-pm] regexp returning count of pattern. In-Reply-To: <20060117204251.194D83AA515@ws5-8.us4.outblaze.com> References: <20060117204251.194D83AA515@ws5-8.us4.outblaze.com> Message-ID: <20060117223209.GE29342@lupus.perlwolf.com> On Tue, Jan 17, 2006 at 03:42:51PM -0500, Josh Johnson wrote: > > ----- Original Message ----- > From: "Kevin Eye" > To: "Josh Johnson" , buffalo-pm at mail.pm.org > Subject: Re: [Buffalo-pm] regexp returning count of pattern. > Date: Tue, 17 Jan 2006 12:30:41 -0500 > > > > > The /g flag on regex substitutions returns the number of substitutions. > > > > Try this: > > > > $text = 'abcba'; > > $num_substitutions = $text =~ /b/d/g; > > > > $num_substitutions is 2 because two b's were replaced with d's. > > > > You can do this without substitutions to count the number of matches, too. > > I can only get this to work with substitution. How can I do it > without? Its not a big deal, I can work around it if needbe. But > now I'm running into another problem: How can I match a *string* > one or more times? I thought I'd start out with baby-steps with > this. But that's not gonna happen. Here's my ultimate goal: > > To convert multiple  's generated by an html editor into some > xml for me. So "    " would become > '' or something like that. So the problem is, I don't > want to count *all*  's, I just want to count the ones that > are in sequence. > > John: I tried your method. I see where you are going with it, and it seems like it should work, but I can't get it to. > > If I could match one or more strings I could get something to work. But I only know how to get regex's to match one or more characters. $string =~ s/((\ ){2,})/''/eg; (This gets harder if there are extra characters allowed within the   run, though.) -- From dmagnuszewski at mandtbank.com Wed Jan 18 07:36:01 2006 From: dmagnuszewski at mandtbank.com (DANIEL MAGNUSZEWSKI) Date: Wed, 18 Jan 2006 10:36:01 -0500 Subject: [Buffalo-pm] Last Night's Meeting - Slides Available - Audio Coming Soon! Message-ID: Mongers, For those of you who could not make it to the meeting last night, we have put the slides & recommended links up on the website ( http://buffalo.pm.org ) under the "Previous Talks: Outlines, Code Samples, Etc." section. We will also be putting the audio up on the website for each of the talks. I will send out another link when they are up on the site. -Dan From dmagnuszewski at mandtbank.com Wed Jan 18 20:17:59 2006 From: dmagnuszewski at mandtbank.com (DANIEL MAGNUSZEWSKI) Date: Wed, 18 Jan 2006 23:17:59 -0500 Subject: [Buffalo-pm] Statistics With Perl... Message-ID: Ganesh, Correct me if I'm wrong, but you mentioned last night that Bioinformatics is beginning to focus more on the statistics and probability of test results being correct and less on the actual lower level programming aspects (such as using Perl to do sequencing and give you the test results, etc). This is because of the large code base that is already in place. You then mentioned that because of this, people within Bioinformatics (in general) will begin to move away from Perl, and begin to use a language like R (http://www.r-project.org/). After we mentioned how there was probably a wrapper module for R, I poked around CPAN and found a module, Statistics::R, that will allow you to interact (create, start, stop, etc) with an R interpreter through Perl. Statistics::R - Controls the R (R-project) interpreter through Perl. http://search.cpan.org/~gmpassos/Statistics-R-0.02/lib/Statistics/R.pm Below is another R module I found, but it states that it doesn't implement all functions of R - so I'm assuming that it can be quite limiting: PDL::R::math - routines from statistics language, R, for PDL http://search.cpan.org/~cavanaugh/PDL-R-math-0.12/rmath.pd Also, I'm not sure if you use programs like MATLAB, but there is an open source version of it called Octave (http://www.octave.org). As with most everything, there are some Perl modules available to help you interact with it: Inline::Octave - Inline octave code into your Perl http://search.cpan.org/~aadler/Inline-Octave-0.22/Octave.pm I have even found a package available that will provide an interface between R and Octave - properly named, ROctave ( http://www.omegahat.org/ROctave/ ). The same group that releases ROctave, has a package called RSPerl ( http://www.omegahat.org/RSPerl/ ) that "provides a bidirectional interface for calling R from Perl and Perl from R". Essentially, these tools provide statistical functionality to Perl that is not natively present. Does any of this seem useful for what Biologist need to do? Would this integrated "framework" help for creating better/more effective tools? Hopefully some of this helps... -Dan From joshua at wolfnix.net Thu Jan 19 05:09:16 2006 From: joshua at wolfnix.net (Joshua Ronne Altemoos) Date: Thu, 19 Jan 2006 08:09:16 -0500 Subject: [Buffalo-pm] REMINDER - The January Meeting Is Today! (Room Confirmation) In-Reply-To: Message-ID: <000401c61cf9$91e69500$be01a8c0@purgatory> Hey, Do you think you can get an earlier confirmation of the location? If you can get this room again it would be great because it would be extremely easy for me to get there. The location came to late for me to be able to attend this month. Thanks! ~JRA --- Joshua Ronne Altemoos joshua at wolfnix.net -Quis custodiet ipsos custodes -----Original Message----- From: buffalo-pm-bounces at pm.org [mailto:buffalo-pm-bounces at pm.org] On Behalf Of DANIEL MAGNUSZEWSKI Sent: Tuesday, January 17, 2006 1:22 PM To: buffalo-pm at mail.pm.org Subject: Re: [Buffalo-pm] REMINDER - The January Meeting Is Today! (Room Confirmation) I just confirmed the room for tonight. The meeting will be in Bell 242 @ 7PM. -Dan >>> "DANIEL MAGNUSZEWSKI" 01/17/06 11:19 AM >>> Mongers, Just a quick reminder about today's meeting. The location is still not 100%. We are planning on having this meeting in Bell 242 on UB's North Campus. I'm still awaiting a response and need to finalize the details with the computer science department before confirming - if anyone else has any alternate suggestions, please let me know. I will send out the location later this after noon - sorry for the delay. Time: 7:00 PM Location: TBA Topics/Presenters: Perl & Bioinformatics By: Ganesh Shankar (30 - 45 Minutes) "Perl became firmly associated with Biology during the Human Genome Project. The usefulness of Perl for text manipulation and pattern matching has been argued to have saved the genome project. Additionally, Perl is used to locate signal sequences, design primers, and convert data formats. I will talk of the historical ( 6 years ago! ) and current uses of Perl. I'll also point the Mongers to the BioPerl project, which attempts to deal with bioinformatic needs at a more abstract, organized level." Intro Perl & Cool Tricks - "Map & Grep" By: Kevin Eye (15 - 20 Minutes) "The most underappreciated functions of Perl are map and grep. With them available, I hardly use for loops, and I think the code is clearer, too..." ~ K.E. Intro To Writing Perl Modules By: Kevin Eye (45 - 60 Minutes) _______________________________________________ Buffalo-pm mailing list Buffalo-pm at pm.org http://mail.pm.org/mailman/listinfo/buffalo-pm From dmagnuszewski at mandtbank.com Thu Jan 19 06:26:28 2006 From: dmagnuszewski at mandtbank.com (DANIEL MAGNUSZEWSKI) Date: Thu, 19 Jan 2006 09:26:28 -0500 Subject: [Buffalo-pm] REMINDER - The January Meeting Is Today! ( RoomConfirmation) Message-ID: We generally do have the room confirmed long before hand, and have for the past few years. The problem was that it was the beginning of the semester so I needed to get my card access re-approved - that's what I was waiting on and what caused the delay. This room will continue to be the location for our technical meetings. See you next month. -Dan >>> "Joshua Ronne Altemoos" 01/19/06 8:09 AM >>> Hey, Do you think you can get an earlier confirmation of the location? If you can get this room again it would be great because it would be extremely easy for me to get there. The location came to late for me to be able to attend this month. Thanks! ~JRA --- Joshua Ronne Altemoos joshua at wolfnix.net -Quis custodiet ipsos custodes -----Original Message----- From: buffalo-pm-bounces at pm.org [mailto:buffalo-pm-bounces at pm.org] On Behalf Of DANIEL MAGNUSZEWSKI Sent: Tuesday, January 17, 2006 1:22 PM To: buffalo-pm at mail.pm.org Subject: Re: [Buffalo-pm] REMINDER - The January Meeting Is Today! (Room Confirmation) I just confirmed the room for tonight. The meeting will be in Bell 242 @ 7PM. -Dan >>> "DANIEL MAGNUSZEWSKI" 01/17/06 11:19 AM >>> Mongers, Just a quick reminder about today's meeting. The location is still not 100%. We are planning on having this meeting in Bell 242 on UB's North Campus. I'm still awaiting a response and need to finalize the details with the computer science department before confirming - if anyone else has any alternate suggestions, please let me know. I will send out the location later this after noon - sorry for the delay. Time: 7:00 PM Location: TBA Topics/Presenters: Perl & Bioinformatics By: Ganesh Shankar (30 - 45 Minutes) "Perl became firmly associated with Biology during the Human Genome Project. The usefulness of Perl for text manipulation and pattern matching has been argued to have saved the genome project. Additionally, Perl is used to locate signal sequences, design primers, and convert data formats. I will talk of the historical ( 6 years ago! ) and current uses of Perl. I'll also point the Mongers to the BioPerl project, which attempts to deal with bioinformatic needs at a more abstract, organized level." Intro Perl & Cool Tricks - "Map & Grep" By: Kevin Eye (15 - 20 Minutes) "The most underappreciated functions of Perl are map and grep. With them available, I hardly use for loops, and I think the code is clearer, too..." ~ K.E. Intro To Writing Perl Modules By: Kevin Eye (45 - 60 Minutes) _______________________________________________ Buffalo-pm mailing list Buffalo-pm at pm.org http://mail.pm.org/mailman/listinfo/buffalo-pm From Ganesh.Shankar at RoswellPark.org Thu Jan 19 07:46:00 2006 From: Ganesh.Shankar at RoswellPark.org (Shankar, Ganesh) Date: Thu, 19 Jan 2006 10:46:00 -0500 Subject: [Buffalo-pm] Statistics With Perl... References: Message-ID: <6FF91AE4F1DC7743A6466E334EB865AE10F20E1D@VERITY.roswellpark.org> Dan, Yes, that's pretty much my opinion. The work under the hood will be done by existing code, be it Perl or not. The reason I mentioned that bioinformatists will move away from Perl is because there is no pluggable framework. With your initial research (good job,by the way), I can see that the major pieces are there, but they need to be glued together. I haven't looked into your links at all, but will do so soon as I get back from vacation. I think that there are going to be two classes of users - biologists and bioinformaticians. The bioinformatics people will be satisfied if we just give them a consistent framework and api with command line tools. The biologists will be at the other extreme where they won't care what language,module is doing the work, they just care that the tools support their workflow. For them, the GUI is paramount, next to speed. The major piece that's missing is the GUI. The tools also have to interact with public databases (www.ncbi.nlm.nih.gov and http://www.ensembl.org/) but that's a forte of Perl and should be manageable. So, I see 3 challanges: build/integrate the framework, GUI, and lastly port existing statistical algorithms to the framework. If we can do this in Perl, then it should be faster than what I've experienced so far. Maybe we can propose this as a business idea for the next School of Management's yearly contest. This is precisely the kind of approach I was advocating as an alternative to the multi-tier, grid enabled, bioinformatics environment that is being developed. Definetely worth thinking about. -Ganesh -----Original Message----- From: buffalo-pm-bounces at pm.org on behalf of DANIEL MAGNUSZEWSKI Sent: Wed 1/18/2006 11:17 PM To: buffalo-pm at mail.pm.org Subject: [Buffalo-pm] Statistics With Perl... Ganesh, Correct me if I'm wrong, but you mentioned last night that Bioinformatics is beginning to focus more on the statistics and probability of test results being correct and less on the actual lower level programming aspects (such as using Perl to do sequencing and give you the test results, etc). This is because of the large code base that is already in place. You then mentioned that because of this, people within Bioinformatics (in general) will begin to move away from Perl, and begin to use a language like R (http://www.r-project.org/). After we mentioned how there was probably a wrapper module for R, I poked around CPAN and found a module, Statistics::R, that will allow you to interact (create, start, stop, etc) with an R interpreter through Perl. Statistics::R - Controls the R (R-project) interpreter through Perl. http://search.cpan.org/~gmpassos/Statistics-R-0.02/lib/Statistics/R.pm Below is another R module I found, but it states that it doesn't implement all functions of R - so I'm assuming that it can be quite limiting: PDL::R::math - routines from statistics language, R, for PDL http://search.cpan.org/~cavanaugh/PDL-R-math-0.12/rmath.pd Also, I'm not sure if you use programs like MATLAB, but there is an open source version of it called Octave (http://www.octave.org). As with most everything, there are some Perl modules available to help you interact with it: Inline::Octave - Inline octave code into your Perl http://search.cpan.org/~aadler/Inline-Octave-0.22/Octave.pm I have even found a package available that will provide an interface between R and Octave - properly named, ROctave ( http://www.omegahat.org/ROctave/ ). The same group that releases ROctave, has a package called RSPerl ( http://www.omegahat.org/RSPerl/ ) that "provides a bidirectional interface for calling R from Perl and Perl from R". Essentially, these tools provide statistical functionality to Perl that is not natively present. Does any of this seem useful for what Biologist need to do? Would this integrated "framework" help for creating better/more effective tools? Hopefully some of this helps... -Dan _______________________________________________ Buffalo-pm mailing list Buffalo-pm at pm.org http://mail.pm.org/mailman/listinfo/buffalo-pm This email message may contain legally privileged and/or confidential information. If you are not the intended recipient(s), or the employee or agent responsible for the delivery of this message to the intended recipient(s), you are hereby notified that any disclosure, copying, distribution, or use of this email message is prohibited. If you have received this message in error, please notify the sender immediately by e-mail and delete this email message from your computer. Thank you. From joshua at wolfnix.net Thu Jan 19 14:32:39 2006 From: joshua at wolfnix.net (Joshua Ronne Altemoos) Date: Thu, 19 Jan 2006 17:32:39 -0500 Subject: [Buffalo-pm] REMINDER - The January Meeting Is Today! ( RoomConfirmation) In-Reply-To: Message-ID: <000601c61d48$48873870$be01a8c0@purgatory> Hehe. This is only my second month involued in the maillist so I was unaware of the past. Thank you for the information josh --- Joshua Ronne Altemoos joshua at wolfnix.net -Quis custodiet ipsos custodes -----Original Message----- From: DANIEL MAGNUSZEWSKI [mailto:dmagnuszewski at mandtbank.com] Sent: Thursday, January 19, 2006 9:26 AM To: joshua at wolfnix.net Cc: buffalo-pm at mail.pm.org Subject: RE: [Buffalo-pm] REMINDER - The January Meeting Is Today! ( RoomConfirmation) We generally do have the room confirmed long before hand, and have for the past few years. The problem was that it was the beginning of the semester so I needed to get my card access re-approved - that's what I was waiting on and what caused the delay. This room will continue to be the location for our technical meetings. See you next month. -Dan >>> "Joshua Ronne Altemoos" 01/19/06 8:09 AM >>> Hey, Do you think you can get an earlier confirmation of the location? If you can get this room again it would be great because it would be extremely easy for me to get there. The location came to late for me to be able to attend this month. Thanks! ~JRA --- Joshua Ronne Altemoos joshua at wolfnix.net -Quis custodiet ipsos custodes -----Original Message----- From: buffalo-pm-bounces at pm.org [mailto:buffalo-pm-bounces at pm.org] On Behalf Of DANIEL MAGNUSZEWSKI Sent: Tuesday, January 17, 2006 1:22 PM To: buffalo-pm at mail.pm.org Subject: Re: [Buffalo-pm] REMINDER - The January Meeting Is Today! (Room Confirmation) I just confirmed the room for tonight. The meeting will be in Bell 242 @ 7PM. -Dan >>> "DANIEL MAGNUSZEWSKI" 01/17/06 11:19 AM >>> Mongers, Just a quick reminder about today's meeting. The location is still not 100%. We are planning on having this meeting in Bell 242 on UB's North Campus. I'm still awaiting a response and need to finalize the details with the computer science department before confirming - if anyone else has any alternate suggestions, please let me know. I will send out the location later this after noon - sorry for the delay. Time: 7:00 PM Location: TBA Topics/Presenters: Perl & Bioinformatics By: Ganesh Shankar (30 - 45 Minutes) "Perl became firmly associated with Biology during the Human Genome Project. The usefulness of Perl for text manipulation and pattern matching has been argued to have saved the genome project. Additionally, Perl is used to locate signal sequences, design primers, and convert data formats. I will talk of the historical ( 6 years ago! ) and current uses of Perl. I'll also point the Mongers to the BioPerl project, which attempts to deal with bioinformatic needs at a more abstract, organized level." Intro Perl & Cool Tricks - "Map & Grep" By: Kevin Eye (15 - 20 Minutes) "The most underappreciated functions of Perl are map and grep. With them available, I hardly use for loops, and I think the code is clearer, too..." ~ K.E. Intro To Writing Perl Modules By: Kevin Eye (45 - 60 Minutes) _______________________________________________ Buffalo-pm mailing list Buffalo-pm at pm.org http://mail.pm.org/mailman/listinfo/buffalo-pm From dmagnuszewski at mandtbank.com Mon Jan 23 07:35:49 2006 From: dmagnuszewski at mandtbank.com (DANIEL MAGNUSZEWSKI) Date: Mon, 23 Jan 2006 10:35:49 -0500 Subject: [Buffalo-pm] Fwd: [tpm] January Meeting - Thu 26 Jan 2006, 6:45pm - Blinkenlites with Perl : A case study in driving c Message-ID: If anyone is interested... -------------- next part -------------- An embedded message was scrubbed... From: "Michael Graham" Subject: [tpm] January Meeting - Thu 26 Jan 2006, 6:45pm - Blinkenlites with Perl : A case study in driving custom home-made hardware with Perl Date: Fri, 20 Jan 2006 22:40:06 -0500 Size: 5651 Url: http://mail.pm.org/pipermail/buffalo-pm/attachments/20060123/65627533/attachment.mht From dmagnuszewski at mandtbank.com Wed Jan 25 10:22:12 2006 From: dmagnuszewski at mandtbank.com (DANIEL MAGNUSZEWSKI) Date: Wed, 25 Jan 2006 13:22:12 -0500 Subject: [Buffalo-pm] Fwd: SR. PHP, Perl Developer - Direct Hire - Buffalo, NY Message-ID: "Job Seeking" Mongers, If interested, do not reply to me. Please contact Hank Williams. -------------- next part -------------- An embedded message was scrubbed... From: "Henry Williams" Subject: SR. PHP, Perl Developer - Direct Hire - Buffalo, NY Date: Wed, 25 Jan 2006 12:27:15 -0500 Size: 1648 Url: http://mail.pm.org/pipermail/buffalo-pm/attachments/20060125/f72ed690/attachment.mht From mtr3 at buffalo.edu Thu Jan 26 23:16:18 2006 From: mtr3 at buffalo.edu (Mike Richardson) Date: Fri, 27 Jan 2006 02:16:18 -0500 Subject: [Buffalo-pm] January Meeting audio finished (almost!) In-Reply-To: References: Message-ID: <43D9C8C2.7090301@buffalo.edu> Fellow Mongers, I finished the audio captures and such, and just realized that I recorded all the intros and ID3 tagged them to claim the meeting took place on the 19th instead of the 17th :) - I'll fix that this weekend. I tried to edit these as best as I could. If you find anything that needs fixing, note the approximate time in the file and send me an e-mail. I have .ogg versions available too if there is a need... > Perl & Bioinformatics > By: Ganesh Shankar > (30 - 45 Minutes) http://mikerichardson.us/bpm/2006-01-17_perl_and_bioinformatics.mp3 (T.R.T. 54:07 @ 24k mono) > Intro Perl & Cool Tricks - "Map & Grep" > By: Kevin Eye > (15 - 20 Minutes) http://mikerichardson.us/bpm/2006-01-17_map_and_grep.mp3 (T.R.T. 25:33 @ 24k mono) > Intro To Writing Perl Modules > By: Kevin Eye > (45 - 60 Minutes) http://mikerichardson.us/bpm/2006-01-17_perl_modules.mp3 (T.R.T. 73:49 @ 24k mono) -- Michael Richardson Web Programmer, ePharmacotherapy Networks School of Pharmacy and Pharmaceutical Sciences State Univ. of New York at Buffalo Cooke Hall Room 309 (716)645-2828 ext. 266 From dmagnuszewski at mandtbank.com Fri Jan 27 07:22:59 2006 From: dmagnuszewski at mandtbank.com (DANIEL MAGNUSZEWSKI) Date: Fri, 27 Jan 2006 10:22:59 -0500 Subject: [Buffalo-pm] Unix Command / Bash Question... Message-ID: All, I wrote a Perl script to parse a file for ip addresses and hostnames, and to print out in the format of: $ip,$hostname There are some duplicates in the list, so I was just using some unix commands and pipes to rid them from the output. While doing this, I ran into something interesting. If I do: user at server:/opt/cwscripts# ./dcraudit.pl | uniq | grep -i '10.x.x.x' I get the output of: 10.x.x.x,router1 10.x.x.x,router1 If I switch the 'uniq' and 'grep' and run: user at server:/opt/cwscripts# ./dcraudit.pl | grep -i '10.x.x.x' | uniq I get the output of: 10.x.x.x,router1 What is the technical reason for this? I assumed that it would work either way. Thanks. -Dan From eye at buffalo.edu Fri Jan 27 07:34:44 2006 From: eye at buffalo.edu (Kevin Eye) Date: Fri, 27 Jan 2006 10:34:44 -0500 Subject: [Buffalo-pm] Unix Command / Bash Question... In-Reply-To: Message-ID: I use sort and uniq a lot. I found similar problems at one point (uniq returning duplicates). Some googling found that sort is affected by your locale and LANG environment variables. My sort man page (redhat) says: *** WARNING *** The locale specified by the environment affects sort order. Set LC_ALL=C to get the traditional sort order that uses native byte values. Some google results (search for "uniq sort broken") also suggest setting LC_ALL=POSIX or unsetting the LANG variable. I'm not sure why this makes sort behave differently, but maybe it'll help you. - Kevin On 1/27/06 10:22 AM, "DANIEL MAGNUSZEWSKI" wrote: > All, > > I wrote a Perl script to parse a file for ip addresses and hostnames, > and to print out in the format of: > > $ip,$hostname > > There are some duplicates in the list, so I was just using some unix > commands and pipes to rid them from the output. While doing this, I ran > into something interesting. > > If I do: > > user at server:/opt/cwscripts# ./dcraudit.pl | uniq | grep -i '10.x.x.x' > > I get the output of: > > 10.x.x.x,router1 > 10.x.x.x,router1 > > If I switch the 'uniq' and 'grep' and run: > > user at server:/opt/cwscripts# ./dcraudit.pl | grep -i '10.x.x.x' | uniq > > I get the output of: > > 10.x.x.x,router1 > > What is the technical reason for this? I assumed that it would work > either way. > > Thanks. > > -Dan > > _______________________________________________ > Buffalo-pm mailing list > Buffalo-pm at pm.org > http://mail.pm.org/mailman/listinfo/buffalo-pm -- Kevin Eye Web Applications Developer Marketing and Creative Services University at Buffalo 330 Crofts Hall Buffalo, NY 14260 eye at buffalo.edu phone (716) 645-5000 x1435 fax (716) 645-3765 From rdice at pobox.com Fri Jan 27 07:40:56 2006 From: rdice at pobox.com (Richard Dice) Date: Fri, 27 Jan 2006 10:40:56 -0500 Subject: [Buffalo-pm] Unix Command / Bash Question... In-Reply-To: References: Message-ID: <1138376456.43da3f082f143@webmail.tht.net> Daniel, The unix 'uniq' command collapses *adjacent* identical lines into unique lines. If I was to have a file like 1 2 1 2 1 2 and I did a "cat FILE | uniq", the output would be 1 2 1 2 1 2 The standard practice is to run sort and then uniq: "cat FILE | sort | uniq" yields 1 2 Some version of 'sort' have uniq built into it, per: "cat FILE | sort -u" yielding 1 2 Your problem lies in the realm of this. In the first case, there must be come stuff in between the two '10.x.x.x' lines that you grepped for that wasn't in the line, so the uniq wouldn't collapse these into a single line. In the second case, your grep removed those lines first, thus allowing uniq to do its job. Cheers, Richard Quoting DANIEL MAGNUSZEWSKI : > All, > > I wrote a Perl script to parse a file for ip addresses and hostnames, > and to print out in the format of: > > $ip,$hostname > > There are some duplicates in the list, so I was just using some unix > commands and pipes to rid them from the output. While doing this, I ran > into something interesting. > > If I do: > > user at server:/opt/cwscripts# ./dcraudit.pl | uniq | grep -i '10.x.x.x' > > I get the output of: > > 10.x.x.x,router1 > 10.x.x.x,router1 > > If I switch the 'uniq' and 'grep' and run: > > user at server:/opt/cwscripts# ./dcraudit.pl | grep -i '10.x.x.x' | uniq > > I get the output of: > > 10.x.x.x,router1 > > What is the technical reason for this? I assumed that it would work > either way. > > Thanks. > > -Dan > > _______________________________________________ > Buffalo-pm mailing list > Buffalo-pm at pm.org > http://mail.pm.org/mailman/listinfo/buffalo-pm > ------------------------------------------------- This mail sent through IMP: http://horde.org/imp/ From dmagnuszewski at mandtbank.com Mon Jan 30 06:07:05 2006 From: dmagnuszewski at mandtbank.com (DANIEL MAGNUSZEWSKI) Date: Mon, 30 Jan 2006 09:07:05 -0500 Subject: [Buffalo-pm] Perl Mongers Map... Message-ID: Mongers, There is a map of (almost) all the PM groups throughout the world, via google maps. The Buffalo link was not listed, but I have notified them about it and hopefully it'll show up soon. The URL isn't linked from the main site yet, but check it out: http://www.pm.org/groups/map.html -Dan From dmagnuszewski at mandtbank.com Tue Jan 31 12:04:50 2006 From: dmagnuszewski at mandtbank.com (DANIEL MAGNUSZEWSKI) Date: Tue, 31 Jan 2006 15:04:50 -0500 Subject: [Buffalo-pm] Fwd: [tpm] MJD visiting TPM (and other TLAs) Message-ID: For those interested... -------------- next part -------------- An embedded message was scrubbed... From: "Richard Dice" Subject: [tpm] MJD visiting TPM (and other TLAs) Date: Tue, 31 Jan 2006 14:49:53 -0500 Size: 1648 Url: http://mail.pm.org/pipermail/buffalo-pm/attachments/20060131/e5e77e90/attachment.mht