Re: using CTRL-C to abort a routine?

2006-07-05 Thread Jorge Almeida
On Tue, 4 Jul 2006, John W. Krahn wrote: You could try something like this (UNTESTED): # main program $SIG{ INT } = 'IGNORE'; sub abortmyroutine { $SIG{ INT } = 'IGNORE'; # do some cleaning... {...} } {...} myroutine(); {...} sub myroutine { # do something {...} $SIG{ INT

Re: FORMAT question

2006-07-05 Thread Mumia W.
Offer Kaye wrote: Hi, Can anyone tell me if it is possible to define 2 different formats for the same filehandle? The reason I am asking is that I want to print 2 different tables to the same text file and I don't want to use printf statements. For me at least, code that uses printf to print som

Re: FORMAT question

2006-07-05 Thread John W. Krahn
Offer Kaye wrote: > Hi, Hello, > Can anyone tell me if it is possible to define 2 different formats for > the same filehandle? > > The reason I am asking is that I want to print 2 different tables to > the same text file and I don't want to use printf statements. For me > at least, code that use

Leading zero with sprintf and option "f".

2006-07-05 Thread John Hennessy
Hi, how is it possible to prefix a leading zero to the $Count result below when this value is less than 100. ? while ($count < 110.000) { $count += 10; $Count = sprintf "%03.4f", $count; print "Count is now $Count\n"; } I am using %03.4f to provide output that looks like 100.

extend tcl to perl

2006-07-05 Thread hot flame
Hi, How to extend tcl to perl. Say for example I have some perl scripts and I want to call them from inside tcl scripts and have perl scripts return values to tcl. A very basic example will be of great help. thanks trm

Re: Leading zero with sprintf and option "f".

2006-07-05 Thread John W. Krahn
John Hennessy wrote: > Hi, how is it possible to prefix a leading zero to the $Count result > below when this value is less than 100. ? > > > while ($count < 110.000) { >$count += 10; >$Count = sprintf "%03.4f", $count; >print "Count is now $Count\n"; > } > > I am using %03.4f to

Re: FORMAT question

2006-07-05 Thread Offer Kaye
On 7/5/06, John W. Krahn wrote: #!/usr/bin/perl use warnings; use strict; sub _print_format1 { # output table 1, with 3 columns $^A = ''; formline <<'FORMAT', @_; @<< @>>> @< FORMAT $^A; } Wow. That's... impressive. Ver

Re: FORMAT question

2006-07-05 Thread Mumia W.
Offer Kaye wrote: On 7/5/06, Jeff Peng wrote: Hello, I think there are not relation between your implement and the filehandle. As far as I can tell, a format must have the same name as the filehandle to which you want to print it, and once you define a format you cannot change it. So these 2

Re: Leading zero with sprintf and option "f".

2006-07-05 Thread Mumia W.
John Hennessy wrote: [...] I am using %03.4f to provide output that looks like 100. I would like number less than 100. to look like 099. I would like to keep the 3 digits prior to the decimal point either with or without the leading zero as required. Any suggestions welcomed. Than

how to avoid "spawning" multiple process of the same script ..

2006-07-05 Thread BenBart
Hi all, How do I prevent multiple instance of the same script from running? That is for example, if I have a script named script1.pl and it is already running, I want the script to be able to check that it is already running and then just exit ... Is this possible to do in both UNIX and Wind

Re: FORMAT question

2006-07-05 Thread Mr. Shawn H. Corey
Offer Kaye wrote: > Hi, > Can anyone tell me if it is possible to define 2 different formats for > the same filehandle? > Yes. Use the select command to select the filehandle of the file. Then use the special variables $~ and $^ to change the format. The format name can be anything you want but i

Perl's fork ... any example please ...

2006-07-05 Thread BenBart
Hi all, Am getting confused on how to use fork, does anyone have an example on how to use this or where and what is it used for ??? Not sure if this is what I needed Is fork the equivalent of running the UNIX wait command when writing a UNIX script where you want to make sure that

RE: how to avoid "spawning" multiple process of the same script ..

2006-07-05 Thread Jeff Peng
That is for example, if I have a script named script1.pl and it is already running, I want the script to be able to check that it is already running and then just exit ... Do you mean you check this script's running status from extern environment?If this script is running,you could get its p

Perl's system "[OS_COMMAND]"

2006-07-05 Thread BenBart
Hi all, Is there another option of running an OS command or UNIX script besides using system "[OS_COMMAND]", for example system "cat /etc/hosts" or system "[UNIX_SCRIPT]"? How can I make sure that the system '[OS_COMMAND]" finishes its run before I proceed to run the rest of the codes in the

Re: how to avoid "spawning" multiple process of the same script ..

2006-07-05 Thread Dr.Ruud
BenBart schreef: > How do I prevent multiple instance of the same script from running? See perldoc -f flock -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Perl's system "[OS_COMMAND]"

2006-07-05 Thread Prabu
Hello Ben, Hope this is what u expected #!/usr/bin/perl system("cat /etc/hosts"); print `cat /etc/hosts`; $? contains the status returned by the last pipe close, backtick(``) command or *system* operator. -- Prabu.M.A When I was born I was so surprised I didnt talk for a period and

Re: Perl's system "[OS_COMMAND]"

2006-07-05 Thread Beginner
On 5 Jul 2006 at 23:12, BenBart wrote: > Is there another option of running an OS command or UNIX script besides > using system "[OS_COMMAND]", for example system "cat /etc/hosts" or > system "[UNIX_SCRIPT]"? Yes, as you already know: exec, folk and there's the backtick operator `. > How can I

An annoying memory leak

2006-07-05 Thread mickb
Hello, I have to write a "daemon" in Perl, with the quite simple structure below : sub test { while(1) { Oracle database connection; $state = result of a database query; if ( $state == 1 ) { call to another function; } } } My function "test" works and make

Re: An annoying memory leak

2006-07-05 Thread Mr. Shawn H. Corey
[EMAIL PROTECTED] wrote: > Hello, > > I have to write a "daemon" in Perl, with the quite simple structure below : > > sub test { >while(1) { > Oracle database connection; > $state = result of a database query; > > if ( $state == 1 ) { > call to another function; >

Re: An annoying memory leak

2006-07-05 Thread Rob Dixon
[EMAIL PROTECTED] wrote: > > Hello, > > I have to write a "daemon" in Perl, with the quite simple structure below : > > sub test { >while(1) { > Oracle database connection; > $state = result of a database query; > > if ( $state == 1 ) { > call to another function; >

Re: An annoying memory leak

2006-07-05 Thread Dr.Ruud
[EMAIL PROTECTED] schreef: > I have to write a "daemon" in Perl, with the quite simple structure > below : > > sub test { >while(1) { > Oracle database connection; > $state = result of a database query; > > if ( $state == 1 ) { > call to another function; > } >

Many lists

2006-07-05 Thread Monomachus
Is there possible to create a n-number of lists in a cycle? I.e. for (1..$n){ my @R.$_; } or smth like this ... I know that 'my' will work only in this loop. So i am waiting for the answer. Thanks, Monomachus Don't worry, Be Happy -- To unsubscribe, e-mail

Re: Many lists

2006-07-05 Thread Dr.Ruud
Unknown Sender schreef: > Is there possible to create a n-number of lists in a cycle? > I.e. > for (1 .. $n) { > my @R.$_; > } > or smth like this ... I know that 'my' will work only in this loop. > So i am waiting for the answer. Thanks, See "perldoc perllol". -- Affijn, Ruud "

Re: Many lists

2006-07-05 Thread Bryan Harris
> Is there possible to create a n-number of lists in a cycle? > I.e. for (1..$n){ > my @R.$_; > } > or smth like this ... I know that 'my' will work only in this loop. So i am > waiting for the answer. Do you mean an array of arrays? my @R; for (1..$n) { push @R, [ 1..$_ ]; } Here, each el

RE: Many lists

2006-07-05 Thread Jeff Peng
Is there possible to create a n-number of lists in a cycle? I.e. for (1..$n){ my @R.$_; } or smth like this ... I know that 'my' will work only in this loop. So i am waiting for the answer. Consider this example: use strict; my $n = 3; my %hash; for (1 .. $n){ $hash{$_} = [ ... ]; } N

Re: Many lists

2006-07-05 Thread Mr. Shawn H. Corey
Monomachus wrote: > Is there possible to create a n-number of lists in a cycle? > I.e. for (1..$n){ > my @R.$_; You cannot concatenation an array to a scalar. Concatenation only works with two strings. See `perldoc perlop`. > } > -- __END__ Just my 0.0002 million dollars worth, --- Sh

Providing STDIN to a PIPEd call to perl

2006-07-05 Thread Kevin Viel
I call a perl script from SAS using a pipe. The file on which the script acts changes. Is there a way to provide the file name to the script using STDIN on the command line? The SAS call looks like: filename ABI pipe "perl C:/base.ps" ; For now, I altered the script to read a text file cont

Hash - narff

2006-07-05 Thread Beginner
Hi, I am being a bit lazy here. I already had this hash defined (cut & pasted from another file) and didn't want to re-type it. my %char = ( 65 => 'a', 66 => 'b', 67 => 'c', 68 => 'd', 69 => 'e', 70 => 'f', 71 => 'g', 72 => 'h',

RE: Hash - narff

2006-07-05 Thread Timothy Johnson
You'd be better off making a second hash: my %reverse_char; while(my($key,$value) = each %char){ $reverse_char{$value} = $key; } print $reverse_char{a}; -Original Message- From: Beginner [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 05, 2006 8:48 AM To: beginners@perl.org Subj

Re: Hash - narff

2006-07-05 Thread Mr. Shawn H. Corey
Beginner wrote: > But now I need to find the key given the value. EG: What is the ASCII value > for 'a'? > %char = reverse %char; Note that this trick only works if the values of the original hash are unique. -- __END__ Just my 0.0002 million dollars worth, --- Shawn "For the things

Re: Providing STDIN to a PIPEd call to perl

2006-07-05 Thread Mr. Shawn H. Corey
Kevin Viel wrote: > I call a perl script from SAS using a pipe. The file on which the > script acts changes. Is there a way to provide the file name to the > script using STDIN on the command line? The SAS call looks like: > > filename ABI pipe "perl C:/base.ps" ; > > For now, I altered the sc

Re: Providing STDIN to a PIPEd call to perl

2006-07-05 Thread Kevin Viel
Mr. Shawn H. Corey wrote: Kevin Viel wrote: I call a perl script from SAS using a pipe. The file on which the script acts changes. Is there a way to provide the file name to the script using STDIN on the command line? The SAS call looks like: filename ABI pipe "perl C:/base.ps" ; For now,

Re: Hash - narff

2006-07-05 Thread Dr.Ruud
"Beginner" schreef: > I am being a bit lazy here. I already had this hash defined (cut & > pasted from another file) and didn't want to re-type it. > > my %char = ( > 65 => 'a', > ... > ); > > > But now I need to find the key given the value. EG: What is the ASCII > value for 'a'? > > Am I being d

Re: Providing STDIN to a PIPEd call to perl

2006-07-05 Thread Mr. Shawn H. Corey
Kevin Viel wrote: > That should work, but I cannot use the keyboard to provide the STDIN. > Instead I was hoping for something like: > > filename ABI pipe "perl C:/base.ps >file.ab1" ; >^ > > Thanks, > > Kevin > > How about? my $filename = <>; c

Re: Providing STDIN to a PIPEd call to perl

2006-07-05 Thread Chad Perrin
On Wed, Jul 05, 2006 at 11:31:55AM -0500, Kevin Viel wrote: > Mr. Shawn H. Corey wrote: > >Kevin Viel wrote: > > > >>I call a perl script from SAS using a pipe. The file on which the > >>script acts changes. Is there a way to provide the file name to the > >>script using STDIN on the command line

RE: What is the function of BEGIN in perl

2006-07-05 Thread Smith, Derek
-Original Message- From: Mr. Shawn H. Corey [mailto:[EMAIL PROTECTED] Sent: Monday, May 01, 2006 7:36 PM To: chen li Cc: beginners@perl.org Subject: Re: What is the function of BEGIN in perl On Mon, 2006-01-05 at 15:32 -0700, chen li wrote: > Dear all, > > Recently I read some source c

Re: Hash - narff

2006-07-05 Thread Mumia W.
Beginner wrote: Hi, I am being a bit lazy here. I already had this hash defined (cut & pasted from another file) and didn't want to re-type it. my %char = ( 65 => 'a', 66 => 'b', 67 => 'c', 68 => 'd', [...] But now I need to find the key given the value. EG: Wh

Re: What is the function of BEGIN in perl

2006-07-05 Thread Mr. Shawn H. Corey
Smith, Derek wrote: > Doesn't the BEGIN and INIT constructs provide the same behavior? No. From `perldoc perlrun`: -c causes Perl to check the syntax of the program and then exit without executing it. Actually, it will execute "BEGIN", "CHECK", and "use" blocks, because these are consid

RE: What is the function of BEGIN in perl

2006-07-05 Thread Smith, Derek
-Original Message- From: Mr. Shawn H. Corey [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 05, 2006 1:21 PM To: Perl Beginners Subject: Re: What is the function of BEGIN in perl Smith, Derek wrote: > Doesn't the BEGIN and INIT constructs provide the same behavior? No. From `perldoc pe

Re: Hash - narff

2006-07-05 Thread Rob Dixon
Beginner wrote: > > I am being a bit lazy here. I already had this hash defined (cut & > pasted from another file) and didn't want to re-type it. > > my %char = ( > 65 => 'a', > 66 => 'b', > 67 => 'c', > 68 => 'd', > 69 => 'e', > 70 => 'f', > 71 => 'g', > 72 => 'h', > 73 => 'i',

Re: Perl's fork ... any example please ...

2006-07-05 Thread Tommy Nordgren
6 jul 2006 kl. 08.08 skrev BenBart: Hi all, Am getting confused on how to use fork, does anyone have an example on how to use this or where and what is it used for ??? Not sure if this is what I needed Is fork the equivalent of running the UNIX wait command when writing a UNIX

Re: how to avoid "spawning" multiple process of the same script ..

2006-07-05 Thread dzhuo
one common way of doing this sort of stuff is to have your script write a PID (process ID) file. when you start up your process, your script will check for this file, if the file is there, a copy of it is already running. if the file is missing, your script will create the PID file and continue

Re: how to avoid "spawning" multiple process of the same script ..

2006-07-05 Thread Mr. Shawn H. Corey
BenBart wrote: > Hi all, > > How do I prevent multiple instance of the same script from running? > > That is for example, if I have a script named script1.pl and it is > already running, I want the script to be able to check that it is > already running and then just exit ... > > Is this possibl

iterate over newlines

2006-07-05 Thread Ryan Moszynski
this is a snippet of a file i'm trying to process: ### iotests ( WriteEmUp [create:openwr:write:close] ReadEmUp [openrd:read:close] ) i need my perl regex to recognize "iotests", then make anything that matches ".[.]" into a string. I can't count o

Re: iterate over newlines

2006-07-05 Thread Tom Phoenix
On 7/5/06, Ryan Moszynski <[EMAIL PROTECTED]> wrote: i need my perl regex to recognize "iotests", then make anything that matches ".[.]" into a string. I can't count on the whitespace or the new lines being there or not. This sounds like a job for Parse::RecDescent, maybe? http://search.cpa

Re: iterate over newlines

2006-07-05 Thread Ryan Moszynski
i really hope thats overkill for my problem. I have my program finshed, this is the last condition i have to deal with. Also, my supervisor would prefer me not to use any nonstandard modules. On 7/5/06, Tom Phoenix <[EMAIL PROTECTED]> wrote: On 7/5/06, Ryan Moszynski <[EMAIL PROTECTED]> wrote:

Re: Providing STDIN to a PIPEd call to perl

2006-07-05 Thread Kevin Viel
Chad Perrin wrote: On Wed, Jul 05, 2006 at 11:31:55AM -0500, Kevin Viel wrote: Mr. Shawn H. Corey wrote: Kevin Viel wrote: I call a perl script from SAS using a pipe. The file on which the script acts changes. Is there a way to provide the file name to the script using STDIN on the comma

Re: iterate over newlines

2006-07-05 Thread Mr. Shawn H. Corey
Ryan Moszynski wrote: > this is a snippet of a file i'm trying to process: > ### > > iotests ( > WriteEmUp [create:openwr:write:close] > ReadEmUp [openrd:read:close] > ) > > > i need my perl regex to recognize "iotests", then make anything that > matches ".[

Re: iterate over newlines

2006-07-05 Thread Rob Dixon
Ryan Moszynski wrote: Hi Ryan > this is a snippet of a file i'm trying to process: > ### > > iotests ( > WriteEmUp [create:openwr:write:close] > ReadEmUp [openrd:read:close] > ) > > > i need my perl regex to recognize "iotests", then make anything that > ma

Next

2006-07-05 Thread Geetha Weerasooriya
Dear all, When I was reading a Perl code I found the following line. Can u please explain what it means? !defined($rt_nearest) or $dh<$dist or next; Kind regards, Geetha

CPAN Newbie Question

2006-07-05 Thread Colin Segovis
I have problems building CPAN on my Debian box. When I run the command: cpan> install Bundle::CPAN the following error message is returned at the bottom of the verbose information presented during the install/build: Running install for module Term::ReadKey Running make for J/JS/JSTOWE/TermRead