[23098] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5319 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 5 14:41:26 2003

Date: Tue, 5 Aug 2003 11:40:58 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 5 Aug 2003     Volume: 10 Number: 5319

Today's topics:
        preserving vars sent by POST method after redirecting b <tunmaster@hotmail.com>
    Re: preserving vars sent by POST method after redirecti <NOSPAM@bigpond.com>
        Reading and writing to a file (MJS)
    Re: Reading and writing to a file <noreply@gunnar.cc>
    Re: Reading and writing to a file <spamblock@junkmail.com>
    Re: Reading and writing to a file (Tad McClellan)
    Re: Regex assistance <mikeflan@earthlink.net>
    Re: Regex assistance <bigj@kamelfreund.de>
    Re: Regex assistance <mikeflan@earthlink.net>
        Renaming Files inside a GZ Zip File <mikeflan@earthlink.net>
    Re: Script "terminates" when processing large numbers o (Scott Stark)
    Re: Script "terminates" when processing large numbers o <bart.lateur@pandora.be>
    Re: Script "terminates" when processing large numbers o (Scott Stark)
        Send color text to printer <hasting@agere.com>
    Re: Send color text to printer <g4rry_sh0rt@zw4llet.com>
    Re: Send color text to printer <asu1@c-o-r-n-e-l-l.edu>
        signal problem <ggkuo@yahoo.com>
    Re: signal problem <krahnj@acm.org>
    Re: Some pointers need for a CGI script & Mysql <NOSPAM@bigpond.com>
    Re: Some pointers need for a CGI script & Mysql ctcgag@hotmail.com
    Re: Time compare using milliseconds news@roaima.freeserve.co.uk
        top 10 cpu usage for MS windows (kydongau)
    Re: top 10 cpu usage for MS windows <simon@unisolve.com.au>
    Re: top 10 cpu usage for MS windows (kydongau)
        unicode entities are for more than one byte <jidanni@jidanni.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 04 Aug 2003 21:55:42 GMT
From: "joe" <tunmaster@hotmail.com>
Subject: preserving vars sent by POST method after redirecting by .htaccess
Message-Id: <yDAXa.122923$Fc6.10178243@amsnews02.chello.com>

Dear fellow-perlers,

The situation is like this: I'd like my .htacces-file to catch all 404
errors. When this .htaccess is located in directory './bla' and a user looks
for a non-existing page './bla/plop/asd', then the .htaccess should cath the
error and redirect to another page to handle this request. So far so good.
The newly called script knows from the original URL several vars (like plop
and asd) and sends these to another script using the GET method.

This way I can send vars through the URL, without using a question mark. Or
maybe do both, like in './bla/plop/asd?cur=dollar'. But what about vars sent
using the POST method. These vars arrive at the .htaccess, but get lost
redirecting to a script that handles the request. Or not...?

In short, is there a way to collect them afterwards or preserve them while
redirecting?

Thanks in advance!

Joe
The Netherlands




------------------------------

Date: Tue, 5 Aug 2003 09:40:24 +1000
From: "Gregory Toomey" <NOSPAM@bigpond.com>
Subject: Re: preserving vars sent by POST method after redirecting by .htaccess
Message-Id: <bgmqt3$q88f6$1@ID-202028.news.uni-berlin.de>

"joe" <tunmaster@hotmail.com> wrote in message
news:yDAXa.122923$Fc6.10178243@amsnews02.chello.com...
> Dear fellow-perlers,
>
> The situation is like this: I'd like my .htacces-file to catch all 404
> errors.

It may have escaped your notice that this is a Perl newsgroup. Try
alt.apache.configuration.

gtoomey




------------------------------

Date: 2 Aug 2003 22:09:41 -0700
From: tabletdesktop@yahoo.com (MJS)
Subject: Reading and writing to a file
Message-Id: <f0171209.0308022109.8dd1c2d@posting.google.com>

Hello All,

I am new to perl and I need some help with the following problem.
 
I have two files viz. file1 and file2. I have to determine if a scalar
variable in file1 (without knowing its location) has a certain value
(say 10). If its true, then I have to add file2 to file1 at a certain
location.
 
So my question is how to do this and how to write at a certain
location in file1.
 
I would highly appreciate your help.
 
Thanks in anticipation.


------------------------------

Date: Sun, 03 Aug 2003 07:17:33 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Reading and writing to a file
Message-Id: <bgi6a7$oik9q$1@ID-184292.news.uni-berlin.de>

MJS wrote:
> I am new to perl and I need some help with the following problem.

<general description of a problem snipped>

     http://learn.perl.org/

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



------------------------------

Date: Sat, 2 Aug 2003 23:37:24 -0700
From: "David Oswald" <spamblock@junkmail.com>
Subject: Re: Reading and writing to a file
Message-Id: <vipbg7oqqbr06b@corp.supernews.com>


"MJS" <tabletdesktop@yahoo.com> wrote in message
news:f0171209.0308022109.8dd1c2d@posting.google.com...
> Hello All,
>
> I am new to perl and I need some help with the following problem.
>
<snip>
> So my question is how to do this.....
<snip>
> I would highly appreciate your help.
>
> Thanks in anticipation.

Sounds like a homework assignment.  When did they start teaching Perl in
High School?





------------------------------

Date: Sun, 3 Aug 2003 02:46:16 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Reading and writing to a file
Message-Id: <slrnbipfe8.2e1.tadmc@magna.augustmail.com>

MJS <tabletdesktop@yahoo.com> wrote:

> I have to determine if a scalar
> variable in file1 


Huh? Files are "data", not "code".

Only "code" has variables in it.

Whatever you were trying to say there, you didn't say it correctly...


> (without knowing its location) 


If it is impossible to find it, then it is impossible to operate on it.

There must be _some_ way to determine where it is.

What way is that?

Is there some text that always comes before/after it?

Is it always on line N ?

At the end of a line?

If you show us an example of your data, and what part you want
to extract, then we can probably help you with that part.

If you don't, then we can't.


> has a certain value
> (say 10).


  ==


> So my question is how to do this 


I dunno. Your "this" is known only to you at this point...


> and how to write at a certain
> location in file1.


   perldoc -q file

       How do I change one line in a file/delete a line in a
       file/insert a line in the middle of a file/append to the
       beginning of a file?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Tue, 05 Aug 2003 15:30:06 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Regex assistance
Message-Id: <3F2FCE0C.790C1155@earthlink.net>



mgarrish wrote:

> You shouldn't be trying to match in two steps when one will suffice.
> Essentially, all you're trying to do is match numbers and letters at the
> beginning of a file name, so there's no need to check first if the filename
> starts with something other than a letter or number. You can also use a
> negative look-ahead assertion to make sure there are no @s or #s in the
> string:
>
> if ($filename =~ /^([A-Za-z0-9]+)(?!.*[@#])/ {
>    push @dirlist, $1;
> }
>
> Matt

I'm not too smart at Perl, so I can't get your code to run.
It says "syntax error at" . . .  line 9 etc.
I tried escaping the @ and #, but that does not help.
Can anybody tell me what's wrong with line 9?

The ! in there mean "not", correct?


Mike


use strict;
use warnings;

my $filename;
my @dirlist;


while ( defined ($filename = <DATA>) ) {
if ($filename =~ /^([A-Za-z0-9]+)(?!.*[@#])/ {  #THIS IS LINE 9
   push @dirlist, $1;
}
}
foreach (@dirlist)
{
    print $_ . "\n";
}


__DATA__
 .
 ..
goofup.exe
listing.txt
bobby_switch_db60d
junk_none.log
junk_db4c5A
junk34_stwx_bine33A
bdfds_db4a4A
juice
master1
master2
memory_profile_db
login_profiles
aray_db76eA
test_master1
 .profile
 .cshrc




------------------------------

Date: Tue, 05 Aug 2003 17:52:59 +0200
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: Regex assistance
Message-Id: <pan.2003.08.05.15.50.58.922568@kamelfreund.de>

Mike Flannigan wrote at Tue, 05 Aug 2003 15:30:06 +0000:

>> You shouldn't be trying to match in two steps when one will suffice.
>> Essentially, all you're trying to do is match numbers and letters at the
>> beginning of a file name, so there's no need to check first if the filename
>> starts with something other than a letter or number. You can also use a
>> negative look-ahead assertion to make sure there are no @s or #s in the
>> string:
>>
>> if ($filename =~ /^([A-Za-z0-9]+)(?!.*[@#])/ {
      ^                                        ^
      opening                                  not closing

>>    push @dirlist, $1;
>> }
>>
>> Matt
> 
> I'm not too smart at Perl, so I can't get your code to run.
> It says "syntax error at" . . .  line 9 etc.
> I tried escaping the @ and #, but that does not help.
> Can anybody tell me what's wrong with line 9?

The closening ) of the if (...) is missing.
                              ^

> The ! in there mean "not", correct?

No, it's a syntactical part of the negative lookahead assertion that
always looks like
(?!...)

It means that at the position where (?!...) is inserted into the regexp,
in a matched string the specified pattern inside (in this case .*[@#])
must not follow.

In this special case the whole regexp stands for a pattern of a string
starting ^ with letters or digits [A-Za-z0-9]+
that isn't followed by some characters and an @ or a #.

Please read
perldoc perlvar
for details.


Greetings,
Janek


------------------------------

Date: Tue, 05 Aug 2003 16:20:04 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Regex assistance
Message-Id: <3F2FD9C3.64B79185@earthlink.net>



Janek Schleicher wrote:

> > I'm not too smart at Perl, so I can't get your code to run.
> > It says "syntax error at" . . .  line 9 etc.
> > I tried escaping the @ and #, but that does not help.
> > Can anybody tell me what's wrong with line 9?
>
> The closening ) of the if (...) is missing.
>                               ^

Thanks.  Even I should have caught that.  It's just that
my text editor (Med) was drawing my attention to the
# by graying out the text after it.


> > The ! in there mean "not", correct?
>
> No, it's a syntactical part of the negative lookahead assertion that
> always looks like
> (?!...)
>
> It means that at the position where (?!...) is inserted into the regexp,
> in a matched string the specified pattern inside (in this case .*[@#])
> must not follow.

Ahhh, yes.  That is so cool.  I really needed to know that
and will certainly use it.


Thanks,

Mike




------------------------------

Date: Tue, 05 Aug 2003 16:35:10 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Renaming Files inside a GZ Zip File
Message-Id: <3F2FDD4C.215EC41B@earthlink.net>


On a Win2000 box I have hundreds of files named
somethingXXX - ZZZZZ.tif.gz
that are gz zip files that contain a single file named:
otherfileYYY.tif

I want to write a perl script that will rename the single tif
file inside each gz file with the first portion of the gz file
name.  So all the "inside" files will be named
somethingXXX.tif

The gz file name will not be modified.  (I could do that
right now if I wanted to).


Anyway, I assume I need a module or two and would
appreciate any pointers about what to use.

This module does not look like the right one to me:
http://search.cpan.org/author/NWCLARK/PerlIO-gzip-0.15/gzip.pm
but I can't find anything else that would apply.



Mike Flannigan




------------------------------

Date: 3 Aug 2003 14:15:45 -0700
From: sstark@us.ibm.com (Scott Stark)
Subject: Re: Script "terminates" when processing large numbers of files
Message-Id: <ce94ec71.0308031315.3ca3361d@posting.google.com>

Tim Heaney <theaney@cablespeed.com> wrote in message news:<87ptjokhte.fsf@mrbun.watterson>...
> Perhaps the glob is hitting the expansion limit. Try reading the
> directory yourself...something like

Hi Tim, well that didn't work either. I've done some further testing
and discovered that the "termination" is happening not in the glob (or
read) but in the search_files() subroutine, always (as far as I can
gather) after it's closed one file in the @files list and before it
opens the next.

Here's an abbreviated version of the search_files subroutine that's
called for each directory:

sub search_files{
my(@files) = @_;
my(@searchStrings) = split(/\s+/,param('terms'));
foreach $f (@files){
 open(F, "$f") || on_error("Can't open file $f for reading");
 while($line=<F>){
  for($s=0;$s<scalar(@searchStrings);$s++){
    $line =~ s/($searchStrings[$s])/<font
color=\"blue\"><b>$1<\/b><\/font>/gi
    and $found{$searchStrings[$s]}=$line 
    and next if($line =~/$searchStrings[$s]/i);
  }
 }
 close(F);
}

Not much unusual going on here -- perhaps Gregory is correct, there's
a time limit? The whole thing never takes more than a couple of
minutes though. And where it stops varies every time.

thanks
Scott


------------------------------

Date: Mon, 04 Aug 2003 08:24:45 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Script "terminates" when processing large numbers of files
Message-Id: <7h5siv0p1bvkshatssiiqdcaso72vui3n3@4ax.com>

Scott Stark wrote:

>Not much unusual going on here -- perhaps Gregory is correct, there's
>a time limit?

Or a memory limit. "Terminated" is not part of any Perl error message,
AFAIK. Unless your script generates it yourself, the system must be
killing your process. Perhaps watch memory and CPU usage with ps at the
command line.

>  for($s=0;$s<scalar(@searchStrings);$s++){
>    $line =~ s/($searchStrings[$s])/<font
>color=\"blue\"><b>$1<\/b><\/font>/gi
>    and $found{$searchStrings[$s]}=$line 
>    and next if($line =~/$searchStrings[$s]/i);
>  }

Ouch. this is recompiling each of the regexes for every line line and
every pattern. Perhaps that's part of the problem. qr() on each pattern
might help a little.

BTW I'm baffled by that "next", I don't understand its purpose. I'm not
even sure it does what you want it to do. What should it do? Skip to the
next line/pattern, or repeat with the same line/pattern? And why do yoo
even use s///? You don't even seem to use the resulting string.

-- 
	Bart.


------------------------------

Date: 4 Aug 2003 08:54:26 -0700
From: sstark@us.ibm.com (Scott Stark)
Subject: Re: Script "terminates" when processing large numbers of files
Message-Id: <ce94ec71.0308040754.7f12ad61@posting.google.com>

Bart Lateur <bart.lateur@pandora.be> wrote in message news:<7h5siv0p1bvkshatssiiqdcaso72vui3n3@4ax.com>...
> >  for($s=0;$s<scalar(@searchStrings);$s++){
> >    $line =~ s/($searchStrings[$s])/<font
> >color=\"blue\"><b>$1<\/b><\/font>/gi
> >    and $found{$searchStrings[$s]}=$line 
> >    and next if($line =~/$searchStrings[$s]/i);
> >  }
> ...
> BTW I'm baffled by that "next", I don't understand its purpose. I'm not
> even sure it does what you want it to do. What should it do? Skip to the
> next line/pattern, or repeat with the same line/pattern? And why do yoo
> even use s///? You don't even seem to use the resulting string.

Actually you're right, that should be a "last" instead of a "next." If
one of the search strings is found, there's no need to search for the
others (this is part of a boolean "or").

I used the s/// because the resulting $line (with the found string
highlighted) is put into the %found hash for later use. Make sense?

Thanks for the feedback, I'll try some optimizing of the search.

Scott


------------------------------

Date: Tue, 5 Aug 2003 10:37:11 -0400
From: "Joe Hasting" <hasting@agere.com>
Subject: Send color text to printer
Message-Id: <bgofen$71r$1@alageremail2.agere.com>

I have been using the Term::ANSIColor to display color on my screen, but I
would like to direct this color to a printer.  I try to print it directly
(see example below) but it just prints the ANSI escape sequences as regular
text.  Could anyone say if there is an alternate MODULE or another technique
to print in color?

thanks
J


use Term::ANSIColor;

open(LPR, "|lpr -P  agrprt166  >/dev/null 2>&1");
  print LPR "test\n";
  print LPR "test\n";
close(LPR);

open(LPR, "|lpr -P  agrprt166  >/dev/null 2>&1");
  print LPR colored ("test\n", "red on_black");
  print LPR colored ("test\n", "green on_red");
close(LPR);






------------------------------

Date: Tue, 05 Aug 2003 15:11:25 +0000
From: Garry Short <g4rry_sh0rt@zw4llet.com>
Subject: Re: Send color text to printer
Message-Id: <bgohev$95a$1$8300dec7@news.demon.co.uk>

Joe, 

this is the same question you posted on July 31st. If you didn't get any
replies then, you're not likely to now, either. I'd suggest assuming now
that no-one here has anything relevant to say on this.

If there is an alternate module, it'll be on CPAN - go have a look.

Regards,

Garry



Joe Hasting wrote:

> I have been using the Term::ANSIColor to display color on my screen, but I
> would like to direct this color to a printer.  I try to print it directly
> (see example below) but it just prints the ANSI escape sequences as
> regular
> text.  Could anyone say if there is an alternate MODULE or another
> technique to print in color?
> 
> thanks
> J
> 
> 
> use Term::ANSIColor;
> 
> open(LPR, "|lpr -P  agrprt166  >/dev/null 2>&1");
>   print LPR "test\n";
>   print LPR "test\n";
> close(LPR);
> 
> open(LPR, "|lpr -P  agrprt166  >/dev/null 2>&1");
>   print LPR colored ("test\n", "red on_black");
>   print LPR colored ("test\n", "green on_red");
> close(LPR);



------------------------------

Date: 5 Aug 2003 15:12:38 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Send color text to printer
Message-Id: <Xns93CE720AD3D3Casu1cornelledu@132.236.56.8>

"Joe Hasting" <hasting@agere.com> wrote in
news:bgofen$71r$1@alageremail2.agere.com: 

> I have been using the Term::ANSIColor to display color on my screen,
> but I would like to direct this color to a printer.  I try to print it
> directly (see example below) but it just prints the ANSI escape
> sequences as regular text.  Could anyone say if there is an alternate
> MODULE or another technique to print in color?

You could write an ANSI terminal driver for your printer ... 

I keep seeing your posts and I am completely baffled as to why you think 
sending ANSI sequences to the printer should do anything.

(goes away and googles a bit and comes back)

Oh, so Amiga used to have ANSI printer drivers huh? Did not know that.

Without knowing your specific context, I am going to suggest generating 
HTML, and printing that.

Sinan.
-- 
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov


------------------------------

Date: Mon, 04 Aug 2003 23:52:12 GMT
From: "C&J" <ggkuo@yahoo.com>
Subject: signal problem
Message-Id: <MkCXa.1328$P43.395@newssvr22.news.prodigy.com>

This is a multi-part message in MIME format.

------=_NextPart_000_000A_01C35B82.AB6142E0
Content-Type: text/plain;
	charset="big5"
Content-Transfer-Encoding: quoted-printable

Hi,=20
I have a cod as following :

 ...
my $stop =3D 0;
sub my_sigint_catcher {
    $stop =3D 1;
};
$SIG{'INT'} =3D 'my_sigint_catcher';

while (1) {
   ....=20
   system("ANOTHER PERL SCRIPT");
    ...
   last if ($stop);
}
exit 0;


Here is my question:
1. The system(" ... ")  has its own  $SIC{'INT'} handler. Therefore, =
when I do ctrl-c during this period, the $stop never get set.
    Is that possible to catch this ctl-c during system("...")'s =
execution?
2. I thought another easy to fix the problem is to use special =
combination dedicated for this, such as (F1 key, or CTRL-O).
    How can I do this? or where can I find related tutorial?

Thanks
Chris=20

------=_NextPart_000_000A_01C35B82.AB6142E0
Content-Type: text/html;
	charset="big5"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dbig5">
<META content=3D"MSHTML 5.50.4807.2300" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi, </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I have a cod as following =
:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>my $stop =3D 0;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>sub my_sigint_catcher {</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; $stop =3D =
1;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>};</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>$SIG{'INT'} =3D =
'my_sigint_catcher';</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>while (1) {</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;.... </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; system("ANOTHER PERL=20
SCRIPT");</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; ...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; last if =
($stop);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>exit 0;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Here is my question:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>1. The system(" ... ")&nbsp;&nbsp;has =
its own=20
&nbsp;$SIC{'INT'} handler. Therefore, when I do ctrl-c during this =
period, the=20
$stop never get set.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;Is that =
possible to catch=20
this ctl-c during system("...")'s execution?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>2.&nbsp;I thought another easy to =
fix&nbsp;the=20
problem is to use special combination dedicated for this, such as (F1 =
key, or=20
CTRL-O).</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; How can I do this? =
or where can=20
I find related tutorial?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Chris</FONT>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_000A_01C35B82.AB6142E0--



------------------------------

Date: Tue, 05 Aug 2003 06:48:10 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: signal problem
Message-Id: <3F2F5360.E30D8AF5@acm.org>

[ Please post using plain text -- NOT HTML.  TIA ]


> C&J wrote:
> 
> I have a cod as following :

Ok, I'll answer just for the halibut.


> my $stop = 0;
> sub my_sigint_catcher {
>     $stop = 1;
> };
> $SIG{'INT'} = 'my_sigint_catcher';
> 
> while (1) {
>    ....
>    system("ANOTHER PERL SCRIPT");
>     ...
>    last if ($stop);
> }
> exit 0;
> 
> Here is my question:
> 1. The system(" ... ")  has its own  $SIC{'INT'} handler. Therefore,
> when I do ctrl-c during this period, the $stop never get set.
>     Is that possible to catch this ctl-c during system("...")'s
> execution?

perldoc -q "How do I make a system\(\) exit on control\-C"

Found in /usr/lib/perl5/5.6.0/pod/perlfaq8.pod
       How do I make a system() exit on control-C?

       You can't.  You need to imitate the system() call (see the
       perlipc manpage for sample code) and then have a signal
       handler for the INT signal that passes the signal on to
       the subprocess.  Or you can check for it:

           $rc = system($cmd);
           if ($rc & 127) { die "signal death" }


> 2. I thought another easy to fix the problem is to use special
> combination dedicated for this, such as (F1 key, or CTRL-O).
>     How can I do this? or where can I find related tutorial?

perldoc Curses
perldoc Term::ReadLine



John
-- 
use Perl;
program
fulfillment


------------------------------

Date: Sun, 3 Aug 2003 12:17:17 +1000
From: "Gregory Toomey" <NOSPAM@bigpond.com>
Subject: Re: Some pointers need for a CGI script & Mysql
Message-Id: <bghr8o$ostfp$1@ID-202028.news.uni-berlin.de>

"Ron Savage" <ron@savage.net.au> wrote in message
news:bghh6o$154q$1@arachne.labyrinth.net.au...
> "Gregory Toomey" <NOSPAM@bigpond.com> wrote in message
> news:bgfhte$o1b31$1@ID-202028.news.uni-berlin.de...
>
> I too wrote a web interface to MySQL. It is not just free, but
unemcumbered:
>
> http://savage.net.au/Perl-tutorials.html
>
> --
> Ron Savage
> ron@savage.net.au
> http://savage.net.au/index.html

Excellent work - well worth looking at  ;-0

gtoomey




------------------------------

Date: 04 Aug 2003 16:36:19 GMT
From: ctcgag@hotmail.com
Subject: Re: Some pointers need for a CGI script & Mysql
Message-Id: <20030804123619.363$hG@newsreader.com>

"Newbie" <dlaw001@yahoonospam.co.uk> wrote:
> Hi
>
> I'm rather new to cgi, (I've done the ice cream and other tutorials), so
> I'm not that
> raw, however I'm running into a brick wall when trying to interface with
> Mysql.
> I can do queries ectra, but I'm hitting the wall hard when trying to add
> information
> to the database (it doesn't seem to be adding the infomation into the
> database).

Are you asking MySQL to raise errors that it encounters?  Are you
either logging those errors or returning them to the browser?
Are you using transactional tables and not committing?


>  And was wondering if anyone outhere knows of any good tutorials, sample
> code,
> or books dealing with cgi/perl ? (I've done some searches and haven't
> come up with
> what  I'm looking for).
> At this stage I'm trying to work out whats going on and what are common
> pitfalls
> so at least if I hit the wall again I'll have some sort of reference
> point for me to start.

There's nothing special about Perl used in a CGI environment.  Can you
get command line scripts to work?  I like DuBois's "MySQL", but then
again it's the only book I looked at on the topic.


> ( for that reason I haven't included any code, as I may be doing other
> "things wrong")
> Thus any pointers would be greatly appreciated.

Then how much can you expect us to help you?  You can write a readable
CGI script to add a row to a table in about 8 lines, and then we could
tell you if you are doing other things wrong.


Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


------------------------------

Date: Mon, 4 Aug 2003 09:31:45 +0100
From: news@roaima.freeserve.co.uk
Subject: Re: Time compare using milliseconds
Message-Id: <h8i101-onu.ln1@moldev.cmagroup.co.uk>

PLEASE don't top-post. It's not the accepted practice in this newsgroup.

Paulers <paulers@cox.net> wrote:
> I have two timestamps that look like this:
> 08:42:38:624
> 08:42:39:437
> I need to find out the difference.

tadmc@augustmail.com (Tad McClellan) replied:
> convert everything to (integer) milliseconds, and then just subtract.

Paulers <paulers@cox.net> then asked
> Got any ideas how to account for one entry being 23:59:59:200 and
> another being 00:02:10:200?

It depends on what you want the result to be. I see two possibilities
based on your *stated* requirements, and one possibility with implicit
assumptions.

1. Tad's posted function returns the correct result (signed difference)

2. Use abs() to strip the sign of Tad's posted function (unsigned
difference)

3. You want an implicit date to be in there too, in which case you need
to extend the function so that if it calculates a negative result you
add a day's worth of milliseconds to make the result positive again.

Note that because there's no date information provided in the values
it's impossible to handle any changes between summer and winter times,
or the odd occasion when a leap second is added to the time.

Chris
-- 
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}


------------------------------

Date: 4 Aug 2003 21:22:18 -0700
From: kydongau@yahoo.com.au (kydongau)
Subject: top 10 cpu usage for MS windows
Message-Id: <738c2d89.0308042022.63462282@posting.google.com>

Do you have some perl codes to display the top 10 CPU processes for MS windows ?

Thanks,
Ky


------------------------------

Date: Tue, 05 Aug 2003 15:22:26 +1000
From: Simon Taylor <simon@unisolve.com.au>
Subject: Re: top 10 cpu usage for MS windows
Message-Id: <bgnf16$2t35$1@otis.netspace.net.au>

kydongau wrote:
> Do you have some perl codes to display the top 10 CPU processes for MS windows ?

Have a look at Win32::Process::Info

   http://search.cpan.org/author/WYANT/Win32-Process-Info-0.014/Info.pm

Regards,

Simon Taylor




------------------------------

Date: 5 Aug 2003 03:33:10 -0700
From: kydongau@yahoo.com.au (kydongau)
Subject: Re: top 10 cpu usage for MS windows
Message-Id: <738c2d89.0308050233.4094594f@posting.google.com>

Simon Taylor <simon@unisolve.com.au> wrote in message news:<bgnf16$2t35$1@otis.netspace.net.au>...

> Have a look at Win32::Process::Info
> 
>    http://search.cpan.org/author/WYANT/Win32-Process-Info-0.014/Info.pm
> 
> Regards,
> 
> Simon Taylor

I have tried this module, it does not have the CPU info.
Thanks anyway.


------------------------------

Date: Tue, 05 Aug 2003 12:10:57 +0800
From: Dan Jacobson <jidanni@jidanni.org>
Subject: unicode entities are for more than one byte
Message-Id: <87vftceoby.fsf_-_@jidanni.org>

Turds, perldoc HTML::Entities doesn't mention anything about unicode.
It's as if it is ok for it to chop a utf-8 string one byte at a time:
$ echo [chinese unicode]|
 perl -wnle 'use HTML::Entities();print HTML::Entities::encode_numeric($_);'
Am I supposedly supposed to use "use Encode; _utf8_on" somehow?


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 5319
***************************************


home help back first fref pref prev next nref lref last post