[22305] in Perl-Users-Digest
Perl-Users Digest, Issue: 4526 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 7 00:07:46 2003
Date: Thu, 6 Feb 2003 21:06:36 -0800 (PST)
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, 6 Feb 2003 Volume: 10 Number: 4526
Today's topics:
Re: Build my own perl html help docs <fma@doe.carleton.ca>
Re: Controlling order of precedence (Malcolm Dew-Jones)
Re: Controlling order of precedence <mgjv@tradingpost.com.au>
Re: Crossposting (was: Fetchrow Question) <mgarrish@rogers.com>
Decoding Newsgroup Messages with Attachments <deke@shillelagh.org>
Re: Decoding Newsgroup Messages with Attachments <jurgenex@hotmail.com>
Re: Decoding Newsgroup Messages with Attachments <deke@shillelagh.org>
error in timelocal function? <hugo@geoinformex.com>
Re: error in timelocal function? <mgjv@tradingpost.com.au>
Re: error in timelocal function? <goldbb2@earthlink.net>
Re: error in timelocal function? (Jay Tilton)
Re: getting env of another user <jurgenex@hotmail.com>
Re: I'm just not getting it... FAQ5 <mgjv@tradingpost.com.au>
Re: LWP multipart/form-data with content NOT from file <pa@panix.com>
Need a bit of help with LWP <anthonysaffer@NOSPAM.yahoo.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 7 Feb 2003 03:49:32 GMT
From: Shing-Fat Fred Ma <fma@doe.carleton.ca>
Subject: Re: Build my own perl html help docs
Message-Id: <3E432CC5.FC599BD7@doe.carleton.ca>
Helgi Briem wrote:
> On 5 Feb 2003 16:44:46 GMT, Shing-Fat Fred Ma
> <fma@doe.carleton.ca> wrote:
>
> > So I'm wondering of
> >the ActivePerl installation puts files into its own
> >self contained directory tree.
>
> Yes. C:/perl or /usr/local/ActivePerl-XXX/
> by default, but you can choose any directory.
>
> >A few more question, if you don't mind....is the
> >installation pretty robust and straightforward
> >for solaris 8 (sun box)?
>
> Yes. Very easy.
>
> > I would be building
>
> Activeperl is prebuilt for the OS. No building
> is necessary or possible.
>
> --
> Regards, Helgi Briem
> helgi AT decode DOT is
Since I'm not root, I generally have to build
stuff myself. (That's not a problem for the
old laptop, though). But I'll definitely keep that
option in mind. Thanks to everyone for the info.
Fred
--
Fred Ma, fma@doe.carleton.ca
Carleton University, Dept. of Electronics
1125 Colonel By Drive, Ottawa, Ontario
Canada, K1S 5B6
------------------------------
Date: 6 Feb 2003 19:06:18 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Controlling order of precedence
Message-Id: <3e4322aa@news.victoria.tc.ca>
Robert Krueger (racsw@frontiernet.net) wrote:
: Hi,
: In C++, you can control the order of evaluation in calculations by
: enclosing particular calculations in (). Everything is then calculated
: from the innermost () to the outermost () so any question of the order of
: precedence can be eliminated.
$result = ($a+$b) + ($c+$d) ;
Is $a+$b calculated before $c+$d ? Are you sure?
------------------------------
Date: Fri, 07 Feb 2003 04:11:42 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Controlling order of precedence
Message-Id: <slrnb46cfq.se5.mgjv@verbruggen.comdyn.com.au>
On 6 Feb 2003 19:06:18 -0800,
Malcolm Dew-Jones <yf110@vtn1.victoria.tc.ca> wrote:
> Robert Krueger (racsw@frontiernet.net) wrote:
>: Hi,
>: In C++, you can control the order of evaluation in calculations by
>: enclosing particular calculations in (). Everything is then calculated
>: from the innermost () to the outermost () so any question of the order of
>: precedence can be eliminated.
>
>
> $result = ($a+$b) + ($c+$d) ;
>
> Is $a+$b calculated before $c+$d ? Are you sure?
I don't think the OP claimed it would be. They only mentioned the
order for enclosing parens, and they only claimed it for C++, not for
Perl.
The OP claimed that in the above the two expressions in brackets would
be calculated before the addition of the results of those two
expressions [1].
What perl currently does is:
$ perl -MO=Terse,exec -e '$result = ($a+$b) + ($c+$d)'
OP (0x80fc088) enter
COP (0x8103018) nextstate
SVOP (0x80f9308) gvsv GV (0x80ffeb4) *a
SVOP (0x80f9328) gvsv GV (0x80ffe9c) *b
BINOP (0x8102d50) add [1]
SVOP (0x8102498) gvsv GV (0x80fff08) *c
SVOP (0x8172c08) gvsv GV (0x80ffecc) *d
BINOP (0x8102cb8) add [2]
BINOP (0x80f9378) add [3]
SVOP (0x8102d78) gvsv GV (0x80fff14) *result
BINOP (0x80f92e0) sassign
LISTOP (0x80fc038) leave [1]
-e syntax OK
So, yes, $a + $b (add [1]) is calculated before $c + $d (add[2]).
If we ever get other implementations of Perl, I suspect that the
language definition would have to be written to specify whether this
is mandatory or optional behaviour. Until then, perl is the
specification and is correct by default. :)
Martien
\begin{offtopic}
[1] Whether that is correct for C++, or whether the implementation
only needs to give you a result as if that actually happened is
another issue, and a matter for comp.lang.c++ if anyone is interested.
For C the actual order of evaluation of a, b, c and d would be
unspecified, and implementation-dependent. For simple variables that
makes no difference, but for anything with side effects, this can have
a severe impact if you reply on the order.
\end{offtopic}
--
|
Martien Verbruggen | If at first you don't succeed, try again.
Trading Post Australia | Then quit; there's no use being a damn fool
| about it.
------------------------------
Date: Fri, 07 Feb 2003 02:39:54 GMT
From: "mgarrish" <mgarrish@rogers.com>
Subject: Re: Crossposting (was: Fetchrow Question)
Message-Id: <_%E0a.584747$F2h1.132646@news01.bloor.is.net.cable.rogers.com>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnb40flh.8b8.tadmc@magna.augustmail.com...
>
> Pardon me, but your ignorance is showing.
>
He's been pouting ever since he had trouble understanding a simple scoping
problem I posed a long time back. I really enjoyed how you've all tried to
pin this on me, though, without realizing any of the context. There are
members of the Perl community who provide good advice and do the language a
service, but he rarely rises above his own sense of self-importance. And all
the half-hearted attempts to back him up are an exercise in futility,
because he's started you all off from such a terrible position. But post
away if it makes you feel any better, because all the "*plonks*" in the
world aren't going to change who or what he is.
As to the reason why I post to alt.perl, which is the heinous crime I stand
accused of, it is in part because I would rather answer the same question a
hundred times to help out a beginner than leave them to the mercy of the
elitism that flows through a number of people here. I also received some
invaluable advice from Randal Schwartz (a real expert, by the way) in
alt.perl (not earth shattering by any stretch, but extremely useful at the
time), and so I try to give back by helping out anyone else who is obviously
a beginner, regardless of whether that means answering the same question or
not.
So before I go quietly back to alt.perl, I'll just leave you all with one
last thought: if leaders lead by example, then take a look at how you've
behaved and think of the example you're setting. I have nothing to lose or
gain by getting in a flame war with Uri. I don't make my living by Perl, nor
am I interested in serving anything more than the niche market that is
alt.perl. If you really think you are the pillars of the community, however,
I would suggest you start behaving like it.
Plonk away now if you're so inclined...
Matt
------------------------------
Date: Fri, 07 Feb 2003 03:45:01 GMT
From: "Deke" <deke@shillelagh.org>
Subject: Decoding Newsgroup Messages with Attachments
Message-Id: <1ZF0a.11299$%U2.790324@twister.austin.rr.com>
I'm writing a web based newsgroup reader in perl using the Net::NNTP
module.Much to my surprise, it actually works pretty well.
The problem I'm running into is decoding messages with attachments. I've
never really played much with newgroups (beyond simple posting), but
apparently files can either be attached using MIME format or by uuencoding.
I can deal with MIME messages, but for the regardless of what I've tried I
can't seem to 1) recognize that non MIME formated message have
attachmentsand 2) decode them.
I've searched the web extensively in an effort to find an answer to the
above with no luck...so I'm posting here.
Questions:
1) Any suggestions on how I can recognize messages with files attached
2) How do I decode these messages
Thanks!
------------------------------
Date: Fri, 07 Feb 2003 03:49:17 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Decoding Newsgroup Messages with Attachments
Message-Id: <11G0a.2744$ta2.840@nwrddc01.gnilink.net>
Deke wrote:
> I'm writing a web based newsgroup reader in perl using the Net::NNTP
> module.Much to my surprise, it actually works pretty well.
>
> The problem I'm running into is decoding messages with attachments.
Well, then just don't do it.
Usenet is not the place for attachements. If you don't extract them then you
are loosing only junk but nothing important.
jue
------------------------------
Date: Fri, 07 Feb 2003 04:05:30 GMT
From: "Deke" <deke@shillelagh.org>
Subject: Re: Decoding Newsgroup Messages with Attachments
Message-Id: <egG0a.11585$%U2.792628@twister.austin.rr.com>
Good point, and actually I would prefer to not include attachments.
However, I'm still left with a message with a lot of unintelligable stuff
tacked on the end.
I have to 1) recongize and 2) filter....
I appreciate the input!
Thanks
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:11G0a.2744$ta2.840@nwrddc01.gnilink.net...
> Deke wrote:
> > I'm writing a web based newsgroup reader in perl using the Net::NNTP
> > module.Much to my surprise, it actually works pretty well.
> >
> > The problem I'm running into is decoding messages with attachments.
>
> Well, then just don't do it.
> Usenet is not the place for attachements. If you don't extract them then
you
> are loosing only junk but nothing important.
>
> jue
>
>
------------------------------
Date: Fri, 07 Feb 2003 11:07:25 +0800
From: hugo <hugo@geoinformex.com>
Subject: error in timelocal function?
Message-Id: <3E4322ED.9030006@geoinformex.com>
Hi
I am using the timelocal function to calculate time in seconds since
1970, then subtract a starting time from an ending time to get a
duration for a particular activity. It works well for time period such
as 9:00 - 11:00 am or 13:00 - 16:00 pm. However, when someone is doing
something from 24:00 to 2:00 am the system goes haywire.
I have the following code (with lines listing values in between)
$start_time[$i] = $start_hour[$i] . ":" . $start_min[$i];
print "<br><b>start_time is $start_time[$i]</b>\n";
Result of the printout is then: start_time is 24:00
$end_time[$i] = $end_hour[$i] . ":" . $end_min[$i];
print "<br><b>end_time is $end_time[$i]</b>\n";
Result of the printout is then: end_time is 2:00
($es_start) = timelocal_nocheck 0, (split /:/, $start_time[$i])[1],
(split /:/, $start_time[$i])[0], 1, 1, 70;
print "<br>es_start is $es_start";
Result of the printout is then: es_start is 2732400
($es_end) = timelocal_nocheck 0, (split /:/, $end_time[$i])[1],
(split /:/, $end_time[$i])[0], 1, 1, 70;
print "<br>es_end is $es_end";
Result of the printout is then: es_end is 2656800
($diff_in_seconds) = $es_end - $es_start;
print "difference in seconds is $diff_in_seconds<br>\n";
Result of the printout is then: difference in seconds is -75600
And indeed: when you bring back -75600 seconds to minutes and hours, you
get -21 hours whereas the difference between midnight and 2 am should be
2 hours.
Note that I used timelocal_nocheck as putting in 24:00 with timelocal
gave me an error "hour 24 out of range 0..23".
Is there a way around this i.e. a way to get the difference between
24:00 and 2:00 am ?
I have to note that the line:
($es_start) = timelocal_nocheck 0, (split /:/, start_time[$i])[1],
(split /:/, $start_time[$i])[0], 1, 1, 70;
comes from existing code and is a bit confusing to me - I am not
precisely sure what why initially the first element only is taken in
start_time[$i])[1] and then, in $start_time[$i])[0], 1, 1, 70; element
0, 1, 1 and 70.
In split you can define which elements you choose to put in $es_start,
but the way it is done is not entirely clear.
Any help, particularly a solution to this sticky problem will be greatly
appreciated.
Thanks
Hugo
------------------------------
Date: Fri, 07 Feb 2003 04:38:27 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: error in timelocal function?
Message-Id: <slrnb46e22.se5.mgjv@verbruggen.comdyn.com.au>
On Fri, 07 Feb 2003 11:07:25 +0800,
hugo <hugo@geoinformex.com> wrote:
> Hi
>
> I am using the timelocal function to calculate time in seconds since
> 1970,
Note that what timelocal returns is not the number of seconds since
1970, but since the epoch, and what exactly that is is
system-dependent. See the entry for time() in perlfunc.
> then subtract a starting time from an ending time to get a
> duration for a particular activity. It works well for time period such
> as 9:00 - 11:00 am or 13:00 - 16:00 pm. However, when someone is doing
> something from 24:00 to 2:00 am the system goes haywire.
That is a very bad description of a problem. "The system goes haywire"
is hardly descriptive of what happens.
> I have the following code (with lines listing values in between)
>
> $start_time[$i] = $start_hour[$i] . ":" . $start_min[$i];
> print "<br><b>start_time is $start_time[$i]</b>\n";
>
> Result of the printout is then: start_time is 24:00
It would be, if $start_hour[$i] is "24" and $start_min[$i] is "00".
Note the quotes. They have to be strings like that. You probably want
to investigate the sprintf function.
> $end_time[$i] = $end_hour[$i] . ":" . $end_min[$i];
> print "<br><b>end_time is $end_time[$i]</b>\n";
>
> Result of the printout is then: end_time is 2:00
>
> ($es_start) = timelocal_nocheck 0, (split /:/, $start_time[$i])[1],
> (split /:/, $start_time[$i])[0], 1, 1, 70;
Why do you concatenate hours and minutes, and then split them again
here? Why don't you simply use $start_hour[$i] and $start_min[$i]? Why
the brackets? Why do you use the 1st of February 1970 as the date? The
1st of Jan seems more logical to me, but since the actual date doesn't
matter at all, why don't you just leave those blank?
$es_start = timelocal_nocheck 0, $start_min[$i], $start_hour[$i], 1, 1, 70;
> print "<br>es_start is $es_start";
>
> Result of the printout is then: es_start is 2732400
The actual values are really not that important. The difference is.
however, that value you have there puts you 759 hours after your
system's epoch (which now appears to be indeed 1 Jan 1970 UTC), which
is 15 hours after midnight on February 1, 1970 UTC, not local time.
> ($es_end) = timelocal_nocheck 0, (split /:/, $end_time[$i])[1],
> (split /:/, $end_time[$i])[0], 1, 1, 70;
> print "<br>es_end is $es_end";
>
> Result of the printout is then: es_end is 2656800
>
> ($diff_in_seconds) = $es_end - $es_start;
> print "difference in seconds is $diff_in_seconds<br>\n";
>
> Result of the printout is then: difference in seconds is -75600
>
> And indeed: when you bring back -75600 seconds to minutes and hours, you
> get -21 hours whereas the difference between midnight and 2 am should be
> 2 hours.
But what you told Time::Local is to give you the seconds for 24 hours
after midnight, 1 Feb 1970, and 2 hours after midnight, 1 Feb 1970
(why it gets 21 hours there is beyond me, and doesn't look entirely
right).
> Note that I used timelocal_nocheck as putting in 24:00 with timelocal
> gave me an error "hour 24 out of range 0..23".
Then don't do that. Use 0:00 if that's what you mean.
> Is there a way around this i.e. a way to get the difference between
> 24:00 and 2:00 am ?
Yep. You either use 24:00 and 26:00 with timelocal_nocheck, or you use
0:00 and 2:00, or you also take the day into account. All of these
will work. You get garbage answers, because you put garbage in. It is,
of course, impossible for Time::Local to guess that you mean a
different day than you tell it to use. You need to give it correct
data. You also need to read the documentation for Time::Local to find
out what its offsets and valid ranges are. If you can't, at least
normalise your hours correctly, and use 0:00 for midnight, and 24:00
for midnight the following day.
If I were you, I would also keep track of the day (and the month and
year), and feed that to timelocal (or timelocal_nocheck) as well.
> I have to note that the line:
>
> ($es_start) = timelocal_nocheck 0, (split /:/, start_time[$i])[1],
> (split /:/, $start_time[$i])[0], 1, 1, 70;
>
> comes from existing code and is a bit confusing to me - I am not
> precisely sure what why initially the first element only is taken in
> start_time[$i])[1] and then, in $start_time[$i])[0], 1, 1, 70; element
> 0, 1, 1 and 70.
This splits out the minutes ($start_time[$i])[1]) and hours from the
string that were just created a few lines earlier. Wasteful and
obfuscatory.
Martien
--
|
Martien Verbruggen | Useful Statistic: 75% of the people make up
Trading Post Australia | 3/4 of the population.
|
------------------------------
Date: Thu, 06 Feb 2003 23:31:13 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: error in timelocal function?
Message-Id: <3E433691.48CC154@earthlink.net>
hugo wrote:
>
> Hi
>
> I am using the timelocal function to calculate time in seconds since
> 1970, then subtract a starting time from an ending time to get a
> duration for a particular activity. It works well for time period such
> as 9:00 - 11:00 am or 13:00 - 16:00 pm. However, when someone is
> doing something from 24:00 to 2:00 am the system goes haywire.
The magic number, 2AM, immediately sets off an alarm, indicating that
you're probably talking about a period where Daylight Savings Time is
entered or left.
Also... there is no such time as '24:00'.
Time goes from 23:59:59 (which is a minute before midnight) to 00:00:00
(midnight).
Looking for the hours field to be '24' is like looking for the minutes
field being '60'. It just doesn't happen.
[snip code which I merely glanced at]
--
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"
------------------------------
Date: Fri, 07 Feb 2003 04:26:49 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: error in timelocal function?
Message-Id: <3e432845.76171364@news.erols.com>
hugo <hugo@geoinformex.com> wrote:
: I am using the timelocal function
It would have been nice to mention also what module that function came
from.
And if you're going suspect the module of being buggy, mention also
its version. You may be using a version that has been superceded.
: to calculate time in seconds since
: 1970, then subtract a starting time from an ending time to get a
: duration for a particular activity. It works well for time period such
: as 9:00 - 11:00 am or 13:00 - 16:00 pm. However, when someone is doing
: something from 24:00 to 2:00 am the system goes haywire.
What timekeeping system represents midnight as 24:00? In one minute,
will it be 24:01, or will it be a more sensible 0:01?
Find the person who created this timekeeping system and kick him in
the head.
: I have the following code (with lines listing values in between)
[snip]
How about making sample code that stands on its own, from shebang to
__END__?
You're counting on people to be interested enough and patient enough
to fill in missing values for variables (e.g. @start_hour, @start_min,
$i, etc). That's a complete PITA.
------------------------------
Date: Fri, 07 Feb 2003 02:31:22 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: getting env of another user
Message-Id: <_TE0a.5871$5g7.1364@nwrddc02.gnilink.net>
Susanne Ruppel wrote:
> I am running an installation-script as "root", and need to get some of
> the environmental variables of user "sybase". After I got those
> variables the script should run further in root-context.
> Is there a way to do this? I'm looking for a non-interactive solution.
>
> I tried to change uid, gid, euid, egid, but I detected, that my
> environment stays the same (set by the shell)...
HOW did you try to change them?
Are you aware of the FAQ
I {changed directory, modified my environment} in a perl script. How come
the
change disappeared when I exited the script? How do I get my changes to be
visible?
jue
------------------------------
Date: Fri, 07 Feb 2003 03:51:11 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: I'm just not getting it... FAQ5
Message-Id: <slrnb46b9f.se5.mgjv@verbruggen.comdyn.com.au>
On Thu, 06 Feb 2003 19:12:51 -0500,
Mina Naguib <spam@thecouch.homeip.net> wrote:
> rab wrote:
>|
>| I need a script to take a text file that looks like this:
[snip]
>| and change it into a file that looks like this:
[snip]
> As with all things perl, TIMTOWTDI (there is more than once way to do it).
Indeed :)
> Here's one of them:
[snip]
And an approach I haven't seen yet:
perl -ne 'print unless /^grok-3/..$a++||print "grok-3 NEW TEXT\n",!/^grok-3/'
or
perl -ne '(/^grok-3/..$a++||print "grok-3 NEW TEXT\n",!/^grok-3/)||print'
or, more simply:
perl -pe 's/^(grok-3).*/$a++?"":"$1 NEW TEXT\n"/es'
Martien
--
|
Martien Verbruggen | Useful Statistic: 75% of the people make up
Trading Post Australia | 3/4 of the population.
|
------------------------------
Date: Fri, 7 Feb 2003 02:54:52 +0000 (UTC)
From: Pierre Asselin <pa@panix.com>
Subject: Re: LWP multipart/form-data with content NOT from file
Message-Id: <b1v75s$rie$6@reader1.panix.com>
Richard Gration <richard@zync.co.uk> wrote:
> Does anyone know how to set the content for the file upload bit? I've
> tried using $req->content on the returned ref to Request object, but this
> replaces the entire contents of the POST. Any ideas anyone??
I no longer do this stuff, but I remember having to look at superclasses
of things like HTTP::Request to find all their accessors. IIRC check
HTTP::Message.
------------------------------
Date: Thu, 06 Feb 2003 22:43:44 -0600
From: Anthony Saffer <anthonysaffer@NOSPAM.yahoo.com>
Subject: Need a bit of help with LWP
Message-Id: <m7e64vs2urlvpfkncdge26k7bdig0um251@4ax.com>
Hello Everyone,
My wife has asked me to write her a small script to help her keep
track of several websites she manages. Basically, the script will be
set on a cron job and will visit each page (url listed in a text
file), go line by line through the page text, and use regular
expressions to extract certain information from the page (url's
mostly). Is there a way to search the page without having to download
it with the getstore() method? How would you accomplish this goal?
Thanks for help in advance!
Anthony
------------------------------
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 4526
***************************************