Re: [regexp] Multi-level pattern matching

2006-04-21 Thread Adam W
Chad Perrin wrote: Y'know, I was playing around with this to see if I could come up with a reasonably elegant solution, and I noticed a problem: Your code doesn't seem to actually work. Am I missing something? I went back to check, and it seems to only be working in very specific cases. For

Re: golf

2006-04-21 Thread Chad Perrin
On Fri, Apr 21, 2006 at 04:03:49PM -0700, John W. Krahn wrote: > Chad Perrin wrote: > > On Fri, Apr 21, 2006 at 12:48:51PM -0700, John W. Krahn wrote: > >>print/.*/g,$"while<> > > > > Woah, that's pretty short. > > You can make it even shorter: > > print/.*/g,$"for<> True, that. I'm used to us

Re: [regexp] Multi-level pattern matching

2006-04-21 Thread Chad Perrin
On Fri, Apr 21, 2006 at 02:54:29PM -0700, Adam W wrote: > > The following does about 95% of the job: > > if (/<(.*?)>/g && !/<\!/g) { # if it's an HTML and not a > #s/^(.*?)"(.*?)"/\L$1\E"$2"/g; > } Y'know, I was playing around with thi

Re: golf

2006-04-21 Thread John W. Krahn
Chad Perrin wrote: > On Fri, Apr 21, 2006 at 12:48:51PM -0700, John W. Krahn wrote: >>print/.*/g,$"while<> > > Woah, that's pretty short. You can make it even shorter: print/.*/g,$"for<> > Thanks. Now I just need to go read a bit > and figure out how exactly it works. > > . . . unless you wan

RE: How to prevent duplicate cron jobs? On windows?

2006-04-21 Thread Kenneth A. Wolcott
If you are using cygwin, then why don't you use the perl in cygwin instead of using activestate? Then you can install cpan modules directly using cygwin. On Fri, 2006-04-21 at 16:36 -0600, siegfried wrote: > I apologize, I forgot to mention something very important: I am using > cygwin's cron on

RE: How to prevent duplicate cron jobs? On windows?

2006-04-21 Thread siegfried
I apologize, I forgot to mention something very important: I am using cygwin's cron on Win2003 Server. I tried using Unix::PID but ppm.bat for ActiveState Perl could not find it. Sieg -Original Message- From: JupiterHost.Net [mailto:[EMAIL PROTECTED] Sent: Friday, April 21, 2006 2:45 PM

[regexp] Multi-level pattern matching

2006-04-21 Thread Adam W
Hello List, I'm writing a little script that will turn some webpages I have from HTML to XHTML. This requires several substitutions. So far, I have been able to write regexps that properly close link, meta, br, and hr tags and either put in or replace an existing tag. Finally, I want it t

Re: golf

2006-04-21 Thread Chad Perrin
On Fri, Apr 21, 2006 at 12:48:51PM -0700, John W. Krahn wrote: > > print/.*/g,$"while<> Woah, that's pretty short. Thanks. Now I just need to go read a bit and figure out how exactly it works. . . . unless you want to explain it. -- Chad Perrin [ CCD CopyWrite | http://ccd.apotheon.org ] "Th

Re: How to prevent duplicate cron jobs?

2006-04-21 Thread JupiterHost.Net
siegfried wrote: I have a cron job running perl and it is taking a very long time -- sometimes over 24 hours. How can I have cron schedule my job daily, or even hourly, and have the perl code exit if a previouse instance of the job is still running? perldoc Unix::PID # job.pl that gets cro

Re: How to prevent duplicate cron jobs?

2006-04-21 Thread Octavian Rasnita
From: "siegfried" <[EMAIL PROTECTED]> > I have a cron job running perl and it is taking a very long time -- > sometimes over 24 hours. > > How can I have cron schedule my job daily, or even hourly, and have the perl > code exit if a previouse instance of the job is still running? > > Some have su

RE: How to prevent duplicate cron jobs?

2006-04-21 Thread Mr. Shawn H. Corey
On Fri, 2006-21-04 at 14:48 -0400, Lewis, Cory (Genworth) wrote: > > > I have a cron job running perl and it is taking a very long time -- > > sometimes over 24 hours. > > > > How can I have cron schedule my job daily, or even hourly, > > and have the perl > > code exit if a previouse instance

Re: golf

2006-04-21 Thread John W. Krahn
M. Kristall wrote: > Chad Perrin wrote: >> This is kind of a frivolous question, but . . . is there some way to >> golf this? >> >> while (<>) { >> s/\n/ /; >> print; >> } > > How about > print/(.*)\n/while<> You probably meant: print/.*/g,$"while<> :-) John -- use Perl; program fulfi

Re: print_r

2006-04-21 Thread Jaime Murillo
On Friday 21 April 2006 11:53, Charles K. Clarkson wrote: > BTW, I think indent() could be rewritten. I think these do > the same thing as your indent(). > > sub indent { > my $indent = shift; > return '' unless defined $indent; > return '' x $indent; > } > > # Or: > > sub inde

Re: golf

2006-04-21 Thread M. Kristall
Chad Perrin wrote: This is kind of a frivolous question, but . . . is there some way to golf this? while (<>) { s/\n/ /; print; } Oops, I misread that as s/\n//; Sorry :'( -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: golf

2006-04-21 Thread M. Kristall
Chad Perrin wrote: This is kind of a frivolous question, but . . . is there some way to golf this? while (<>) { s/\n/ /; print; } How about print/(.*)\n/while<> ? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: print_r

2006-04-21 Thread Charles K. Clarkson
Johannes Ernst wrote: : I also realize that Cpan exists ;-) but that this piece of code : isn't quite ready to go into Cpan, which is why I didn't put it : there. I'm only posting this in the hope that somebody, one day, : may think it could be marginally useful. That's all. I'm making : no claims

RE: How to prevent duplicate cron jobs?

2006-04-21 Thread Lewis, Cory \(Genworth\)
> I have a cron job running perl and it is taking a very long time -- > sometimes over 24 hours. > > How can I have cron schedule my job daily, or even hourly, > and have the perl > code exit if a previouse instance of the job is still running? > > Some have suggested creating a file in /tmp

Re: How to prevent duplicate cron jobs?

2006-04-21 Thread John W. Krahn
siegfried wrote: > I have a cron job running perl and it is taking a very long time -- > sometimes over 24 hours. > > How can I have cron schedule my job daily, or even hourly, and have the perl > code exit if a previouse instance of the job is still running? > > Some have suggested creating a f

Re: Extracting a bit of a scalar variable

2006-04-21 Thread Jaime Murillo
On Friday 21 April 2006 10:15, Smith, Derek wrote: > -Original Message- > From: Smith, Derek > Sent: Friday, April 21, 2006 10:22 AM > To: Perl Beginners > Subject: RE: Extracting a bit of a scalar variable > > > Original Message- > From: Dr.Ruud [mailto:[EMAIL PROTECTED] > Sent: Fr

Re: regular expressions

2006-04-21 Thread John W. Krahn
Bowen, Bruce wrote: > In perldoc under this topic s is listed as "Treat string as a single > line" and m as Treat string as multiples lines". > > If I have text that has varying spaces at the begging of each line, > and I use > > $string =~ s/^\s+//; It will remove the spaces from in from of th

How to prevent duplicate cron jobs?

2006-04-21 Thread siegfried
I have a cron job running perl and it is taking a very long time -- sometimes over 24 hours. How can I have cron schedule my job daily, or even hourly, and have the perl code exit if a previouse instance of the job is still running? Some have suggested creating a file in /tmp and checking it bef

Re: print_r

2006-04-21 Thread Johannes Ernst
Many people indeed suggested Data::Dumper, in fact I did so myself in my original message when I asked: http://www.nntp.perl.org/group/perl.beginners/81554 The problem with Data::Dumper is that it is way too low-level for most application-level debugging, e.g. as I said then: "(I don't w

Re: Average from array of arrays

2006-04-21 Thread John W. Krahn
The Other1 wrote: > Hi all, Hello, > Sorta newbie here... > > I have parsed log files and have an array of arrays that looks like this: > > [...] > 1 0.0 0.000 31.954 36.169 12.645 20:40 > 16 1048.0 16.196 15.825 52.502 5.150 20:40 > 8 1281.7 12.059 9.634 41.264 4.869 20:40 > 9 1157.7 19.094 16

RE: Extracting a bit of a scalar variable

2006-04-21 Thread Smith, Derek
-Original Message- From: Smith, Derek Sent: Friday, April 21, 2006 10:22 AM To: Perl Beginners Subject: RE: Extracting a bit of a scalar variable Original Message- From: Dr.Ruud [mailto:[EMAIL PROTECTED] Sent: Friday, April 21, 2006 9:19 AM To: beginners@perl.org Subject: Re: E

Re: arguments

2006-04-21 Thread Dr.Ruud
"Mr. Shawn H. Corey" schreef: > Tom Allison: >> Maybe I'm getting old, but I'm starting to thing that if there is a >> method/sub/function/whatever that has more than one argument, one >> should always pass the args as a hash reference. This eliminates >> the problems of getting the variables out

Re: Handeling huge hashes.

2006-04-21 Thread Dr.Ruud
Rob Coops schreef: > I have two quite large hashes each are several hundreds of MB's in > size, now I want to with some logic merge these into a single hash. I > this works of course but as one might imagine this takes quite a lot > of memory. And can depending on the machine simply run out of mem

RE: Extracting a bit of a scalar variable

2006-04-21 Thread Smith, Derek
Original Message- From: Dr.Ruud [mailto:[EMAIL PROTECTED] Sent: Friday, April 21, 2006 9:19 AM To: beginners@perl.org Subject: Re: Extracting a bit of a scalar variable Praveena Vittal schreef: > I am newbie to PERL. ITYM: Perl. > I think this is a very simple question to ask. Well,

Re: regular expressions

2006-04-21 Thread Xavier Noria
On Apr 21, 2006, at 16:10, Bowen, Bruce wrote: In perldoc under this topic s is listed as "Treat string as a single line" and m as Treat string as multiples lines". If I have text that has varying spaces at the begging of each line, and I use $string =~ s/^\s+//; It will remove the space

Re: Handeling huge hashes.

2006-04-21 Thread Mr. Shawn H. Corey
On Fri, 2006-21-04 at 14:39 +0200, Rob Coops wrote: > Good day list, > > I hope there is someone out there that can point me in the right direction > to find a solution for this. > > I have two quite large hashes each are several hundreds of MB's in size, now > I want to with some logic merge the

regular expressions

2006-04-21 Thread Bowen, Bruce
In perldoc under this topic s is listed as "Treat string as a single line" and m as Treat string as multiples lines". If I have text that has varying spaces at the begging of each line, and I use $string =~ s/^\s+//; It will remove the spaces from in from of the first line but not any other l

Re: Extracting a bit of a scalar variable

2006-04-21 Thread Dr.Ruud
Praveena Vittal schreef: > I am newbie to PERL. ITYM: Perl. > I think this is a very simple question to ask. Well, let's see. > Is there any way to print a particular bit of a digit after converting > to binary form. Why convert anything "to binary" first, if you can use "$var & (1 << $bitp

Handeling huge hashes.

2006-04-21 Thread Rob Coops
Good day list, I hope there is someone out there that can point me in the right direction to find a solution for this. I have two quite large hashes each are several hundreds of MB's in size, now I want to with some logic merge these into a single hash. I this works of course but as one might ima

Re: Average from array of arrays

2006-04-21 Thread Mr. Shawn H. Corey
On Thu, 2006-20-04 at 20:55 -0600, The Other1 wrote: > My question is how to walk through the array grabbing column 1 of four rows, > pass those values to the Average function (or if there is a beter way, I am > open to it!), store the average to be used by GD later, then do the next > column, e

Re: print_r

2006-04-21 Thread Mr. Shawn H. Corey
On Thu, 2006-20-04 at 23:14 -0700, Johannes Ernst wrote: > Some time ago I asked about a print_r implementation in Perl. > > print_r: print object structures recursively, as in PHP, see http:// > php.net/print_r > > Because nobody seemed to have a good answer, we built our own. It has > some i

Re: arguments

2006-04-21 Thread Mr. Shawn H. Corey
On Thu, 2006-20-04 at 20:54 -0400, Tom Allison wrote: > Maybe I'm getting old, but I'm starting to thing that if there is a > method/sub/function/whatever that has more than one argument, one should > always > pass the args as a hash reference. This eliminates the problems of getting > the >

Re: print_r

2006-04-21 Thread Randal L. Schwartz
> "Johannes" == Johannes Ernst writes: Johannes> Some time ago I asked about a print_r implementation in Perl. Johannes> print_r: print object structures recursively, as in PHP, see http:// Johannes> php.net/print_r Johannes> Because nobody seemed to have a good answer, we built our own. It

Average from array of arrays

2006-04-21 Thread The Other1
Hi all, Sorta newbie here... I have parsed log files and have an array of arrays that looks like this: [...] 1 0.0 0.000 31.954 36.169 12.645 20:40 16 1048.0 16.196 15.825 52.502 5.150 20:40 8 1281.7 12.059 9.634 41.264 4.869 20:40 9 1157.7 19.094 16.889 52.218 4.742 20:40 0 0.0 0.000 76.430 10

Re: strange errormessage from script run in cron

2006-04-21 Thread Bjørge Solli
On Thursday 20 April 2006 23:31, John W. Krahn wrote: > Bjørge Solli wrote: > > On Thursday 20 April 2006 12:01, John W. Krahn wrote: > >>Bjørge Solli wrote: > >>>I have this as a part of my script: > >>> > >>>$ncfile = `ls -1 $mersea_cat | head -1`; > >>>print $ncfile; > >>> > >>>It prints

Re: Extracting a bit of a scalar variable

2006-04-21 Thread Xavier Noria
On Apr 21, 2006, at 20:59, Praveena Vittal wrote: Is there any way to print a particular bit of a digit after converting to binary form. That can be easily done with substr y sprintf, this would take the second bit of 7 written in base 2: % perl -wle 'print substr sprintf("%b", 7), -2,