[7199] in Perl-Users-Digest
Perl-Users Digest, Issue: 824 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 7 16:07:50 1997
Date: Thu, 7 Aug 97 13:00:21 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 7 Aug 1997 Volume: 8 Number: 824
Today's topics:
[doc_site_install] Error 1 while doing "make install" f ofni.thomas@gecapital.com
Re: [doc_site_install] Error 1 while doing "make instal <rootbeer@teleport.com>
backquote command and floppy drive <growe@mic.dundee.ac.uk>
Re: Blanket textual changes <rootbeer@teleport.com>
Cannot execute this code - HELP (Todd Vinson)
Re: Cannot execute this code - HELP <rootbeer@teleport.com>
Counting Files <pdenman@ims.ltd.uk>
Re: File::Find and maxdepth? <clark@s3i.com>
FILEHANDLE actually IO::Handle? <oboyle@.cs.purdue.edu>
Re: Getting Missing File Title return when executing sc <lilly@fedex.com>
Re: HELP: 2-D Arrays? <ajohnson@gpu.srv.ualberta.ca>
Re: How to make Perl Regular expressions "Rightmost is <christopher.green@nol2316.fh.zh.ubs.com>
Re: html --> perl (Tad McClellan)
Pack / Unpack of IEEE floating point? (Irving Reid)
passing command line arguments to script in debugger <bweinra@uswest.com>
Perl and security issues (was: Re: File locking) <rootbeer@teleport.com>
problems with process-handling <ingo.ruth@stud.uni-erlangen.de>
Re: sleep not mixing well with other signal handlers <stuartc@ind.tansu.com.au>
Substitution/Read/Write (infinite loop?) wrebel@mindspring.com
Re: Substitution/Read/Write (infinite loop?) <rootbeer@teleport.com>
translating accented characters to non-accented chars a-sylvim@microsoft.com
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 07 Aug 1997 12:02:49 -0600
From: ofni.thomas@gecapital.com
Subject: [doc_site_install] Error 1 while doing "make install" for CGI.pm
Message-Id: <870969529.8041@dejanews.com>
Re'
When trying to install CGI.pm 2.36 I get the following error message
when
doing a "make install".
------------------------------------------------------
Installing /tmp/perl5/lib/perl5.003/site_perl/./CGI/Carp.pm
Installing /tmp/perl5/lib/perl5.003/site_perl/./CGI/Fast.pm
Installing /tmp/perl5/lib/perl5.003/site_perl/./CGI/Push.pm
Installing /tmp/perl5/lib/perl5.003/site_perl/./CGI/Apache.pm
Installing /tmp/perl5/lib/perl5.003/site_perl/./CGI/Switch.pm
Installing /tmp/perl5/lib/perl5.003/site_perl/./CGI.pm
Installing /tmp/perl5/lib/perl5.003/man/man3/./CGI::Fast.3
Installing /tmp/perl5/lib/perl5.003/man/man3/./CGI::Carp.3
Installing /tmp/perl5/lib/perl5.003/man/man3/./CGI::Push.3
Installing /tmp/perl5/lib/perl5.003/man/man3/./CGI.3
Installing /tmp/perl5/lib/perl5.003/man/man3/./CGI::Switch.3
Installing /tmp/perl5/lib/perl5.003/man/man3/./CGI::Apache.3
Writing
/tmp/perl5/lib/perl5.003/site_perl/sun4-solaris/auto/CGI/.packlist
/bin/sh: /tmp/perl5/lib/perl5.003/sun4-solaris/5.003/perllocal.pod:
cannot
creat
e
make: *** [doc_site_install] Error 1
------------------------------------------------------
I am using csh and my $PATH is:
/opt/GCC2721/bin:/usr/local/bin:/usr/local/lib:/usr/openwin/bin:/usr/o
penw
in/lib:/usr/openwin/share:/usr/ccs/bin:/usr/ccs/lib:/bin:/sbin:/usr/sb
in:/
usr/bin:/usr/ucb:/etc
Here's some information about the box in which I am compiling...
System Model is SPARCserver 1000
Main Memory is 128 MB
Virtual Memory is 288 MB
ROM Version is 2.13
Number of CPUs is 2
CPU Type is sparc
App Architecture is sparc
Kernel Architecture is sun4d
OS Name is SunOS
OS Version is 5.5.1
Kernel Version is SunOS Release 5.5.1 Version Generic [UNIX(R)
System V Release 4.0]
I am using gcc version 2.7.2.1 and GNU Make version 3.74 with perl,
version 5.003 with EMBED built under solaris at Sep 26 1996 11:01:01
+ suidperl security patch.
Can anyone tell me why do I get that error ... I tried searching for
it
with no luck. I get the same error when I try to install GD or
DateCalc.
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Thu, 7 Aug 1997 11:22:53 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: ofni.thomas@gecapital.com
Subject: Re: [doc_site_install] Error 1 while doing "make install" for CGI.pm
Message-Id: <Pine.GSO.3.96.970807112115.12163I-100000@kelly.teleport.com>
On Thu, 7 Aug 1997 ofni.thomas@gecapital.com wrote:
> Writing
> /tmp/perl5/lib/perl5.003/site_perl/sun4-solaris/auto/CGI/.packlist
> /bin/sh: /tmp/perl5/lib/perl5.003/sun4-solaris/5.003/perllocal.pod:
> cannot
> creat
> e
Is the directory you are installing to writable (and readable and
executable, for that matter) by the user ID under which you're doing the
install? You don't have to be root, but you do have to have the
permissions to make it possible. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 7 Aug 1997 17:20:53 +0100
From: Glenn Rowe <growe@mic.dundee.ac.uk>
Subject: backquote command and floppy drive
Message-Id: <33E9F63B.ECA0F5C2@mic.dundee.ac.uk>
I am running Perl 5 on Windows 95, and have a rather curious problem.
Whenever I use a system call with the backquote syntax in a Perl
script, as in:
$fileContents = ` type testfile.txt `;
the floppy drive gets accessed. The command works OK, though.
The file being read is not on the floppy,
and the floppy isn't in my PATH environment, so I was wondering if
there is any way of stopping this access. The main reason I want to stop
this is that I use backquote commands in Perl CGI scripts and don't
want the floppy accessed every time someone uses the CGI script.
Thanx for any help.
--
Glenn Rowe, Dept. of Math & Computer Science
University of Dundee, DUNDEE DD1 4HN U.K.
http://orange.mcs.dundee.ac.uk:8080/Test/home.html
"Technology is dominated by those who manage what they don't
understand."
------------------------------
Date: Thu, 7 Aug 1997 11:10:02 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Steven Chmielnicki <sc7b+@andrew.cmu.edu>
Subject: Re: Blanket textual changes
Message-Id: <Pine.GSO.3.96.970807110655.12163G-100000@kelly.teleport.com>
On Thu, 7 Aug 1997, Steven Chmielnicki wrote:
> Newsgroups: comp.lang.perl.misc, comp.lang.perl
If your news administrator still carries comp.lang.perl, please let him
or her know that that newsgroup has not existed since 1995. If you
have such an outdated newsgroup listing, you are probably missing out
on many other valid newsgroups as well. You'll be doing yourself and
many others a favor to use only comp.lang.perl.misc (and other valid
Perl newsgroups) instead.
> I'm currently working on batch updating of my web site.
> Any elegant ideas on how I can replace everything between <applet> and
> </applet> with the contents of another text file?
It sounds like something you could do with a one-line Perl command, not
much different than this one.
perl -pi.bak -e 's/old/new/g' *.html */*.html
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 7 Aug 1997 17:12:41 GMT
From: tvinson@uswest.com (Todd Vinson)
Subject: Cannot execute this code - HELP
Message-Id: <5scvm9$2qn@aeon.ecte.uswc.uswest.com>
Below is the code that does not execute due to errors. I have commented
before the effor occurs. I have tried to execute on various versions of
perl. Unfortantely, I get the same error.
#!/usr/local/bin/perl
require "/usr/local/bin/cgi-lib.pl";
$ENV{'PATH'} = '.:/bin:/etc:/usr/bin:/usr/etc:/usr/local/bin:/usr/ucb:/usr/bsd:/export/home/dbms/ora733/bin';
$ENV{'ORACLE_SID'} = 'CPS';
$ENV{'ORACLE_HOME'} = '/export/home/dbms/ora733';
$ORACLE_BIN = '/export/home/dbms/ora733/bin';
$requestMethod = $ENV{'REQUEST_METHOD'};
$outfile='/tmp/outfile.$$'
# after else the syntax "}" results in an error
# this is a standard if statement
if($requestMethod eq 'GET') {
$FORMINFO = $ENV{'QUERY_STRING'};
} else {
$sizeOfFormInfo = $ENV{'CONTENT_LENGTH'};
read(STDIN, $FORMINFO, $sizeOfFormInfo);
}
&PrintHeaderMessage; # Open dialog between script and browser
# Format the browser form data. The data is returned in the associative array USERIN
&FormatBrowserData;
&PrintMessage("<H2>Registration Data Received</H2>");
# TEST STUFF
# Uncomment the following 3 lines to print the form values back to the browser screen
foreach $i (sort keys %USERIN) {
&PrintHtml("$i: $USERIN{$i}\n");
}
sub PrintHeaderMessage {
print &PrintHeader; # NOTE : A blank line must follow this statement
print &HtmlTop("Reuse Hardware Registration");
print("<HR>");
print &HtmlBot;
}
sub PrintMessage {
local($text_string) = @_;
# print &PrintHeader; # NOTE : A blank line must follow this statement
print("$text_string");
print("<p>");
print &HtmlBot;
}
sub FormatBrowserData {
local(@browserData, $i, $inputVar, $inputVal);
@browserData = split(/&/, $FORMINFO);
for($i=0;$i<=$#browserData;++$i) {
($inputVar, $inputVal) = split(/=/, @browserData[$i]);
$inputVal =~ tr/A-Z/a-z/;
$inputVal =~ s/[ ]+//g;
$inputVal =~ s/[+]+//g;
# Load the form data into the USERIN associative array.
$USERIN{"$inputVar"} = $inputVal;
}
}
------------------------------
Date: Thu, 7 Aug 1997 11:43:39 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Todd Vinson <tvinson@uswest.com>
Subject: Re: Cannot execute this code - HELP
Message-Id: <Pine.GSO.3.96.970807114239.12163K-100000@kelly.teleport.com>
On 7 Aug 1997, Todd Vinson wrote:
> Below is the code that does not execute due to errors. I have commented
> before the effor occurs. I have tried to execute on various versions of
> perl. Unfortantely, I get the same error.
What error message is it, and does the entry for that message in the
perldiag(1) manpage answer all of your questions about it? :-) Hope this
helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 7 Aug 1997 12:15:10 +0100
From: "Paul Denman" <pdenman@ims.ltd.uk>
Subject: Counting Files
Message-Id: <6oacs5.i4h.ln@gate.imsport.co.uk>
Hello,
I have written a small program to count the number of files in a given
directory
which have the suffix of '.dat' :
#!/usr/local/bin/perl5
$dir_Name = 'C:\perl5\paul\dir_info\data';
opendir DIRNAME, $dir_Name or die "Directory Not Found.";
@file_List = grep /.dat/, readdir DIRNAME;
closedir DIRNAME;
print "".@file_List . " files which match our criteria in the directory " .
$dir_Name;
Does anyone know of a quicker way? (IE one command which will return the
number of files in a given directory)
Cheers,
Paul Denman
pdenman@ims.ltd.uk
------------------------------
Date: 06 Aug 1997 12:59:23 -0400
From: Clark Dorman <clark@s3i.com>
Subject: Re: File::Find and maxdepth?
Message-Id: <dyb6fw8lw.fsf@s3i.com>
Randal Schwartz <merlyn@stonehenge.com> writes:
> >>>>> "Steve" == Steve Harvey <egodeath@geocities.com> writes:
>
> Steve> I was pleased to discover the "find2perl" utility, but there's
> Steve> one hitch - I want to find the files *ONLY* in a given
> Steve> directory, without descending into any subdirectories. With
> Steve> Unix find, I can just add -maxdepth 1 to the command line, but
> Steve> find2perl doesn't support the maxdepth option as far as I can
> Steve> tell. I also thought of using a regexp and -prune to strip out
> Steve> anything more than X leading slashes, but Perl's find doesn't
> Steve> return the complete pathname -- only the filename itself.
>
> Simple enough.
>
> find2perl . -type d -prune -o ...rest goes here... | perl
>
> like for example:
>
> find2perl . -type d -prune -o -mtime +14 -ls | perl
>
> -prune is your friend. Use -prune.
I know I'm missing something, but how could a person know this? I
cannot find a man page for find2perl (though it does exist for s2p and
a2p), I cannot do a "perldoc find2perl", there is not a readme in the
x2p directory where I found find2perl, and find2perl is not even
mentioned in the FAQ.
--
Clark
------------------------------
Date: 7 Aug 1997 05:07:19 GMT
From: Todd O'Boyle <oboyle@.cs.purdue.edu>
Subject: FILEHANDLE actually IO::Handle?
Message-Id: <5sbl67$b1o@ector.cs.purdue.edu>
I am encountering an error in some code that I wrote, and the error
is quite puzzling. Using perl5.004 I am getting a "Can't locate object
method "print" via package "IO::Handle" at Authd.pm line 257." error
when passing around a filehandle. (Using perl 5.003 I get FileHandle
instead of IO::Handle)
I don't use IO::Handle anywhere in my code, so I was wondering if perl
uses it in it's underlying data structure. If so, why is it not
finding print(), I know it has it?
Here is some of my code:
----- Authd.pm
package Authd;
use Socket;
use Carp;
sub connect
{
my $self = shift;
my $host = shift || $self->{host};
my $port = shift || $self->{port};
if ($self->{nh}) { return; }
if ($port =~ /\D/) { $port = getservbyname($port, 'tcp'); }
my $iaddr = inet_aton($host) || croak "No host: $host, quitting";
my $paddr = sockaddr_in($port, $iaddr);
my $proto = getprotobyname('tcp');
unless (socket(S, PF_INET, SOCK_STREAM, $proto)) { warn $!; }
unless (connect(S,$paddr)) { warn $!; }
# print *S . "\n";
### Works here!!
#####
S->print("foobar\n");
if (defined(*S)) {return *S;}
# croak "Cannot connect to $host:$port, quitting";
$self->{failed_connects}++;
$self->connect($host,$port);
}
sub print
{
my $self = shift;
my $data = shift;
unless ($self->{nh})
{
warn "Attempt to print() to a NULL filehandle";
return 0;
}
$|=1;
# print "Authd::print: " . $self->{nh} . "\n";
### Breaks here!!!
#####
if ($data) { $self->{nh}->print($data); }
## Hmm. Gots to flush() to get anything to print to the other screen.
####
$self->{nh}->flush();
return 1;
}
sub new
{
my $params = '';
my $class = shift;
my $retrieval_type = shift;
## Have to pull some hackery to overload the constructor.
##
## I should always either get a host or a reference to $self,
## so read in host, then if we don't get a port along with it,
## then we assume that they passed us the $self.
####
my $host = shift || 'icd.cc.purdue.edu';
my $port = shift;
unless ($port)
{
$params = $host;
# undef $host;
}
unless ($retrieval_type)
{
croak "Authd constructor requires a retrieval type as a parameter,\n".
"(auth,class,pass,login); died $!\n";
}
my $self = {
'ret_type' => $retrieval_type, ## auth vs. class retrieval.
'nh' => $$params{nh}, ## Our shared network handle.
'host' => (ref $host) ? $$params{host} : $host,
'port' => $port || $$params{port},
'failed_connects' => 0
};
bless $self, $class;
$self->{nh} = $self->connect($self{host},$self{port}) if (! $self->{nh});
return $self;
}
TIA,
-Todd
--
Key: ftp://csociety.ecn.purdue.edu/pub/oboyle/oboyle.asc
Fingerprint: DA 83 ED B0 48 79 F4 5D B2 4D B0 B7 F1 A3 C1 49
Note: Remove the "." (dot) after the @ sign to reach the destination
------------------------------
Date: Thu, 07 Aug 1997 09:57:28 -0500
From: Dave Lilly <lilly@fedex.com>
Subject: Re: Getting Missing File Title return when executing script..
Message-Id: <33E9E258.794B@fedex.com>
> > Could someone give me some insight why my script is returning a Missing
> > File title when executing a script?
If it's a "File not found" HTTP error, which is what it sounds like to
me, make sure (a) the permissions are set correctly on the script
(world-executable) and (b) the path to the perl interpreter is set
correctly in your script...
good luck.
-dave
--
Dave Lilly
Federal Express
lilly@fedex.com
------------------------------
Date: Thu, 07 Aug 1997 11:27:02 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: HELP: 2-D Arrays?
Message-Id: <33E9F756.4A2F4F24@gpu.srv.ualberta.ca>
Chim Jason wrote:
>
> Can Perl do 2-D arrays?
>
> If yes, please show me a line of
> code assigning a value to a 2-D array.
>
$array[1][2]=42;
note, perl's multidimensional arrays are implemented
by means of references, so you probably want to look through
the 2nd ed Camel, chapter 4 on references, and you can
peruse the 'perldsc' and 'perllol' manpages (.pod files) for
additional information on constructing and accessing them.
---actually, some would say perl doesn't have *real*
multidimensional arrays, others say it does... many are just
happy to use them without regard to their questionable
philosophical status---and its somehow pleasing to be able
to store the answer to the universe in some possibly
non-existent dimensionality :-)
regards
andrew
------------------------------
Date: Wed, 06 Aug 1997 23:18:23 +0200
From: Christopher Green <christopher.green@nol2316.fh.zh.ubs.com>
Subject: Re: How to make Perl Regular expressions "Rightmost is greediest"?
Message-Id: <33E8EA1F.69AE8BCA@nol2316.fh.zh.ubs.com>
Patrice Boissonneault wrote:
> [...]
>
> $_ = "a xxx c xxxxxxxx c xxx d";
> /a.*c.*d/;
>
> [...] Patrice Boissonneault
> -----------------------------
> Patrice.Boissonneault@nrc.ca
In your example you'd have to use
/a.*?c.*d/
which simply does non-greedy matching.
does that do things for you?
- chris
------------------------------
Date: Tue, 5 Aug 1997 16:37:02 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: html --> perl
Message-Id: <ud68s5.vg4.ln@localhost>
Tom Halligan (tomh@u1.abs.net) wrote:
: Hi does anyone know a sharwware or freeware program for converting html
: to perl
Eh?
HTML is a markup language.
Perl is a programming language.
They are different things for different purposes.
Your request makes no sense.
What do you mean?
Nevertheless:
Here is one way to convert your HTML page into some perl code:
----------------------
print<<ENDHTML;
** replace this line with your web page **
ENDHTML
----------------------
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: 7 Aug 97 15:41:02 GMT
From: irving@sys.toronto.edu (Irving Reid)
Subject: Pack / Unpack of IEEE floating point?
Message-Id: <1997Aug7.114102.1608@jarvis.cs.toronto.edu>
Keywords: pack float IEEE
We have an application (actually the 'COPE' CORBA IIOP implementation,
http://www.lunatech.com/cope/) that needs to pack and unpack floats and
doubles in IEEE format.
I prowled through all the modules I could find, but there doesn't seem
to be any existing IEEE format mangling tools.
If nobody else knows of them, I'll go bug the Perl5-porters with a feature
request. This seems like a prime candidate for new format designators for
the pack() functions..
- irving -
------------------------------
Date: Thu, 07 Aug 1997 11:55:57 -0600
From: Bret D Weinraub <bweinra@uswest.com>
Subject: passing command line arguments to script in debugger
Message-Id: <33EA0C2D.8D9@uswest.com>
How do I debug a perl script AND pass that script command line
arguments?
perl 5.004, HPUX 10.20.
Thanks,
bret
--
Bret D Weinraub
mailto:bweinra@uswest.com
------------------------------
Date: Thu, 7 Aug 1997 11:34:51 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Bart Lateur <bart.mediamind@tornado.be>
Subject: Perl and security issues (was: Re: File locking)
Message-Id: <Pine.GSO.3.96.970807112310.12163J-100000@kelly.teleport.com>
[followups set to c.l.p.misc]
On Thu, 7 Aug 1997, Bart Lateur wrote:
> Does this mean that 5.004 doesn't have any security hole, or just that
> nobody has found it yet?
>
> My bet is on the latter. Nothing is ever 100% secure.
Why do you say that? My computer is 100% secure. It can't possibly have a
security problem: I keep it turned off all day and all night! :-)
But you're right, of course. You can't even trust C's "Hello, World"
program, since the compiler, libraries, or kernel may be buggy. (!)
As for Perl security issues, though, a number of big ones have been fixed
recently, but "there's always one more bug". Still, a well-written Perl
script can typically be more secure than the corresponding C program or a
program in other languages, because of (among other things) the ability to
use "taint checking" which is, AFAIK, unique to Perl. (Details in the
perlsec(1) manpage).
Of course, the perl binary is compiled from C, so if the compiler,
libraries, or kernel actually _is_ buggy....
Excuse me. I've got to turn off my computer now.
:-)
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 06 Aug 1997 21:04:03 +0200
From: Ingo Ruth <ingo.ruth@stud.uni-erlangen.de>
Subject: problems with process-handling
Message-Id: <33E8CAA3.FB2@stud.uni-erlangen.de>
Hallo to everybody!
I have got a problem with handling of many processes which I use to
connect a database!
There is a database with 300.000 rows, each row has among others one
column with a title like that:
discription 1 /discription part two /discript next /first of this
then the next row would be:
discription 1 /discription part two /discript next /second of this
and so on, every title is made of up to 11 parts!
I planned to normalize this database and put every part in one table if
it is not inserted. Therefore I wrote a script that open a
database-connection, read every titel and splitted it into the parts.
For each part I opened another database-connect, ask the to the actual
part referenced table about the ID of the parts word and close that
process. If /no rows selected/ I again open a database-connect to insert
the part and the gaven ID, else that database-connect only insert the ID
to that part in the new main table. At least I close this process.
Main parts of the code:
open (SQL, "sqlplus user/passw <<!
select titel from table;
quit;
!|") || die ...;
while ($row = <SQL>) {
...
some regular expresions to make a higher data-quality
...
@titel = ();
@titel = split(/ \//, $row);
...
some data-konsistence-tests
...
foreach $part (@titel) {
$tabid[$tabz] = &dbinsert($part, "Table"."$tabz", titel"."$tabz");
$tabz++;
}
open (DBINSZR, "sqlplus user/passw <<!
insert into mainTable values( ... , \'$tabid[1]\', ...,
\'$tabid[1]\');
commit;
quit;
!|") || die ...
@dbinszr = <DBINSZR>;
close (DBINSZR);
...
evaluating @dbinszr
...
close(SQL);
The sub dbinsert also makes a database-connect in the same way, first
like:
select id from table_N where titelPartColumn = $part;
If there were no rows selected it makes a connect to insert the $part.
The Sub returns the id of the $part.
As (I hope) you can see there may be up to 6 database-connects (some
more in the part with the konsistence-tests) for each part of the title,
and that makes the program take a very_very_very long time to work, and
that is my first problem!
My second problem is, that now (after it works 5 days and inserted over
50000 rows of the 300000) it stopped , I mean it don't insert more rows
in the mainTable, but it still runs - and there were more and more
errors like: "Bus Error - core dumped"! That message came for many times
before, but the program worked on, so I decided to do nothing ...till
now!
So these are my questions:
Is it possible to open a process-handling (database-connect) to which I
can send a statement, get the answer, and later on use the same
process-handling again to insert and so on? If this is possible, the
program would be much faster!
Maybe the error-message has got s.th. to do with the many processes I
opened (and closed)? Or what could it be? Could they be the reason for
the program stopped working, but still running?
Can I save the program without killing it?
Hope ther is somebody who can help me!
Ingo.
------------------------------
Date: 06 Aug 1997 11:47:06 +1000
From: Stuart Cooper <stuartc@ind.tansu.com.au>
Subject: Re: sleep not mixing well with other signal handlers
Message-Id: <yeo4t94hylh.fsf@kudu.ind.tansu.com.au>
Shimpei Yamashita <shimpei@socrates.caltech.edu> writes:
> As I understand from perlfunc man pages, sleep should not be used
> along with signal handlers for SIGALRM, but there shouldn't be any
> problems installing signal handlers for other signals, right?
> #! /usr/bin/perl
>
> $SIG{CHLD}=\&hee;
>
> if ( ($child=fork) < 0 ) {
> die "Error: could not fork!\n";
> }
> if ( ($child > 0) ) {
> sleep 2;
> kill "STOP", $child;
> print "suspension done\n";
> sleep 10;
^--------- not sleeping for 10. What's going on?? <answer below>
> print "sleep done\n";
> } else {
> for($i=0;$i<99999999;$i++) {
> print;
> }
> }
>
> sub hee {
> if (kill 0, $child) {
> print "$child suspended\n";
> } else {
> print "$child dead\n";
> wait;
> }
> }
>
> Eventually I'd like to write code in which the parent will
> periodically suspend the child, do some stuff, and turn the child back
> on. Right now the code should just let the child run amok for two
> seconds before the child gets suspended, after which the parent
> sleeps for 10 seconds and exits (upon which the children should
> die also).
>
> The problem is that the second "sleep 10" statement is not being
> honored: after two seconds, the program prints
>
> suspension done
> <some number> suspended
> sleep done
>
> all at once and exits. If I take out the kill statement, it works just
> as expected. What gives? I'm pretty new at this signals programming
> business, so it is possible that I'm doing something entirely wrong.
> I'd appreciate some help.
>
> This is on perl 5.004_01. I've run the script on Linux 2.0.30 (Intel
> and PowerPC) and Solaris 2.5.1 (SPARC) with identical results, so
> I don't think it's a quirk in a particular OS.
No, it's the tricky-and-not-obvious behaviour of sleep.
What gives is that your parent gets the SIGCHLD signal as it's executing
the sleep 10 statement. It goes into the signal handler hee, and then
returns to the sleep; which terminates according to the definition of sleep.
You thus get only 0.01 seconds or so of sleep.
Information from "Advanced Programming in the Unix Environment" by
W. Richard Stevens; [Addison Wesley, 1992] p317:
================================================================
sleep:
#include <unistd.h>
unsigned int sleep(unsigned int seconds)
Returns: 0 or number of unslept seconds.
This function causes the calling process to be suspended until either:
1) the amount of wall clock time specified by seconds has expired
2) a signal is caught by the process and the signal handler returns.
================================================================
sleep() is behaving perfectly correctly and exits according to (2).
You may find this on your sleep(3) man page but I've seen misleading
ones that suggest you only have to worry about SIGALRM.
Your approach of suspending the child through SIGSTOP and presumably then
waking it up with SIGCONT is flawed I think. I'm not sure what
you need to program here; but in most cases people want
communication between parent and child. You want the parent to do something
while the child waits; then the child to do something while the parent
waits; then both processes to do stuff independently; then the child to
do something while the parent waits and so on.
This can be done with pairs of functions:
wait_parent - child waits for parent to finish; by calling POSIX::pause();
tell_parent - child tells parent he's finished; by kill SIGUSR1 PARENT_PID
wait_child - parent waits for child to finish; by calling POSIX::pause();
tell_child - parent tells child he's finsiehd; by kill SIGUSR1 CHILD_PID
Here's a scenario for the child to do something; then the parent:
--- fork ---
PARENT CHILD
wait_child() do
some
stuff
tell_parent()
do wait_parent()
some
stuff
tell_child()
concurrent concurrent
The parent calls wait_child() to block until the child is finished. The
child tells the parent he's done with tell_parent(). The child then
blocks with wait_parent(). The parent does stuff and then uses
tell_child().
Thanks again to Stevens cited above; where a C language version of this
can be found on pp307-308.
Hope this helps, and good luck!
Stuart Cooper
stuartc@ind.tansu.com.au
------------------------------
Date: Thu, 07 Aug 1997 11:53:23 -0600
From: wrebel@mindspring.com
Subject: Substitution/Read/Write (infinite loop?)
Message-Id: <870972238.11173@dejanews.com>
Trust me when I tell you I have looked at all of
the messages and books to solve this dilemna
and have found no resolution. Close to the brink
of madness, I am now posting a message. I am a
newbie but have tried resolving this on my own.
Through a CGI form (post method), I am opening
an existing html file, reading it and writing to
another file, while doing a substitution. I close
both files then open the file with the
substitutions and write back into the original
file.
It seems to work fine and then overnight it
spawns itself in what seems to be an infinite
loop. I don't see the infinite loop.
When I tried to use this:
while ($line = <OLD>)
in place of this:
while (<OLD>)
I get "document contains no data" messages
errors I couldn't resolve.
Detail and insight into this problem is greatly
appreciated.
NOTE: in the shell the program seems to work
fine and doesn't spawn itself overnight. It is in
the cgi form that creates the problem.
Diane
SNIPPET BELOW:
sub AddLink {
#$old = "calendar.html";
#$new = "calendar2.html";
$link1 = '<A HREF="http://';
$link4 = 'www.somewhere.com/';
$link2 = '.html">';
$link3 = 'event</a>';
open(OLD, "<calendar.html") || die ("can't
open calendar file: $!");
open(NEW, ">calendar2.html") || die ("can't
open new: $!");
while (<OLD>) {
s/>$sdate/>
$sdate$link1$link4$sdate$link2$link3/g;
(print NEW $_) || die ("can't write to new:
$!");
}
close(OLD) || die ("can't close old: $!");
close(NEW) || die ("can't close new: $!");
#return;
}
sub AddLink2 {
open(NEW, "<calendar2.html") || die ("can't
open new to read: $!");
open(OLD, ">calendar.html") || die ("can't open
old to write: $!");
while (<NEW>) {
(print OLD $_) || die ("can't write to new:
$!");
}
close(OLD) || die ("can't close old: $!");
close(NEW) || die ("can't close new: $!");
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Thu, 7 Aug 1997 11:20:23 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: wrebel@mindspring.com
Subject: Re: Substitution/Read/Write (infinite loop?)
Message-Id: <Pine.GSO.3.96.970807111036.12163H-100000@kelly.teleport.com>
On Thu, 7 Aug 1997 wrebel@mindspring.com wrote:
> Trust me when I tell you I have looked at all of the messages and books
> to solve this dilemna and have found no resolution. Close to the brink
> of madness, I am now posting a message. I am a newbie but have tried
> resolving this on my own.
I appreciate your hard work, and I congratulate you upon avoiding
incipient insanity.
> When I tried to use this:
> while ($line = <OLD>)
>
> in place of this:
> while (<OLD>)
>
> I get "document contains no data" messages
> errors I couldn't resolve.
That may be because the two are not the same. :-) The second one is a
short way to write this.
while (defined($_=<OLD>))
Newer versions of Perl can warn you if you mistakenly omit the defined()
check, even when assigning to a different variable than $_ . So, did you
mean to use $line or $_ in the first one, and is Perl complaining about
not using defined()?
In the code you posted, I also saw the possibility that your code could
die(), which, in a CGI script, could cause you to see a "document contains
no data" message. You may want to trap the die, or an error message that
it produces, so that you can see what the error message says.
I couldn't see anything that seemed likely to produce an infinite loop.
What makes you think that might be happening?
Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 07 Aug 1997 12:36:47 -0600
From: a-sylvim@microsoft.com
Subject: translating accented characters to non-accented chars
Message-Id: <870974637.14774@dejanews.com>
Hello all,
I've searched the archives on this, but haven't been able to find a lot.
My problem is I have a file that has ascii characters above 128 (accented
characters, etc). I need to translate these to non-accented chars, for
example, e with an accent should become just plain e. I was thinking of
creating a function with a long list of one-to-one translations with s///
, but it seems like there must be an easier way.
Thanks!
Sylvia
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 824
*************************************