[22853] in Perl-Users-Digest
Perl-Users Digest, Issue: 5074 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 4 14:06:04 2003
Date: Wed, 4 Jun 2003 11:05:12 -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 Wed, 4 Jun 2003 Volume: 10 Number: 5074
Today's topics:
Re: a Bayesian intelligent e-mail autoresponder? (totojepast)
Re: a Bayesian intelligent e-mail autoresponder? (totojepast)
Re: Access variable in caller's scope (or alternate sol <jaspax@u.washington.edu>
Re: capturing output of executed system command <tzz@lifelogs.com>
Re: Directory Notification in Unix? <tzz@lifelogs.com>
Re: formatted STDERR of an child process <spam@thecouch.homeip.net>
Re: formatting my output (Sam Holden)
Re: getting the date for "last Wednesday" <tzz@lifelogs.com>
Re: getting the date for "last Wednesday" (John D)
Help needed checking if paths are the same (Mark Smith)
Re: Help needed checking if paths are the same <noreply@gunnar.cc>
Re: Hy guys,I need some help(opening directories) <jurgenex@hotmail.com>
Re: Hy guys,I need some help(opening directories) (Tad McClellan)
Re: Hy guys,I need some help(opening directories) (Tad McClellan)
Re: Module to decode MS Word documents? (Sherman Willden)
Re: Module to decode MS Word documents? <tzz@lifelogs.com>
Re: Module to decode MS Word documents? <wsegrave@mindspring.com>
Re: Need Help with directories <jurgenex@hotmail.com>
Re: Need Help with directories <wksmith@optonline.net>
Re: Perl Daemon and inittab (Villy Kruse)
Re: Perl Daemon and inittab (Carlton Brown)
Re: Perl fork() question ctcgag@hotmail.com
Problems with & operator <shanem@nospam.ll.mit.edu>
Re: Problems with & operator (Sam Holden)
Problems with gmtime function on activestate 5.8.0 vers <mothra@nowhereatall.com>
Re: Problems with gmtime function on activestate 5.8.0 <mothra@nowhereatall.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 4 Jun 2003 10:41:57 -0700
From: totojepast@atlas.cz (totojepast)
Subject: Re: a Bayesian intelligent e-mail autoresponder?
Message-Id: <1445a2d7.0306040941.5dfe7969@posting.google.com>
I want the script to return an information based on the text of the
query. Fighting spam is not the purpose.
Bob Wheeler <bwheeler@echip.com> wrote in message news:<3ED363D1.7030301@echip.com>...
> I don't know about "evil," but it will cause you problems
> if used to bounce spam, since you not only will double the
> traffic, as observed below, but maybe tripple it since the
> receiving server will likey reply with an unknown address
> message which will fill your inbox.
>
> Blue Squirrel offers a commercial product, Spam Sleuth,
> which bounces this way if you choose. It uses a Bayesian
> procedure to classify mail. I'm not sure, however, that
> the procedure is superior to a simple discriminant function,
> since there are only two categorise, spam, and non-spam.
>
> Yeff wrote:
> > On 26 May 2003 07:03:56 -0700, totojepast wrote:
> >
> >
> >>Please can you tell me if anybody has tried to use ifile or a similar
> >>Bayesian for an automatic e-mail autoresponder?
> >
> >
> > If I grok what you're trying to do (automatically identify and bounce
> > spam?) then all I can say is that the concept is *evil*.
> >
> > "Evil, pure and simple from the eighth dimension!"
> >
> > You're doubling the amount of traffic generated by the spam and probably
> > bouncing your messages to bogus addresses (not the people who actually sent
> > the spam).
> >
> > Evil.
> >
> > -Jeff B.
> > yeff at erols dot com
------------------------------
Date: 4 Jun 2003 10:42:40 -0700
From: totojepast@atlas.cz (totojepast)
Subject: Re: a Bayesian intelligent e-mail autoresponder?
Message-Id: <1445a2d7.0306040942.2b52a19c@posting.google.com>
I want the script to return an information based on the text of the
query. Fighting spam is not the purpose.
pkent <pkent77tea@yahoo.com.tea> wrote in message news:<pkent77tea-FD4328.21102028052003@dev.rsn.selsyn.co.uk>...
> In article <6869c57c.0305271849.6c3b8ab2@posting.google.com>,
> larix_occidentalis@yahoo.com (Western Larch) wrote:
>
> > Yeff <yeff@myrealbox.com> wrote:
> > > On 26 May 2003 07:03:56 -0700, totojepast wrote:
> > > > Please can you tell me if anybody has tried to use ifile or a similar
> > > > Bayesian for an automatic e-mail autoresponder?
> > >
> > > If I grok what you're trying to do (automatically identify and bounce
> > > spam?) then all I can say is that the concept is *evil*.
> > >
> > > "Evil, pure and simple from the eighth dimension!"
> > >
> > > You're doubling the amount of traffic generated by the spam and probably
> > > bouncing your messages to bogus addresses (not the people who actually sent
> > > the spam).
> >
> > Relax, dude. Why not take the proposal as a springboard for
> > further development? No need to get bent out of shape.
> >
> > How about this: instead of replying to every apparent spam message,
> > reply only to the ones which look like they might possibly be non-spam.
> > So if every message is assigned a score, and the scores above a
> > threshold are thrown out as spam, then messages near but just above
> > the threshold would merit a reply.
>
> That sounds pretty good. Another approach (maybe covered elsewehere in
> this thread) is to have your MTA return a 500 code to the sender when a
> spam is detected. I expect this ends up generating return messages of
> some kind, somewhere, and some of those might be to bogus addresses.
> Other people set up their MTA to simply dev-null spam. It's a hard
> problem to solve, given the way email works. I know many people who love
> SpamAssassin though (which is perl I think)
>
> P
------------------------------
Date: Wed, 4 Jun 2003 08:56:34 -0700
From: JS Bangs <jaspax@u.washington.edu>
Subject: Re: Access variable in caller's scope (or alternate solution?)
Message-Id: <Pine.A41.4.55.0306040817130.83310@dante35.u.washington.edu>
Anno Siegel sikyal:
> What still isn't clear is who sets the "direction" value and when does
> this happen. Apparently at some point the user has to type in
> "do => sub { metathesize($_[0], $_[1])" but not "direction => 'rightward'".
> So who contributes "direction => 'rightward'"?
The user does have to type "direction => 'rightward'" or "direction =>
'leftward'" if they want. If the user neglects to do so, 'rightward' is
assigned as a default, but the direction is still a user-defined property.
From my original post:
> > > > $rules = new Lingua::Phonology::Rules;
> > > > $rules->add_rule( Swap => {
> > > > direction => 'rightward',
^^^^^^^^^^^
> > > > do => sub { metathesize($_[0], $_[1]); } });
Moving on . . .
> I don't see why you necessarily need a package variable for that.
> You could use a file scoped lexical "my $dir", plus a class method
> to set the variable. It doesn't even have to be file-scoped:
Methathesis() and the rule algorithm are in different packages, so I don't
see how what you wrote will help. There are at least three different
namespaces here:
main (user script)
Lingua::Phonology::Rules
Lingua::Phonology::Functions
The user is using Rules and Functions, and importing metathesis() from
Functions. In any case, metathesis() runs in a scope that does not
normally have access to Rules.pm's internal variables. There actually
already exists a get/set method for the direction for Rules objects, but
trying to get metathesis() to use that makes the problem worse, as it
would need to have both the Rules object and the name of the currently
executing rule in order to retrieve the direction.
I just thought of a different solution, though. The arguments passed to
metathesis() (or any similar function) are objects in a third package,
Lingua::Phonology::Segment. Segment allows for properties to be added and
dropped at run-time, so I could add a temporary property to the Segment
objects and smuggle my Rules variables in that way. This may be the best
solution.
Jesse S. Bangs jaspax@u.washington.edu
http://students.washington.edu/jaspax/
http://students.washington.edu/jaspax/blog
Jesus asked them, "Who do you say that I am?"
And they answered, "You are the eschatological manifestation of the ground
of our being, the kerygma in which we find the ultimate meaning of our
interpersonal relationship."
And Jesus said, "What?"
------------------------------
Date: Wed, 04 Jun 2003 10:54:13 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: capturing output of executed system command
Message-Id: <4nllwhgaga.fsf@lockgroove.bwh.harvard.edu>
On Wed, 04 Jun 2003, grazz@pobox.com wrote:
> Andy Baxter <news2@earthsong.null.free-online.co.uk> wrote:
>> benson limketkai wrote:
>>
>>> system 'ps'
>>>
>>> how can i redirect the output into an array?
>
> [ snip sig, etc ]
>
>> $ps=`ps`; # capture output of 'ps'
>> print $ps ."\n"; # print output as a string.
>> @ps=split /\n/,$ps; # split into an array
>
> You're making this harder than it needs to be:
>
> my @ps = `ps`;
Don't forget
chomp @ps;
to get the effect of the "split /\n/, $ps" in the original code.
Otherwise you're leaving the trailing newlines.
Ted
------------------------------
Date: Wed, 04 Jun 2003 10:58:44 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Directory Notification in Unix?
Message-Id: <4nhe75ga8r.fsf@lockgroove.bwh.harvard.edu>
On Wed, 04 Jun 2003, bik.mido@tiscalinet.it wrote:
> On 31 May 2003 21:09:07 +0100, Brian McCauley <nobull@mail.com>
> wrote:
>
>>> I'm looking for something like Win32::ChangeNotify except that it
>>> needs to run on Solaris. For those who don't know, it notifies you
>>> when something has happened in a particular directory.
>
>>There is no standard Unix feature for this.
>
>>This is really a Unix question.
>
> So, may we say that we finally found a win* feature that *nices
> don't provide? OK, then one would have to argue wether this is a
> useful feature or not... if I understand correctly, this is the kind
> of facility exploited e.g. in a file browser to instantly update the
> visual representation of a "folder" as files are added/removed/etc.,
> isn't it?
See the info on FAM:
http://oss.sgi.com/projects/fam/faq.html
There is a Perl interface to it:
http://search.cpan.org/author/JGLICK/SGI-FAM-1.002/lib/SGI/FAM.pm
Ted
------------------------------
Date: Wed, 04 Jun 2003 10:48:46 -0400
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: formatted STDERR of an child process
Message-Id: <kFnDa.47669$g33.599344@weber.videotron.net>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Michael Korte wrote:
> Hello NG :-)
>
> I´ve a tricky question :
>
> My perlscript is starting a process (In my case : ldapdelete / ldapmodify)
> and it switches the STDERR into my Logfile
> like this :
>
> open(LOGG,">>logfile.log") or die "could not open logfile.log";
> open(STDERR, ">&LOGG") || die "STDERR: $!\n";
>
> This works fine, but all STDERRoutput, of course, is being written directly
> into the file. All Entries I´m creating from the actual script
> are formatted like :
>
> [03.06.2003] [ERROR] "Some Error String "
>
> Does somebody know a possibility to format the STDERR from the childprocess
> before writing into the file ?
> My first suggestion was to write it into a tmpfile, for later formatting
> these entries, but in this case I would not get the
> real time when the Error occureds...
>
> Maybe I can first send the STDERR into a function ?
> Thx for any suggestion.
I am sure one of the fine modules listed here:
http://search.cpan.org/search?query=stderr&mode=all
Will do what you want.
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE+3gbReS99pGMif6wRAlMEAJ0buqG3v4rCpDNIxG6aznk2U93TVQCggFSi
evf5lA4ojjsqibAYtOd3uz8=
=4lAL
-----END PGP SIGNATURE-----
------------------------------
Date: 4 Jun 2003 13:30:05 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: formatting my output
Message-Id: <slrnbdrt2t.qpm.sholden@flexal.cs.usyd.edu.au>
On 4 Jun 2003 05:12:17 -0700, slash <satishi@gwu.edu> wrote:
> Hi,
> Thanks for your response. I tried what you had mentioned before but
> not any success. The output I want is the following:
Replace the printf with print in the change I suggested (I didn't notice the
useless use of printf when I copy-n-pasted the line...).
--
Sam Holden
------------------------------
Date: Wed, 04 Jun 2003 11:05:21 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: getting the date for "last Wednesday"
Message-Id: <4nd6htg9xq.fsf@lockgroove.bwh.harvard.edu>
On 4 Jun 2003, anno4000@lublin.zrz.tu-berlin.de wrote:
> In the presence of DST, there are days that are shorter than 24
> hours (in local time). In your original solution you are stepping
> back by 24 hour intervals, so you may skip the day you are looking
> for if you are unlucky. You would then get the Wednesday a week
> earlier.
I know which solution is more "proper," but specifically in this case
stepping back by 1 hour instead of 24 would be correct and probably
will be faster than the proper solution. It will definitely eliminate
the dependency on an external module, which may be desirable or even
required.
Ted
------------------------------
Date: 4 Jun 2003 09:39:22 -0700
From: johndageek@yahoo.com (John D)
Subject: Re: getting the date for "last Wednesday"
Message-Id: <c608545f.0306040839.3b4faa93@posting.google.com>
"David K. Wall" <usenet@dwall.fastmail.fm> wrote in message news:<Xns938FDBFCA519Edkwwashere@216.168.3.30>...
> I need a function that will return the calendar date for Wednesday of
> last week. If the current day of the week is Wednesday, I want last
> week's date. All I need is year, month, and day.
>
> Here's the function I wrote:
>
> sub get_last_wed {
> my $usetime = time();
> my $weekday = 0; # as long as it's not 3 (Wed)
> my @date;
> while ($weekday != 3) { # 3=Wed (0=Sun)
> $usetime -= 24*60*60;
> ($weekday, @date) = (localtime $usetime)[6,5,4,3];
> }
> return $date[0]+1900, $date[1]+1, $date[2]; # Year,Month,Day
> }
>
> It returns just what I want, but in my opinion it's a bit ugly. Should
> I try to make it "prettier", or just go ahead and use it? It doesn't
> really *matter*, but I or whoever has to maintain this years down the
> road might appreciate it.
>
> By the way, execution speed is not an issue. I wouldn't want it to take
> more than, say, 0.1 sec, but other than that I don't care. It's far
> faster than that already.
This might do it
$today=time();
## get day of week
$days_offset = (localtime($today))[6];
## convert to an offset
$days_offset =~ tr/0123456/4567123/;
$seconds_offset = $days_offset * 86400;
$last_wednesday_date = localtime($today - $seconds_offset);
Enjoy!
------------------------------
Date: 4 Jun 2003 06:42:55 -0700
From: Mark.Smith@sonyericsson.com (Mark Smith)
Subject: Help needed checking if paths are the same
Message-Id: <cf24885e.0306040542.4ed0b76a@posting.google.com>
I have two arrays of file paths. One contains paths in the format:
d:\path\somepath\path1\filename.exe
The other contains paths in the format:
\Path\ANOTHERPATH\Pathname\somefile.txt
What I need to do is compare every path from the first array against
every path from the second array and peform some output when they
match. Now I need to disregard the drive letter and case so I would
get a match for the following strings:
d:\path\somepath\path1\filename.exe
and
\PATH\somepath\Path1\Filename.exe
I've tried pattern matching the second against the first with \i but
with no success. Can anyone offer a solution.
Many thanks.
Regards,
Mark.
------------------------------
Date: Wed, 04 Jun 2003 15:42:44 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Help needed checking if paths are the same
Message-Id: <bbkt6t$aql7v$1@ID-184292.news.dfncis.de>
Mark Smith wrote:
> What I need to do is compare every path from the first array
> against every path from the second array and peform some output
> when they match. Now I need to disregard the drive letter and case
> ...
<snip>
> I've tried pattern matching the second against the first with \i
> but with no success.
Let's see what you've got.
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 04 Jun 2003 13:28:49 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Hy guys,I need some help(opening directories)
Message-Id: <lumDa.42249$da1.17563@nwrddc03.gnilink.net>
Zoran wrote:
[...]
> I am getting this error message:
>
> "readline()on closed filehandle DAT at test.pl line 309"
>
> line 309:$rawdata=<DAT>;
>
> Can someone explain me what's wrong with my code?
[...]
> open DAT,"< $opname";
Why don't you ask perl to help you?
open DAT, ,"< $opname" or die "Cannot open $opname because $!\n";
> undef $/;
> $rawdata=<DAT>;
> $flaggy=1;
jue
------------------------------
Date: Wed, 4 Jun 2003 09:47:13 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Hy guys,I need some help(opening directories)
Message-Id: <slrnbds1jh.n23.tadmc@magna.augustmail.com>
Zoran <Zoran.Marinkovic@post.rwth-aachen.de> wrote:
> On 4 Jun 2003 09:30:36 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
> Siegel) wrote:
>>Zoran <zoran_m@t-online.de> wrote in comp.lang.perl.misc:
>>> foreach $file (readdir VH){
>>> if ($file eq $opname)
>>> {
>>> open DAT,"< $opname";
>>> If I am going to
>>> directory C:\perl I cannot open any file.
>>Old story, but apparently not a FAQ yet.
It is already covered in the documentation for the function being
used, so it should be a NAQ (never). :-)
perldoc -f readdir
... you'd better prepend the directory ...
Though I suppose it should change "filetest" to something more general.
>>readdir() returns only the file name, not the whole path to the file.
> Oh god,you guys are the best.
You do not need us guys if you read the contract
before signing the contract!
Become self-sufficient. Use the docs Luke!
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 4 Jun 2003 09:55:03 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Hy guys,I need some help(opening directories)
Message-Id: <slrnbds227.n23.tadmc@magna.augustmail.com>
Zoran <zoran_m@t-online.de> wrote:
> if (!opendir VH,$directory)
> {
> $erg_text->delete("1.0",'end');
> $erg_text->insert('end',"Directory $directory not found\n");return;}
>
> foreach $file (readdir VH){
> if ($file eq $opname)
> {
> open DAT,"< $opname";
> undef $/;
> $rawdata=<DAT>;
> $flaggy=1;
> }}
> Can someone explain me what's wrong with my code?
Yes.
It is not indented so as to reveal its structure.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 4 Jun 2003 08:46:28 -0700
From: sherman.willden@hp.com (Sherman Willden)
Subject: Re: Module to decode MS Word documents?
Message-Id: <3a80d8d6.0306040746.5045896a@posting.google.com>
This is useful information. How about an Excel xls spreadsheet? How do
I get a string from it?
Thanks;
Sherman
------------------------------
Date: Wed, 04 Jun 2003 12:11:27 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Module to decode MS Word documents?
Message-Id: <4nd6htesb4.fsf@lockgroove.bwh.harvard.edu>
On 4 Jun 2003, sherman.willden@hp.com wrote:
> This is useful information. How about an Excel xls spreadsheet? How
> do I get a string from it?
This article should help.
http://www-106.ibm.com/developerworks/linux/library/l-pexcel/
Ted
------------------------------
Date: Wed, 4 Jun 2003 11:38:18 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Module to decode MS Word documents?
Message-Id: <bbl7g9$f0n$1@slb6.atl.mindspring.net>
"Sherman Willden" <sherman.willden@hp.com> wrote in message
news:3a80d8d6.0306040746.5045896a@posting.google.com...
> This is useful information. How about an Excel xls spreadsheet? How do
> I get a string from it?
See, e.g.,
1. _The Perl Journal_, Issue No. 10 (Vol. 3, No. 2), OLE Automation with
Perl, pp. 39-46.
2. PowerPoint presentation at www.roth.net
Did you search CPAN for applicable modules?
"How do I ..." should be a cue for you to look at FAQs.
Cheers.
Bill Segraves
------------------------------
Date: Wed, 04 Jun 2003 13:34:12 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Need Help with directories
Message-Id: <ozmDa.42252$da1.32234@nwrddc03.gnilink.net>
Zoran wrote:
> Hello guys,i have some problems with opening files in directories.
Is this a different problem then the one you posted under the subject
"Hy guys,I need some help(opening directories)"?
They seem to be awfully similar to me.
jue
------------------------------
Date: Wed, 04 Jun 2003 14:00:06 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: Need Help with directories
Message-Id: <GXmDa.12933$sG3.5543286@news4.srv.hcvlny.cv.net>
"Zoran" <Zoran.Marinkovic@post.rwth-aachen.de> wrote in message
news:3edde7ab.2242186@news.rwth-aachen.de...
>
>
>
> Hello guys,i have some problems with opening files in directories.
>
> I am currently running my perl program in C:\perl\appz
> Without problems i am able to open files and work with them.
> But when I am going to C:\perl and want to open a file i am getting
> this error message:
>
> "readline() on closed filehandle DAT at test.pl line 309"
>
>
> here is the code
>
>
>
> if (!opendir VH,$directory)
opendir(VH,$directory) or die "Unable to open directory $directory: $!";
> { ####### no longer needed
> $erg_text->delete("1.0",'end');
> $erg_text->insert('end',"Directory $directory not found\n");return;}
>
> foreach $file (readdir VH){
> if ($file eq $opname)
> {
> open DAT,"< $opname";
> undef $/;
> $rawdata=<DAT>;
> }} ####### remove outer brace
>
>
> can anyone tell me whats wrong?
opendir returns TRUE on success. Your code processes the directory only
if the open fails. It is easier to find and fix the problem if you die
and report the error as soon as possible.
Bill
------------------------------
Date: 04 Jun 2003 15:43:07 GMT
From: vek@station02.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Perl Daemon and inittab
Message-Id: <slrnbds4sb.cb8.vek@station02.ohout.pharmapartners.nl>
On Wed, 04 Jun 2003 01:57:04 GMT,
Jack D. <goodcall__1@hotmail.com> wrote:
>I want to have a program running as a daemon. (Linux RH7.2) So I daemonize using
>the subroutine as shown at:
>
>http://webreference.com/perl/tutorial/9/3.html
>
>I want this running all the time, so I put the perl command as a 'respawn' in
>the inittab. The problem is that I get a "respawning too rapidly" error and I
>get about 10 of these running. I assume it has something to do with the fork and
>exit (which will respawn another program). I even tried wrapping the perlscript
>within a shell script to no avail.
>
The respawn entries in the inittab file are for processes which must be
restarted anytime it terminates, typically for the getty processes. A
deamonized program will terminate immediately when started, leaving a
running child process, and the init process will promptly start another
instance until it says "enough is enough" and issue the message shown above.
You can use a "once" entry in inittab instead, or don't daemonize the
program.
------------------------------
Date: 4 Jun 2003 10:20:19 -0700
From: carltonbrown@hotmail.com (Carlton Brown)
Subject: Re: Perl Daemon and inittab
Message-Id: <aa611a32.0306040920.34ebd7f7@posting.google.com>
"Jack D." <goodcall__1@hotmail.com> wrote in message news:<QlcDa.6348$QF2.1666995@news2.telusplanet.net>...
> I want to have a program running as a daemon. (Linux RH7.2) So I daemonize using
> the subroutine as shown at:
>
> http://webreference.com/perl/tutorial/9/3.html
>
> I want this running all the time, so I put the perl command as a 'respawn' in
> the inittab.
> 1. Am I doing this wrong?
The solution at the URL you've provided will cause the running daemon
to have a different PID than what was spawned out of inittab. It is
not a bad solution, I've used it in the past. But if you put it in
the inittab, init sees this as a program that exits immediately and
constantly needs respawning.
The right way to do it? Try your above solution without the
pid-changing code - don't fork, don't exit, don't setsid. Create a
signal handler to catch or ignore HUP signals.
This should work from init, but it leaves a minor problem if you run
it from the command line. If you run it from the command line, you'd
have to run it in the background if you wanted your prompt back.
That's because you don't detach from the parent tty if you don't fork.
Init doesn't run on a tty, so it should work fine there.
This is just from my experience on SunOS - writing code that works on
other platforms is left as an exercise for the reader.
------------------------------
Date: 04 Jun 2003 14:29:17 GMT
From: ctcgag@hotmail.com
Subject: Re: Perl fork() question
Message-Id: <20030604102917.984$Iv@newsreader.com>
Prodigy <reply@newsgroup.invalid> wrote:
>
> Hmm.. I read the perl documentation and both manual pages (2 and 9), but
> I don't really understand how I can use ioctl for my application. In
> short what I want: perl should build a socket to a remote host, do some
> things (send data, receive data) and then return the received data in a
> variable or something. At the moment, I'm doing this in serial but I want
> to do this in parallel, is that possible at all?
You mean something like this:
push @socket , IO::Socket::INET->new('assimilate.borg.org:31416') or die $!
foreach (1..10);
With no forking involved?
Now, of course you still need to coordinate the writing and reading, but
that's an application specific question and you haven't given anything to
go on.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service New Rate! $9.95/Month 50GB
------------------------------
Date: Wed, 04 Jun 2003 11:46:49 -0400
From: Shane McDaniel <shanem@nospam.ll.mit.edu>
Subject: Problems with & operator
Message-Id: <3EDE1469.F0F827D7@nospam.ll.mit.edu>
I have a text file with rows that looks as such
0x12345678 0x9abcdef0
I basically want to print out with same line but with the second number
bit masked with a certain mask.
Here's my code
--------
#!/usr/local/bin/perl
open( IN, "$ARGV[0]" ) || die "ERROR: can't open file $ARGV[0]\n";
foreach $line ( <IN> )
{
chomp $line;
($first, $second ) = split /\s+/, $line;
print "$first $second -> ";
$second &= 0x3ffffff;
print "$first $second\n";
}
-------
For the first line I get the following output
0x12345678 0x9abcdef0 -> 0x12345678 0
I can't figure out how to get & to properly bitmack the variable. I
tried explicitly saying $second was an number with '$second = int(
$second )' as one web page said that bitwise operators distinguish
between char and number variables.
Any ideas?
-shane
------------------------------
Date: 4 Jun 2003 16:00:26 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Problems with & operator
Message-Id: <slrnbds5sq.sks.sholden@flexal.cs.usyd.edu.au>
On Wed, 04 Jun 2003 11:46:49 -0400,
Shane McDaniel <shanem@nospam.ll.mit.edu> wrote:
> I have a text file with rows that looks as such
>
> 0x12345678 0x9abcdef0
>
>
> I basically want to print out with same line but with the second number
> bit masked with a certain mask.
>
> Here's my code
> --------
> #!/usr/local/bin/perl
>
> open( IN, "$ARGV[0]" ) || die "ERROR: can't open file $ARGV[0]\n";
>
>
> foreach $line ( <IN> )
> {
>
> chomp $line;
>
> ($first, $second ) = split /\s+/, $line;
> print "$first $second -> ";
>
> $second &= 0x3ffffff;
> print "$first $second\n";
>
> }
>
> -------
>
> For the first line I get the following output
>
> 0x12345678 0x9abcdef0 -> 0x12345678 0
>
>
> I can't figure out how to get & to properly bitmack the variable. I
> tried explicitly saying $second was an number with '$second = int(
> $second )' as one web page said that bitwise operators distinguish
> between char and number variables.
Try printing out $second after that int() call, you'll find it is 0.
0 & 0x3ffffff is 0, so the output is what I would expect.
See :
perldoc -f hex
For documentation on how to interpret a hex string as a number and not a
string.
--
Sam Holden
------------------------------
Date: Wed, 4 Jun 2003 09:08:07 -0700
From: "Mothra" <mothra@nowhereatall.com>
Subject: Problems with gmtime function on activestate 5.8.0 version of perl
Message-Id: <3ede170c@usenet.ugs.com>
Hi All,
I am having problems with the gmtime function on dates before Jan 1 1970.
Below you
will find a script that uses timegm (from the Time::Local module) and gmtime
(from default perl installation). This script will run under HPUX 10.20
using perl version 5.8.0 but will not run under windows :(
what is odd is that the timegm function produces the correct output
but to convert back (using gmtime) the script generates this error
F:\scripts>test.pl
-28853939
Uncaught exception from user code:
0 at F:\scripts\test.pl line 9.
Has anyone seen this? Is this a bug or am I doing
something stupid.
Thanks
Mothra
----------------
use warnings;
use strict;
use diagnostics;
use Time::Local;
my $time = timegm(1,1,1,1,1,1969);
print $time ."\n";
my $now = gmtime($time) or die"$?";
print $now;
------------------------------
Date: Wed, 4 Jun 2003 09:39:11 -0700
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: Problems with gmtime function on activestate 5.8.0 version of perl
Message-Id: <3ede1e54@usenet.ugs.com>
"Mothra" <mothra@nowhereatall.com> wrote in message
news:3ede170c@usenet.ugs.com...
> Hi All,
>
> I am having problems with the gmtime function on dates before Jan 1 1970.
> Below you
> will find a script that uses timegm (from the Time::Local module) and
gmtime
> (from default perl installation). This script will run under HPUX 10.20
> using perl version 5.8.0 but will not run under windows :(
> what is odd is that the timegm function produces the correct output
> but to convert back (using gmtime) the script generates this error
After taking another look at this. It seems that perl is using mktime
File config.vc:
d_mktime='define'
I checked the microsoft web site on this.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HT
ML/_crt_mktime.asp
The most important information is
If timeptr references a date before midnight, January 1, 1970, or if the
calendar time cannot be represented, the function returns -1 cast to type
time_t.
MORONS!!!!
Why did microsoft do this stupid thing? Now what?
Anyone up to creating a POSIX compliant gmtime() out of whole cloth for the
poor
souls running Win32???
Mothra
------------------------------
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 5074
***************************************