[26408] in Perl-Users-Digest
Perl-Users Digest, Issue: 8579 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 27 18:05:36 2005
Date: Thu, 27 Oct 2005 15:05:10 -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 Thu, 27 Oct 2005 Volume: 10 Number: 8579
Today's topics:
FAQ 3.23 How can I get "#!perl" to work on [MS-DOS,NT,. <comdog@pair.com>
Mail::Audit help plz <rob@nowhere.com>
Unintuitive expression evaluation <davidsen@deathstar.prodigy.com>
Re: Unintuitive expression evaluation <1usa@llenroc.ude.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 27 Oct 2005 22:03:01 +0000 (UTC)
From: PerlFAQ Server <comdog@pair.com>
Subject: FAQ 3.23 How can I get "#!perl" to work on [MS-DOS,NT,...]?
Message-Id: <djriql$69c$1@reader2.panix.com>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.
--------------------------------------------------------------------
3.23: How can I get "#!perl" to work on [MS-DOS,NT,...]?
For OS/2 just use
extproc perl -S -your_switches
as the first line in "*.cmd" file ("-S" due to a bug in cmd.exe's
"extproc" handling). For DOS one should first invent a corresponding
batch file and codify it in "ALTERNATE_SHEBANG" (see the dosish.h file
in the source distribution for more information).
The Win95/NT installation, when using the ActiveState port of Perl, will
modify the Registry to associate the ".pl" extension with the perl
interpreter. If you install another port, perhaps even building your own
Win95/NT Perl from the standard sources by using a Windows port of gcc
(e.g., with cygwin or mingw32), then you'll have to modify the Registry
yourself. In addition to associating ".pl" with the interpreter, NT
people can use: "SET PATHEXT=%PATHEXT%;.PL" to let them run the program
"install-linux.pl" merely by typing "install-linux".
Under "Classic" MacOS, a perl program will have the appropriate Creator
and Type, so that double-clicking them will invoke the MacPerl
application. Under Mac OS X, clickable apps can be made from any "#!"
script using Wil Sanchez' DropScript utility:
http://www.wsanchez.net/software/ .
*IMPORTANT!*: Whatever you do, PLEASE don't get frustrated, and just
throw the perl interpreter into your cgi-bin directory, in order to get
your programs working for a web server. This is an EXTREMELY big
security risk. Take the time to figure out how to do it correctly.
--------------------------------------------------------------------
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-2002 Tom Christiansen and Nathan
Torkington, and other contributors as noted. All rights
reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
------------------------------
Date: Thu, 27 Oct 2005 20:26:16 GMT
From: Rob <rob@nowhere.com>
Subject: Mail::Audit help plz
Message-Id: <IJa8f.8645$tV6.3915@newssvr27.news.prodigy.net>
Hi,
I've installed the Mail::Audit (ver 2.1) perl module
to my home directory as non-root user & I get a problem.
here's my .forward:
|/home/rob/bin/forward_email
here's the forward_email:
#!/usr/bin/perl -w
BEGIN{
unshift @INC, '/home/rob/lib/lib/perl5/site_perl/5.8.3'
}
$\ = "\n";
select(STDERR); $| = 1;
select(STDOUT); $| = 1;
use Mail::Audit;
my $mail = Mail::Audit->new(emergency=>"/home/rob/emergency_mbox");
my $from = $mail->from();
my $to = $mail->to();
my $subject = $mail->subject();
chomp($from, $to, $subject);
open(LOG, ">> /home/rob/mynewmail.log");
print LOG "from is $from";
print LOG "to is $to";
print LOG "subj is $subject";
close(LOG);
$mail->accept('/home/rob/dead.lettters');
However, nothing is written to mynewmail.log. Plus the first line
of the dead.lettters is:
From root@localhost Wed Oct 26 16:06:27 2005
<<and then we have the body of the mail here>>
In addition, this email is sent back to the user:
This message was created automatically by mail delivery software.
A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:
pipe to |/home/rob/bin/forward_email
generated by rob@domainname.com
The following text was generated during the delivery attempt:
------ pipe to |/home/rob/bin/forward_email
generated by rob@domainname.com ------
Use of uninitialized value in pattern match (m//) at /home/rob/lib/lib/perl5/site_perl/5.8.3/Mail/Audit.pm line 431.
------ This is a copy of the message, including all the headers. ------
<<the headers + body of email is here>>
Has anyone seen this problem? What do you think I should do?
--Rob
------------------------------
Date: Thu, 27 Oct 2005 20:30:10 GMT
From: Bill Davidsen <davidsen@deathstar.prodigy.com>
Subject: Unintuitive expression evaluation
Message-Id: <mNa8f.3023$Y61.1523@newssvr33.news.prodigy.com>
I am reading a log file which has 32 bit unsigned values, and need to
take the difference between them. If the difference is negative I assume
that the data counter has rolled over, and I want to add 231 to get the
correct value. For readability I wanted to put the value in a variable
so it would be obvious what was happening.
So I wrote:
$Roll32 = (1 << 32); # the way I would for a C macro
but the value was (after I did some looking) one! Then I wrote:
$Roll32 = 1 << 32; # in case the parens were a issue
bit it was still one, so I wrote:
$Roll32 = ( 4 * (1 << 30) ); # which works (4G)
This is the first time perl has failed to do int=>double conversion when
expected (by me). Just a note in case someone else is ever doing
similar, perl on Linux 32 bit, v5.6.1, v5.8.0, v5.8.5 builds.
--
bill davidsen
SBC/Prodigy Yorktown Heights NY data center
http://newsgroups.news.prodigy.com
------------------------------
Date: Thu, 27 Oct 2005 20:37:50 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Unintuitive expression evaluation
Message-Id: <Xns96FCA930B77D2asu1cornelledu@127.0.0.1>
Bill Davidsen <davidsen@deathstar.prodigy.com> wrote in
news:mNa8f.3023$Y61.1523@newssvr33.news.prodigy.com:
> I am reading a log file which has 32 bit unsigned values, and need to
> take the difference between them. If the difference is negative I
> assume that the data counter has rolled over, and I want to add 231 to
> get the correct value. For readability I wanted to put the value in a
> variable so it would be obvious what was happening.
>
> So I wrote:
> $Roll32 = (1 << 32); # the way I would for a C macro
> but the value was (after I did some looking) one! Then I wrote:
> $Roll32 = 1 << 32; # in case the parens were a issue
> bit it was still one, so I wrote:
> $Roll32 = ( 4 * (1 << 30) ); # which works (4G)
>
> This is the first time perl has failed to do int=>double conversion
> when expected (by me).
The only thing that failed in this case is you.
> Just a note in case someone else is ever doing
> similar, perl on Linux 32 bit, v5.6.1, v5.8.0, v5.8.5 builds.
You mean "just in case someone else refuses to read the documentation"?
perldoc perlop:
Shift Operators
...
Either way, the implementation isn't going to generate results larger
than the size of the integer type Perl was built with (32 bits or 64
bits).
The result of overflowing the range of the integers is undefined
because it is undefined also in C. In other words, using 32-bit
integers, "1 << 32" is undefined. Shifting by a negative number
of bits is also undefined.
How hard is it to read this, and understand it?
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component andremove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 8579
***************************************