[16373] in Perl-Users-Digest
Perl-Users Digest, Issue: 3785 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 24 14:05:57 2000
Date: Mon, 24 Jul 2000 11:05:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <964461916-v9-i3785@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 24 Jul 2000 Volume: 9 Number: 3785
Today's topics:
Re: Accessing DLLs from Perl? <thoren@southern-division.com>
Re: Add data to script with perl and php? (Logan Shaw)
Calling C-Functions in Perl using the XS-Interface <r7768c@email.sps.mot.com>
Re: CGI.pm Cookies and images together <lr@hpl.hp.com>
Re: CGI.pm Cookies and images together <flavell@mail.cern.ch>
Re: CGI.pm List (Robert Goff)
close(STDOUT) trick doesn't seem to work when HTTP/1.1 <sloyola@bestwebbuys.com>
compiling perl on NT into an exec. victor@daemos.com
DBI, XML issue <m.kaiser@sz-sb.de>
Re: DBI, XML issue <jeff@vpservices.com>
File & Directory Reading <koen_lesenne@ins.be>
Re: File & Directory Reading (Logan Shaw)
Re: File & Directory Reading <koen_lesenne@ins.be>
Re: flock nonsense ? <franl-removethis@world.omitthis.std.com>
Re: golf apocalypse post-mortem? <george.kuetemeyer@mail.tju.edu>
Hash within an array problem <robm@web-impact.com>
hashes and lists <donv@web-impact.com>
Re: hashes and lists (Logan Shaw)
Re: Hostname in Net::SMTP <tony_curtis32@yahoo.com>
Re: How to detect when an output file is removed timhood@bigfoot.com
Re: How to detect when an output file is removed (Logan Shaw)
Looking for an online store script. <rcmodeler@mmcable.com>
Mail::Mailer for win9n <yhu@mail.nih.gov>
Re: Mail::Mailer for win9n <camerond@mail.uca.edu>
Re: matching contents of array <bart.lateur@skynet.be>
Re: Matts Script Archive - A critique <mjcarman@home.com>
Re: Need questions for Perl quiz (Bernard El-Hagin)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 24 Jul 2000 17:10:24 +0200
From: "Thoren Johne" <thoren@southern-division.com>
Subject: Re: Accessing DLLs from Perl?
Message-Id: <8lhmgi$5lh$18$1@news.t-online.com>
Toni Mueller <toni@oeko.net> wrote in message
news:8lh9af$c4g$1@oak.oeko.net...
> I would like to use home grown DLLs, eg written in VC++ or VB,
> together with ActiveState Perl on NT4. It would be nice if anyone
> could make a comment if this is possible, or what has to be done
> to make it happen.
yes, use the Win32::API module and read it's documentation
> If someone could probably also explain what
> the difference between OLE and DLL is, I'm very interested in
> hearing this.
hmmm... perhaps you should read ActivePerl-Winfaq12.html - Using OLE with
Perl
gruß
thoren
8#X
--
----------------------------------------------------------------------
Thoren Johne - 8#X - thoren@southern-division.com
Southern Division Classic Bikes - www.southern-division.com
------------------------------
Date: 24 Jul 2000 11:41:17 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Add data to script with perl and php?
Message-Id: <8lhrjd$dtn$1@provolone.cs.utexas.edu>
In article <8lfjk0$bl3$1@nnrp1.deja.com>, vivekvp <vivekvp@spliced.com> wrote:
>I would lijke to be able to add the info via the web and have it save
>to my script so it uses the new addresses added.
Can't you have your PHP script open a regular old file and read its
contents? If so, then just add IP addresses and ports to the file, and
you're done. (And create a PHP script to modify the file if you want.)
And if you don't want to do that, keep a text file listing
ports and addresses and stuff, and then rebuild that into a
PHP file that can be included in your script at run-time.
So, if your text file looks like this:
127.0.0.1 5678
10.0.0.1 1234
Your perl script to rebuild it might look like this:
#! /usr/local/bin/perl
print '$gnutella_server_list = array(', "\n";
while (<>)
{
($address, $port) = split;
print '"', $address, '" => "', $port, '"', "\n";
}
print ");\n";
Hope that helps.
- Logan
------------------------------
Date: Mon, 24 Jul 2000 18:36:53 +0200
From: Thomas Benedek <r7768c@email.sps.mot.com>
Subject: Calling C-Functions in Perl using the XS-Interface
Message-Id: <397C70A5.6C1098CB@email.sps.mot.com>
Hi!
I have a problem with the XS-Compiler.
The only possibility I found to use C-Functions in Perl is to
build up an own library with the ar command and add it
to the Makefile.PL!
I tried to add single object-files with the 'OBJECT' statement to the
Makefile.PL, but then no C-File was created by the XS-compiler!
Could someone explain me what goes on there and how I can use only
some special object-files with XS?
Thanks
Thomas
---------------------
Thomas Benedek
---------------------
------------------------------
Date: Mon, 24 Jul 2000 07:50:17 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: CGI.pm Cookies and images together
Message-Id: <MPG.13e5f787bf03c67c98abe0@nntp.hpl.hp.com>
In article <slrn8nnpt5.8gj.efflandt@efflandt.xnet.com>,
efflandt@xnet.com says...
...
> #!/usr/bin/perl -w
use strict;
> use CGI qw/:standard/;
> my $cookie = cookie( -name=>'Favorite',
> -value=>'Chocolate Chip',
> -expires=>'+30s',
> -path=>'/');
> $image = '../img/apache_pb.gif';
That path is relative to the current directory, which hasn't been
specified.
> $len = -s $image;
> print header(-type=>'image/gif',-Content_length=>$len,
> -expires=>'now',-cookie=>$cookie);
> open(IMG,"$image") || die "Can't open $image: $!";
^ ^
Misleading, unnecessary quotes.
> print <IMG>;
That reads the whole file into memory before printing it.
print while read IMG, $_, 8192;
> close IMG;
>
> You might need a binmode or 2 in there if running on a Win server.
You need binmode(IMG) and binmode(STDOUT), though they do nothing in
some server environments.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 24 Jul 2000 17:32:31 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: CGI.pm Cookies and images together
Message-Id: <Pine.GHP.4.21.0007241725580.2955-100000@hpplus03.cern.ch>
On Mon, 24 Jul 2000, David Efflandt wrote:
> You might need a binmode or 2 in there if running on a Win server.
You're dealing with binary data, so binmode() is the right thing. It
does no harm on unix, and it's needed on more OSes than merely
MS-Windows.
When it's the right thing to do: just do it. Somewhere down the line,
someone will thank you for having done it, in the interests of
portability.
cheers
------------------------------
Date: 24 Jul 2000 15:03:13 GMT
From: robert@goff.com (Robert Goff)
Subject: Re: CGI.pm List
Message-Id: <8lhlrh$ssk$0@207.66.2.182>
>difficulty with using the module then I guess you might want to ask here,
>in comp.lang.perl.modules,
Thanks, I actually hadn't found the clp.modules group yet.
--
Clones are people, two.
===============================================
Robert Goff beast@avalon.albuquerque.nm.us
Technical Writer/Editor, Webmaster 505-564-8959
------------------------------
Date: Mon, 24 Jul 2000 18:02:04 GMT
From: Steve Loyola <sloyola@bestwebbuys.com>
Subject: close(STDOUT) trick doesn't seem to work when HTTP/1.1
Message-Id: <397C84C9.B2564646@bestwebbuys.com>
Has anyone seen this strange behavior before?
When I want my CGI script to signal the web server (Apache) that it can close
the connection, but I still want the script to do some other stuff (like writing
to an application specific log), I have gotten into the habit of simply using
"close(STDOUT)" as soon as the dynamically generated page was complete.
Well, I've been testing a new script and its behavior is different between
Netscape 4.73 and IE 5.5. It appears that Netscape 4.73 still makes GET
requests as HTTP/1.0 while IE 5.5 makes them as HTTP/1.1.
The Netscape requests process as expected, but the IE requests appear to die
(with no mention in the error_log) as soon as "close(STDOUT)" is called. I know
I can simply leave STDOUT open for the duration of the script, but I was hoping
that I could prevent the user's browser logo from continuing to spin while my
script was logging its actions (which could theoretically get blocked since I
use file locking on the log file.
Any ideas?
Is the "close(STDOUT)" trick obsolete?
Is there a new trick to do this?
Thanks,
--
Steve Loyola <sloyola@bestwebbuys.com>
Best Web Buys <http://www.bestwebbuys.com/>
Best Book Buys <http://www.bestbookbuys.com/>
One of Consumer Reports "Web sites that really deliver", March 2000
------------------------------
Date: Mon, 24 Jul 2000 17:53:24 GMT
From: victor@daemos.com
Subject: compiling perl on NT into an exec.
Message-Id: <8lhvqh$us$1@nnrp1.deja.com>
Hi,
I know this is possible, but I can't seem to find any reference to
this on the internet. I want to compile a perl script that i currently
have workin on perl for NT into an executable so I don't need the
interpreter. Does anybody know where I get the files to do this?
thanks..
-victor
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 24 Jul 2000 17:36:51 +0200
From: "Markus Kaiser" <m.kaiser@sz-sb.de>
Subject: DBI, XML issue
Message-Id: <8lhnqm$a8gr8$1@hades.rz.uni-sb.de>
Hi there,
when I use the Perl modules DBI and XML:Parser together
the following error message occurs:
"read method call failed at .../lib/perl5/XML/Parser.pm
line 184."
The issue can be reproduced using this short script
(comment out the 'use DBI;' line and it will work)
test2.pl
--------
#!/usr/local/bin/perl -w
use strict;
use DBI;
use XML::Parser;
my $parser = new XML::Parser( );
for( @ARGV )
{
my $doc = $parser->parsefile( $_ );
}
exit;
test.xml
--------
<?xml version="1.0"?>
<html>
<p>Put pudding in my shoes</p>
</html>
Any ideas? Thanks in advance, Markus
--
Markus Kaiser (mkaiser@handshake.de)
Malstatter Str. 4, D-66117 Saarbruecken, Germany
Phone +49 681 926300, Fax +49 681 9263015
------------------------------
Date: Mon, 24 Jul 2000 09:31:00 -0700
From: Jeff Zucker <jeff@vpservices.com>
To: Markus Kaiser <m.kaiser@sz-sb.de>
Subject: Re: DBI, XML issue
Message-Id: <397C6F44.A0FF6266@vpservices.com>
Markus Kaiser wrote:
>
> when I use the Perl modules DBI and XML:Parser together
> the following error message occurs:
> "read method call failed at .../lib/perl5/XML/Parser.pm
> line 184."
>
> [snip of test script]
I can't reproduce your error. I just copied your script and xml file
onto my computer and ran them and they ran fine. That's on win98,
ActivePerl 522, DBI 1.13, XML::Parser 2.27.
BTW, are you aware that DBD::RAM works with XML files and can import
them to or export them from a DBI/SQL accessible database automatically?
--
Jeff
------------------------------
Date: Mon, 24 Jul 2000 19:01:04 +0200
From: "Koen Lesenne" <koen_lesenne@ins.be>
Subject: File & Directory Reading
Message-Id: <397c78f8$0$20579@bru5-newsr1.be.uu.net>
Dear All,
I'm currently using the following statement to read an entire directory. The
. and .. are filtered out by default but now I would also like to exclude
the "*.gif" and "*.jpg" files. Can someone help me with this please ?
opendir(FH,"/Website/CONFIGURATION/") or die "Cannot open dir: $!";
@filelist = grep(!/^\.{1,2}$/, readdir(FH));
closedir(FH);
Kind regards,
Koen Lesenne
------------------------------
Date: 24 Jul 2000 12:17:21 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: File & Directory Reading
Message-Id: <8lhtn1$e38$1@provolone.cs.utexas.edu>
In article <397c78f8$0$20579@bru5-newsr1.be.uu.net>,
Koen Lesenne <koen_lesenne@ins.be> wrote:
>I'm currently using the following statement to read an entire directory. The
>. and .. are filtered out by default but now I would also like to exclude
>the "*.gif" and "*.jpg" files. Can someone help me with this please ?
>
> opendir(FH,"/Website/CONFIGURATION/") or die "Cannot open dir: $!";
> @filelist = grep(!/^\.{1,2}$/, readdir(FH));
> closedir(FH);
To make the code clear, I'd do this:
opendir (DIR, "/my/dir") or die "Can't open dir because $!\n";
while (readdir DIR)
{
next if /^\.{1,2}$/; # ignore "." and ".."
next if /[.](gif|jpe?g)$/i; # ignore pictures
push (@filelist, $_);
}
closedir DIR;
But you can do it more concisely if you want:
opendir(FH,"/Website/CONFIGURATION/") or die "Cannot open dir: $!";
@filelist = grep(!/(^\.{1,2}$)|(\.(gif|jpe?g)$)/i, readdir(FH));
closedir(FH);
Hope that helps.
- Logan
------------------------------
Date: Mon, 24 Jul 2000 19:07:11 +0200
From: "Koen Lesenne" <koen_lesenne@ins.be>
Subject: Re: File & Directory Reading
Message-Id: <397c7a67$0$5682@bru5-newsr1.be.uu.net>
Hi,
Thanks !
That's what I was lookin' for !
Kind regards,
Koen Lesenne
"Logan Shaw" <logan@cs.utexas.edu> wrote in message
news:8lhtn1$e38$1@provolone.cs.utexas.edu...
> In article <397c78f8$0$20579@bru5-newsr1.be.uu.net>,
> Koen Lesenne <koen_lesenne@ins.be> wrote:
> >I'm currently using the following statement to read an entire directory.
The
> >. and .. are filtered out by default but now I would also like to exclude
> >the "*.gif" and "*.jpg" files. Can someone help me with this please ?
> >
> > opendir(FH,"/Website/CONFIGURATION/") or die "Cannot open dir: $!";
> > @filelist = grep(!/^\.{1,2}$/, readdir(FH));
> > closedir(FH);
>
> To make the code clear, I'd do this:
>
> opendir (DIR, "/my/dir") or die "Can't open dir because $!\n";
> while (readdir DIR)
> {
> next if /^\.{1,2}$/; # ignore "." and ".."
> next if /[.](gif|jpe?g)$/i; # ignore pictures
> push (@filelist, $_);
> }
> closedir DIR;
>
> But you can do it more concisely if you want:
>
> opendir(FH,"/Website/CONFIGURATION/") or die "Cannot open dir: $!";
> @filelist = grep(!/(^\.{1,2}$)|(\.(gif|jpe?g)$)/i, readdir(FH));
> closedir(FH);
>
> Hope that helps.
>
> - Logan
------------------------------
Date: Mon, 24 Jul 2000 16:22:37 GMT
From: Francis Litterio <franl-removethis@world.omitthis.std.com>
Subject: Re: flock nonsense ?
Message-Id: <m3u2dfbir6.fsf@franl.andover.net>
John Armsby <jaws@mindspring.com> writes:
> I don't see it. Instance 1 writes the file. Instance 2 waits until instance 1
> is finished
But how does instance 2 wait? What system call does instance 2 make to
cause it to cease executing until instance 1 renames the file back to its
original name? You will be forced to busy-wait, which is undesireable.
Yes, a file rename operation is atomic on a locally mounted UNIX
filesystem, so that implements the exclusionary aspect of flock(), but it
doesn't implement the blocking aspect of flock().
--
Francis Litterio
franl-removethis@world.std.omit-this.com
PGP public keys available on keyservers.
------------------------------
Date: Mon, 24 Jul 2000 12:52:39 -0400
From: "George M. Kuetemeyer" <george.kuetemeyer@mail.tju.edu>
Subject: Re: golf apocalypse post-mortem?
Message-Id: <397C7457.4E48779A@mail.tju.edu>
John Callender wrote:
> Come to think of it, might it be possible to bring it back as a
> real-time distributed competition over the net?
I also was disappointed, though Damian Conway's replacement talk was
execellent.
A tournament over the net would be a lot of fun. Here's a few ideas:
* Perhaps a 4 day event, like the Masters, or British Open.
* 18 questions posted to www.perl.com for each of 4 days.
* Questions test both "long" and "short" game strengths. Not quite sure
how that translates to Perl, but it's a key feature of golf
(brute force vs. touch/accuracy).
* Scoring based solely on # of characters required.
* All answers must be correct. A single incorrect answer results in
disqualification.
* Answers sent via e-mail. Must be received within 24 hours of question
postings.
* Running commentary as e-mail solutions arrive & are judged.
* Results (scoring and winning solutions) posted the next day (depending
on how many people/teams enter & number of judges).
* Tied players/teams at the end of regulation result in a sudden death
playoff.
GK
------------------------------
Date: Mon, 24 Jul 2000 12:31:03 -0400
From: Robert Mark <robm@web-impact.com>
Subject: Hash within an array problem
Message-Id: <397C6F47.F259438@web-impact.com>
Hello,
I am having a problem assigning information to an hash array withs
belongs to a normal array.
Example.
#!/usr/bin/perl
local @my_array=();
assign();
display();
# assign data to my hashes
sub assign
{
for ($i=0; $i < 5; $i++)
{
$my_array[$i]={};
%my_hash=$my_array[$i];
$my_hash{index}="entry_$i";
}
print "@my_array\n";
}
# retrieve the data from the hashes and printout the result.
sub display
{
for ($i=0; $i < 5; $i++)
{
$my_hash=$my_array[$i];
print "Value of $i is $my_hash{index}\n";
}
}
The output will be:
Value of 0 is entry_4
Value of 1 is entry_4
Value of 2 is entry_4
Value of 3 is entry_4
Value of 4 is entry_4
Why is that? Why isn't the output:
Value of 0 is entry_0
Value of 1 is entry_1
Value of 2 is entry_2
Value of 3 is entry_3
Value of 4 is entry_4
The following statement...
print "@my_array\n";
in the first subroutine, perl prints out five defferent references as
such:
HASH(0x7a938) HASH(0x7ab84) HASH(0x7ab90) HASH(0x7aba8) HASH(0x7abc0)
Anyone understand what is happening.
Thanks
Don
------------------------------
Date: Mon, 24 Jul 2000 12:53:22 -0400
From: Don Vaillancourt <donv@web-impact.com>
Subject: hashes and lists
Message-Id: <397C7482.9F208692@web-impact.com>
What is the difference between the following two notations? It doesn't
make sense. From a programming standpoint using any other language,
both notations should mean the exact same thing.
local @my_array;
$my_array->[0]={};
# Notation 1
%my_hash=$my_array->[0];
$my_hash{name}="Don";
# Notation 2
$my_array->[0]{name}="Don";
------------------------------
Date: 24 Jul 2000 12:12:04 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: hashes and lists
Message-Id: <8lhtd4$e2j$1@provolone.cs.utexas.edu>
In article <397C7482.9F208692@web-impact.com>,
Don Vaillancourt <donv@web-impact.com> wrote:
>What is the difference between the following two notations? It doesn't
>make sense. From a programming standpoint using any other language,
>both notations should mean the exact same thing.
Actually, I'm going to explain to you what your code does and sidestep
the issue of notation, because I think that might help clear things up.
>local @my_array;
This tells perl to create local version of the array called "my_array".
>$my_array->[0]={};
This tells perl to use a completely unrelated variable[1] -- a SCALAR
called "my_array" -- as a reference to an array.
It then locates the first value (the one with index 0) of that array,
and assigns to it a scalar value. That scalar value is a reference to
an anonymous hash that you just created on the righthand side of your
assignment.
So, at this point, you have the following things:
* An entry in the symbol table that makes all variables named
"my_array" local to the enclosing block (due to "local").
* A scalar called "my_array" which is a reference to an array.
* The array that $my_array is referring to, which has one element.
* That element, which is a reference to a hash.
* An anonymous hash with no elements in it.
To put it another way:
* @my_array is a local array which has no value
* $my_array is a scalar which is a reference to an array
* @{ $my_array } is the array that you're trying to
dereference the first element of.
* $my_array->[0] is that first element, and its value
is a reference to an anonymous hash.
># Notation 1
>%my_hash=$my_array->[0];
In this statement, you have taken the reference to your hash and
assigned it to a hash. This isn't likely to lead to useful results.
You need to instead assign it to a scalar that can hold a reference:
$my_hash_ref = $my_array->[0];
or assign the whole hash by dereferencing the reference:
%my_hash = %{ $my_array->[0] };
>$my_hash{name}="Don";
Here you modify your hash and in doing so, you have no effect on
anything referenced by $my_array or by anything it references.
However, if you had done this:
$my_hash_ref = $my_array->[0];
$my_hash_ref->{name} = "Don";
You would have copied the reference to the hash and then used the
reference to the hash to modify the hash.
># Notation 2
>$my_array->[0]{name}="Don";
That is actually shorthand for
$my_array->[0]->{name} = "Don";
which means it will do what you're apparently trying to do.
Hope that helps.
- Logan
[1] Except that it's not unrelated because "local" messes with
the symbol table in a way that makes them both local, even
though their values are a completely separate. That's one
good reason to use "my" instead of "local".
------------------------------
Date: 24 Jul 2000 09:01:10 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Hostname in Net::SMTP
Message-Id: <87k8ebbpax.fsf@limey.hpcc.uh.edu>
>> On Mon, 24 Jul 2000 11:47:35 +0000,
>> Mike <mike@cyborg-group.com> said:
> When I set up up the from field without a full email
> address ie name instead of name@mailhost the mail gets
> sent fine but when I try to do a reply it looks for an
> email address on my own machine instead of the host ie:
> it sends to mike@mikespc.mailshot.
That's what it should do. If you don't qualify the
address, it will be interpreted as local by the receiving
user agent when a reply is set up.
> Is there any way to set the host in the script so that
> it will not try to do this. It would be useful as the
> purpose is for a client and I would not really like my
> host name to appear in the actual message.
Sounds like you want to set up masquerading in the
outgoing SMTP system, but that's got nothing to do with
perl.
Either that or set the From field explicitly yourself in
the Mail Headers. Using the Mail:: and MIME:: module
families may help here.
hth
t
--
"With $10,000, we'd be millionaires!"
Homer Simpson
------------------------------
Date: Mon, 24 Jul 2000 15:00:28 GMT
From: timhood@bigfoot.com
Subject: Re: How to detect when an output file is removed
Message-Id: <8lhlm8$ogm$1@nnrp1.deja.com>
In article <12vlns8i9olfquna0d3hb8u3cn1qkg507o@news.supernews.net>,
Bernie Cosell <bernie@fantasyfarm.com> wrote:
> mjtg@cus.cam.ac.uk (M.J.T. Guy) wrote:
>
> } Drew Simonis <care227@attglobal.net> wrote:
> } >timhood@bigfoot.com wrote:
> } >>
> } >> I have a process that writes output to a log file. It seems
though that
> } >> if someone removes the logfile after the program redirects the
output
> } >> that all future output goes to nowhere-land.
> }
> } In the Unix world, you're at liberty to delete a file even though it
> } is currently open. Or more strictly, you can delete a link to a
file
> } (directory entry). The file itself isn't deleted; rather it
will
> } go away when the last handle to it disappears (in this case, when
> } the program closes the file).
>
> And that's why many programs, for which the loss of log data is
potentially
> a problem, close and re-open the log file with each entry -- a bit
more
> overhead but unless your program has gone _wild_ making log entries it
> shouldn't be that severe, and it does ensure that your log entries
will
> make it to an (at least temporarily) visible file. As a rule, IMO,
> programs that hold their log files open for the entire run of the
program
> are bad-Unix-citizens... it just makes life too difficult [e.g, you
can't
> "roll" the logs or snapshot them or anything if the program has
glommed
> onto the file]. At the least, if you must do this, you really ought
to
> provide a signal that'll force your program to close and reopen the
log
> file.
That's what I had resigned myself to doing. The situation you described
is exactly mine. While I anticipate log rolling to be the most common
event, I wanted a means of losing as little log output as possible if
some gung-ho admin decides to wipe out the file. Since my process will
run as a daemon, it would be a long time before the process stopped and
re-started.
>
> A Unix trick: this is a standard hack for making "for sure cleaned up"
temp
> files. What you do is open a temp file, then 'unlink' it --- if you
opened
> it "+<" you can move around in it and read and write and generally use
it
> for a scratch pad or anything you need it for.. and then when your
process
> goes away...poof.. the file does too. No muss,no fuss, no cleanup, no
bugs
> or abort or signal problems leaving [potentially sensitive] temp info
> around.
That's a neat idea, I'll have to remember that. That's one of those
little tricks that definitely deserves some extra commenting in the code
so as not to confuse the casual observer. :-)
Thanks.
>
> /Bernie\
> --
> Bernie Cosell Fantasy Farm Fibers
> bernie@fantasyfarm.com Pearisburg, VA
> --> Too many people, too few sheep <--
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 24 Jul 2000 11:24:14 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: How to detect when an output file is removed
Message-Id: <8lhqje$doa$1@provolone.cs.utexas.edu>
In article <8lhlm8$ogm$1@nnrp1.deja.com>, <timhood@bigfoot.com> wrote:
>That's what I had resigned myself to doing. The situation you described
>is exactly mine. While I anticipate log rolling to be the most common
>event, I wanted a means of losing as little log output as possible if
>some gung-ho admin decides to wipe out the file.
If a gung-ho admin decides to wipe out the file, that's the gung-ho
admin's problem. And I can say that from an admin's point of view too,
because I was one for several years. :-)
In my opinion, the best thing to do is to make clear documentation so
the system admin can figure out what your logging strategy is, and then
not worry about what they do beyond that point.
In other words, don't worry about a gung-ho admin deleting a file. The
proper way to rotate log files doesn't involve "cp" at all, and only
involves "rm" on the oldest file. (And even that "rm" is optional --
you can have "mv" do it for you.)
Basically, you do this:
rm logfile.3
mv logfile.2 logfile.3
mv logfile.1 logfile.2
mv logfile logfile.1
touch logfile
chmod 755 logfile # or whatever.
Now, this means that logfile (the active log file) gets renamed while
it's open, but that's not a problem because the daemon will continue
writing to it.
Note also the "chmod". If you re-open the file yourself, you do the
file creation yourself; this takes control of mode and ownership (and
similar stuff) away from the system admin.
So, IMHO, the best way to do it is with some facility (a la SIGHUP for
syslog) that allows the system admin's script to notify your daemon
that the logs need to be closed and re-opened.
Another approach is just to use syslog. :-)
- Logan
------------------------------
Date: Mon, 24 Jul 2000 16:31:38 GMT
From: "rcmodeler" <rcmodeler@mmcable.com>
Subject: Looking for an online store script.
Message-Id: <Kb_e5.12852$t%4.101307@typhoon.kc.rr.com>
Looking for an online store script.
Thanks All..
rcmwc@mmcable.com
------------------------------
Date: Mon, 24 Jul 2000 11:32:37 -0400
From: Ying Hu <yhu@mail.nih.gov>
Subject: Mail::Mailer for win9n
Message-Id: <397C6195.89C6C473@mail.nih.gov>
Hi,
Is there and/or where is Mail module for Win9n?
Thanks!
Ying
------------------------------
Date: Mon, 24 Jul 2000 11:44:00 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: Mail::Mailer for win9n
Message-Id: <397C7250.C9F0A380@mail.uca.edu>
Ying Hu wrote:
>
> Hi,
>
> Is there and/or where is Mail module for Win9n?
perlwin32faq4: How do I send email from Perl for Win32?
Cameron
--
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu
------------------------------
Date: Mon, 24 Jul 2000 17:20:15 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: matching contents of array
Message-Id: <1cuonssmmlbmt9sv6iohs23ifmd3fhn05r@4ax.com>
steve cramton wrote:
>@providers = qw(aol tweb.net timeweb.net mailhost.sas.net
>hotmail digiweb.com) ;
>
>#the regex im using is
>if ($host =~ /\$providers\b/i)
I think you want
/\b$providers\b/i
which still won't work because $providers is not related to @providers.
Suppose you set $" to "|", and suppose you try to match
/\b@providers\b/i
that STILL wouldn't do the proper thing for "\b", because it will only
tie in with the first or last array item. For example, if @providers
contains qw(hotmail yahoo pobox), then the regex would be treated as
/\bhotmail|yahoo|pobox\b/i
So "hotmail" would only be tested for a leading word boundary, "pobox"
for a trailing one, and "yahoo" for none.
This would work:
/\b(?:hotmail|yahoo|pobox)\b/i
--
Bart.
------------------------------
Date: Mon, 24 Jul 2000 08:12:20 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Matts Script Archive - A critique
Message-Id: <397C40B4.F8B1661C@home.com>
Richard Lawrence wrote:
>
> Drew Simonis <care227@attglobal.net> wrote:
> >
> > Do a Deja search on Matt in this NG, you'll find plenty of... err..
> > "critiques".
>
> I found a fair few descriptive complaints but nothing where someone had
> sat down and quoted a bit of code, explained why it was bad and what it
> should be.
>
> I know its a lot to ask so I'm not holding out much hope. I just
> thought it would be a nice way to show people how not to do things.
Odd that no one has mentioned this yet:
Mark-Jason Dominus has recently done a couple of "Program Repair Shop
and Red Flags" articles on perl.com for this purpose. Not Matt's stuff,
nor CGI for that matter, but I think it fits the intent of your original
post.
http://www.perl.com/pub/2000/04/raceinfo.html
http://www.perl.com/pub/2000/06/commify.html
-mjc
------------------------------
Date: Mon, 24 Jul 2000 13:12:23 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Need questions for Perl quiz
Message-Id: <slrn8nofsv.61h.bernard.el-hagin@gdndev25.lido-tech>
Daniel Foster <daniel@blackomega.com> wrote:
>I'm compiling a quiz on Perl to test people's knowledge. The
>questions need to be multiple choice, with 4 or 5 answers, like this
>one...
>
>If an anonymous subroutine is created with "$coderef = sub {print
>"Hello world\n";};" then how should it be called?
>1. &coderef;
>2. $coderef->call;
>3. &{$coderef};
>4. anoncall($coderef);
>
>The other answers are clearly made up, with only one correct answer
>(even though there are clearly multiple ways of doing anything).
>
>If you could take a moment to write just one or two questions I'd be
>most grateful.
Try this:
___________________
#!/usr/bin/perl -wl
use strict;
my (@questions, $i);
while( $i++ < 9 ){
open (IN, "perldoc perlfaq$i | col -b |") or die $!;
while (<IN>){
push @questions, $1 if /^(\s*[A-Z].*\?\s*)$/g;
}
}
print @questions;
___________________
That's 236 questions for you.
You're welcome.
Bernard
--
perl -le 'open(JustAnotherPerlHacker,"")or$_="B$!e$!r$!n$!a$!r$!d$!";
print split/No such file or directory/;'
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 3785
**************************************