RE: regex one liner

2006-03-21 Thread stu meacham
> perl -i -p -e 's/^(\d{2}\t\d{2}\t\d{2})/g' This was the 1st thing that I > tried; it doesn't work. It was initially easy but different things kept > appearing that forced me to use > 1 statements on the command line. Negating what I want seems like it ought to be simple. > > > What have

SIGNALS & OOP

2006-03-21 Thread Tom Allison
I'm trying to refactor an application I wrote a few months ago and ran into a question about SIG{TERM}. Currently I have a single application that uses the approach of: my $please_die = 0; $SIG{TERM} = sub {$please_die = 1 }; to control when I should exit out of different loops and structures.

threads

2006-03-21 Thread Octavian Rasnita
Hi, I have tried the following script: use threads; my $threads = async {foreach(1 .. 70) {download($_)}}; $threads->join(); $threads->detach(); sub download {...} This program takes the same amount of time to run like when not using threads, but a simple for() loop. How can I make it to run a

Re: printing die error ina file

2006-03-21 Thread Mr. Shawn H. Corey
Jeff Pang wrote: So why wouldn't you redirect STDOUT and STDERR to this file too? Many other Perl's errors, like division by zero, are not handle via die or warn. And these messages are printed out even if encountered in an eval. When operating the files (including opening and writing and cl

Re: threads

2006-03-21 Thread Jay Savage
On 3/21/06, Octavian Rasnita <[EMAIL PROTECTED]> wrote: > Hi, > > I have tried the following script: > use threads; > my $threads = async {foreach(1 .. 70) {download($_)}}; This creates a single thread to execute the block. The choice between $threads->create and async has to do with whether you'r

Re: regex one liner

2006-03-21 Thread Jay Savage
On 3/20/06, stu meacham <[EMAIL PROTECTED]> wrote: > > > perl -i -p -e 's/^(\d{2}\t\d{2}\t\d{2})/g' This was the 1st thing that I > > tried; it doesn't work. It was initially easy but different things kept > > appearing that forced me to use > 1 > statements on the command line. Negating what

Re: printing die error ina file

2006-03-21 Thread Jay Savage
On 3/21/06, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: > Jeff Pang wrote: > >> So why wouldn't you redirect STDOUT and STDERR to this file too? Many > >> other Perl's errors, like division by zero, are not handle via die or > >> warn. And these messages are printed out even if encountered in an

Re: threads

2006-03-21 Thread Stephen Kratzer
I'm not too familiar with threads, but I'll give it a go. You're still executing the download() sub seventy times one after another rather than concurrently. The async function will created one new thread for the block following it. You might try a for loop which creates a new thread at each it

Re: printing die error ina file

2006-03-21 Thread Jeff Pang
>using a logging facility (either RYO or a syslog interface) to log, >using that interface to write both the data and the errors I'm >interested in (which may be differnt from what Perl sees fit to write >to STDERR) to the appropriate files, and redirecting STDERR to >/dev/null so it doesn't clutte

Re: printing die error ina file

2006-03-21 Thread Mr. Shawn H. Corey
Jay Savage wrote: As for simply redirecting STDERR, most people don't really want to do this with a daemon. If you're using strictures and warnings, you expect many daemons to produce hundres, possibly thousands, of lines of warnings, depending on the purpose of the daemon, how busy it is, and ho

Re: SIGNALS & OOP

2006-03-21 Thread Mr. Shawn H. Corey
Tom Allison wrote: I'm trying to refactor an application I wrote a few months ago and ran into a question about SIG{TERM}. Currently I have a single application that uses the approach of: my $please_die = 0; $SIG{TERM} = sub {$please_die = 1 }; to control when I should exit out of different lo

Perl/Syslog: openlog is very slow in sending syslog message

2006-03-21 Thread Ravi Malghan
Hi: I am trying to use the following lines in a program where I want to log syslog messages. == openlog($zone, 'ndelay','local7'); syslog('debug', $log); closelog; == But the function openlog takes 30-40 seconds to complete. Any idea why it takes this long and also if there is a wa

Re: printing die error ina file

2006-03-21 Thread Mr. Shawn H. Corey
Jeff Pang wrote: using a logging facility (either RYO or a syslog interface) to log, using that interface to write both the data and the errors I'm interested in (which may be differnt from what Perl sees fit to write to STDERR) to the appropriate files, and redirecting STDERR to /dev/null so it

Perl Help

2006-03-21 Thread Irfan J Sayed
Hi All, I have written following perl code use CQPerlExt; use Prima; use Prima::Application; use Prima::MsgBox; $sessionobj = $entity->GetSession(); $username = $session->GetUserLoginName(); Prima::MsgBox::message( "You have entered: '$username'", mb::Ok); but when i compile

Re: regex one liner

2006-03-21 Thread stu meacham
I tried one final time with non-capturing parentheses i.e. (?: to no avail. This works just fine however: perl -i -p -e '@matches = m/\d{2}\t\d{2}\t\d{2}/g; s/.*//g; print"@matches\n"' Retrieve, delete what's left, and rewrite what's to be kept. It should now work everytime all the time. C

Re: threads

2006-03-21 Thread Octavian Rasnita
From: "Stephen Kratzer" <[EMAIL PROTECTED]> > I'm not too familiar with threads, but I'll give it a go. You're still > executing the download() sub seventy times one after another rather than > concurrently. The async function will created one new thread for the block > following it. You might try

RE: regex one liner

2006-03-21 Thread Timothy Johnson
We run into one of these "How do I do this in a one-liner?" questions pretty frequently, and I for one have to ask, what exactly makes the one-liner so compelling, especially when you are using it for something that will be run repeatedly? IMHO it would have been much more practical to just creat

Re: regex one liner

2006-03-21 Thread Jay Savage
On 3/21/06, Timothy Johnson <[EMAIL PROTECTED]> wrote: > > We run into one of these "How do I do this in a one-liner?" questions > pretty frequently, and I for one have to ask, what exactly makes the > one-liner so compelling, especially when you are using it for something > that will be run repeat

Re: regex one liner

2006-03-21 Thread Mr. Shawn H. Corey
Timothy Johnson wrote: We run into one of these "How do I do this in a one-liner?" questions pretty frequently, and I for one have to ask, what exactly makes the one-liner so compelling, especially when you are using it for something that will be run repeatedly? Because you can use them in alia

Re: threads

2006-03-21 Thread Jay Savage
On 3/21/06, Octavian Rasnita <[EMAIL PROTECTED]> wrote: > From: "Stephen Kratzer" <[EMAIL PROTECTED]> > > > I'm not too familiar with threads, but I'll give it a go. You're still > > executing the download() sub seventy times one after another rather than > > concurrently. The async function will c

RE: regex one liner

2006-03-21 Thread Timothy Johnson
> >-Original Message- >From: Mr. Shawn H. Corey [mailto:[EMAIL PROTECTED] >Sent: Tuesday, March 21, 2006 1:36 PM >To: beginners perl >Subject: Re: regex one liner > >Timothy Johnson wrote: >> We run into one of these "How do I do this in a one-liner?" questions >> pretty frequently, and I f

Re: regex one liner

2006-03-21 Thread Mr. Shawn H. Corey
Timothy Johnson wrote: And you can't do this? alias pcalc='perl ~/pcalc.pl' No. With alias, I can create an alias file that works with sh (and ksh, bash) and csh (and tcsh). This would be dot'ed in your .profile as: . ~/.alias or source'd in your .cshrc as: source ~/.alias If you

Re: regex one liner

2006-03-21 Thread Kevin Viel
BTW, out here in the real world (that would be UNIX), *.pl stands for Perl Library file, not a script. What extension do you suggest using, if any, in the real world? Thanks, Kevin -- Kevin Viel Department of Genetics

Re: regex one liner

2006-03-21 Thread Dave Gray
On 3/21/06, Kevin Viel <[EMAIL PROTECTED]> wrote: > > BTW, out here in the real world (that would be UNIX), *.pl stands for > > Perl Library file, not a script. > > What extension do you suggest using, if any, in the real world? .ps for perl script /snicker -- To unsubscribe, e-mail: [EMAIL PROT

Re: regex one liner

2006-03-21 Thread Jay Savage
the incredible missing reply-to field strikes again... On 3/21/06, Jay Savage <[EMAIL PROTECTED]> wrote: > On 3/21/06, Timothy Johnson <[EMAIL PROTECTED]> wrote: > > > > > >-Original Message- > > >From: Mr. Shawn H. Corey [mailto:[EMAIL PROTECTED] > > >Sent: Tuesday, March 21, 2006 1:36 PM

RE: regex one liner

2006-03-21 Thread Timothy Johnson
> > >-Original Message- >From: Mr. Shawn H. Corey [mailto:[EMAIL PROTECTED] >Sent: Tuesday, March 21, 2006 2:29 PM >To: beginners perl >Subject: Re: regex one liner > >Timothy Johnson wrote: >> And you can't do this? >> >> alias pcalc='perl ~/pcalc.pl' > >No. With alias, I can create an

RE: regex one liner

2006-03-21 Thread Timothy Johnson
> >-Original Message- >From: Jay Savage [mailto:[EMAIL PROTECTED] >Sent: Tuesday, March 21, 2006 3:06 PM >To: Timothy Johnson >Subject: Re: regex one liner >> >> >> And as for the issue of slightly varying regexes as arguments to a >> script (different email), it may seem easier to you,

Re: regex one liner

2006-03-21 Thread Omega -1911
With all the debate going on, let me just say that a perl script was THE ONLY method that allowed me to change paths in 13,161 files and scripts when I moved from one provider to another. Try a *one-liner" on multiple files (13,000+) located in different directories... With a Perl script, I can ma

Re: regex one liner

2006-03-21 Thread Chad Perrin
On Tue, Mar 21, 2006 at 09:27:28AM -0500, Jay Savage wrote: > On 3/20/06, stu meacham <[EMAIL PROTECTED]> wrote: > > > > > perl -i -p -e 's/^(\d{2}\t\d{2}\t\d{2})/g' This was the 1st thing that I > > > tried; it doesn't work. It was initially easy but different things kept > > > appearing that

Re: regex one liner

2006-03-21 Thread Chad Perrin
On Tue, Mar 21, 2006 at 04:32:21PM -0700, Chad Perrin wrote: > > misused the carat. Mea culpa, Jay. I didn't mean to lead you astray. . . . and here I go with the stupid mistakes again. I meant Stu, not Jay. -- Chad Perrin [ CCD CopyWrite | http://ccd.apotheon.org ] "Real ugliness is not har

Re: regex one liner

2006-03-21 Thread Chad Perrin
On Tue, Mar 21, 2006 at 04:05:17PM -0700, Dave Gray wrote: > On 3/21/06, Kevin Viel <[EMAIL PROTECTED]> wrote: > > > BTW, out here in the real world (that would be UNIX), *.pl stands for > > > Perl Library file, not a script. > > > > What extension do you suggest using, if any, in the real world? >

Re: SIGNALS & OOP

2006-03-21 Thread John W. Krahn
Mr. Shawn H. Corey wrote: > Tom Allison wrote: >> I'm trying to refactor an application I wrote a few months ago and ran >> into a question about SIG{TERM}. >> >> Currently I have a single application that uses the approach of: >> >> my $please_die = 0; >> $SIG{TERM} = sub {$please_die = 1 }; >> >>

Re: regex one liner

2006-03-21 Thread Mr. Shawn H. Corey
Timothy Johnson wrote: Beyond being rude and immature, this is off-topic. Please don't try to start a "my OS is better than your OS" war. I wasn't trying to be rude but Perl was developed and evolved in UNIX; something most people don't know. In UNIX, all scripts, whether there are Perl, sh,

Re: regex one liner

2006-03-21 Thread Mr. Shawn H. Corey
Chad Perrin wrote: Actually, I tend to either use no file extension or .plx as the file extension for a non-library script. I'm pretty sure ActivePerl recognizes .plx (not entirely sure, but pretty sure), though I generally do all my scripting on *nix, so it's not really an issue here. In UNI

Re: SIGNALS & OOP

2006-03-21 Thread Mr. Shawn H. Corey
John W. Krahn wrote: If you use the package name then you don't need to use our(): $ perl -Mwarnings -Mstrict -le'$main::var = q[test]; print $main::var' test John True. But if you don't use 'our' you would always have to use its fully-qualified name. $main::please_die = 0; $SIG{TER

Perl Hash of arrays : comparison

2006-03-21 Thread Sonika Sachdeva
Hi, I have Hash of array. I want to compare the array values within the hash. How can it be done? if ($eline =~ /$pattern/ ) { $eline =~ /(.*)\"(\w+)\s(.*)\?(.*)\"/ ; my $uniq=$1; my $url=$4; chomp($uniq);chomp($url); my @var= ( split("&",$url) );

RE: Perl Hash of arrays : comparison

2006-03-21 Thread Timothy Johnson
You need to dereference the array at $var{$key} in a similar way to the way you did it when you created the array, so something like this should work: foreach my $key(keys %VAR){ foreach my $element(@{$VAR{$key}}){ #do something... } } -Original Message- From: Sonika Sachdeva

Re: SIGNALS & OOP

2006-03-21 Thread Jeff Pang
when I should exit out of different loops and structures. > >But if I have a script that uses objects, how to I propogate this to the >objects from the main script? > I would suggest you read this article " Using Global Variables and Sharing Them Between Modules/Packages" writen by Stas Bekman:

Re: Perl Hash of arrays : comparison

2006-03-21 Thread Mr. Shawn H. Corey
Sonika Sachdeva wrote: I have Hash of array. I want to compare the array values within the hash. How can it be done? if ($eline =~ /$pattern/ ) { $eline =~ /(.*)\"(\w+)\s(.*)\?(.*)\"/ ; my $uniq=$1; my $url=$4; chomp($uniq);chomp($url); my @var= (

Re: Perl Hash of arrays : comparison

2006-03-21 Thread John W. Krahn
Sonika Sachdeva wrote: > Hi, Hello, > I have Hash of array. I want to compare the array values within the hash. > How can it be done? > > if ($eline =~ /$pattern/ ) { > $eline =~ /(.*)\"(\w+)\s(.*)\?(.*)\"/ ; my $uniq=$1; my > $url=$4; You shouldn't use the numerical variables i

Re: SIGNALS & OOP

2006-03-21 Thread Jay Savage
On 3/21/06, Tom Allison <[EMAIL PROTECTED]> wrote: > > I'm trying to refactor an application I wrote a few months ago and ran > into a question about SIG{TERM}. > > Currently I have a single application that uses the approach of: > > my $please_die = 0; > $SIG{TERM} = sub {$please_die = 1 }; > > to

Need to run a program concurrently by multiple users

2006-03-21 Thread prabhath g
Hi, I have a build script which needs to run by multiple users(concurrently). Currently only one user can run this program.What are the code changes to make this program run concurrently. As I am a new comer to perl , I request you to give me advice/suggestions . Reg

Re: Need to run a program concurrently by multiple users

2006-03-21 Thread Chad Perrin
On Tue, Mar 21, 2006 at 10:36:46PM -0800, prabhath g wrote: > > I have a build script which needs to run by multiple > users(concurrently). Currently only one user can run this program.What are > the code changes to make this program run concurrently. > That's pretty difficult to a