[24782] in Perl-Users-Digest
Perl-Users Digest, Issue: 6935 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 30 21:06:17 2004
Date: Mon, 30 Aug 2004 18:05:06 -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 Mon, 30 Aug 2004 Volume: 10 Number: 6935
Today's topics:
email parsing->mysql:: Can someone explain me this perl (albatroz)
Re: email parsing->mysql:: Can someone explain me this <tadmc@augustmail.com>
Re: Execute Windows program from Perl script (??) <zebee@zip.com.au>
Re: how many days ago is 2003-07-20 ? <emschwar@pobox.com>
Matching neighbouring words of a pattern using Regex <cv@nospamadelphia.net>
Re: Matching neighbouring words of a pattern using Rege <noreply@gunnar.cc>
Re: Matching neighbouring words of a pattern using Rege <tadmc@augustmail.com>
Re: Matching neighbouring words of a pattern using Rege (Charles DeRykus)
NEWBIE CGI HELP::Can I verify a user has logged on <joeblow@nospam.com>
Re: NEWBIE CGI HELP::Can I verify a user has logged on <matternc@comcast.net>
Re: newbie question <tadmc@augustmail.com>
Re: Object Oriented programs, Perl and others (Daniel Berger)
Re: Object Oriented programs, Perl and others <tassilo.von.parseval@rwth-aachen.de>
Re: OS/2 port of Perl 5.8 not adding CR to \n <nospam-abuse@ilyaz.org>
output image & cookie together <ardel26.1btd87@news.webfrustration.com>
problems with MIME:Lite timeout (dan baker)
Re: problems with MIME:Lite timeout <noreply@gunnar.cc>
Re: two's compliment? (Greg Bacon)
Re: two's compliment? <matternc@comcast.net>
use warnings; and use Warnings; give different results (Ted Sung)
Re: use warnings; and use Warnings; give different resu <spamtrap@dot-app.org>
What do the &= and &&= operators do? (Xevo)
Re: What do the &= and &&= operators do? <mritty@gmail.com>
Re: Xah Lee's Unixism <usemyfullname@hotmail.com>
Re: Xah Lee's Unixism <spam@mouse-potato.com>
Re: Xah Lee's Unixism (Rob Warnock)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 30 Aug 2004 11:20:50 -0700
From: alejandro.lengua@gmail.com (albatroz)
Subject: email parsing->mysql:: Can someone explain me this perl script?
Message-Id: <1350f9d9.0408301020.6e8f2f39@posting.google.com>
I am a perl noob that can learn if you give me a hand.
I currently need a script to read emails using email piping,
extract some information and put it inside a MySQL database.
The reason? Make some statistics of my email server antivirus.
The sample body of my emails is as follows:
-----------------> Source of Sample email source <---------
From: "MailScanner" <postmaster@mydomain.com>
To: postmaster@mail.mydomain.com
Subject: Advertencia: Virus detectado en e-mail
Message-Id: <E1C1YEW-000372-5g@mail.mydomain.com>
Date: Sun, 29 Aug 2004 17:33:08 -0500
Body:
Se han encontrado virus en el siguiente e-mail:
Sender: noreply@mydomain.org.pe
IP Address: 200.106.12.141.22214
Recipient: mipersona@mydomain.org.pe
Subject: RETURNED MAIL: SEE TRANSCRIPT FOR DETAILS
MessageID: 1C1YEL-0002Zn-VA
Informe: message.zip contains Worm.Mydoom.M
-----------------> Source of Sample email source <---------
For this purpose I got this script (called amavistat), however
I need that someone tells me what modifications should I do to
to make it work in my case, here I am attaching the source of
the script
#!/usr/bin/perl
# Veghead 2001
# Fixed stupid '=' vs 'eq' bug - Veghead 2003-08-14
#
# changes 18.08.03 - Marcus Schopen <marcus@localguru.de>
use DBD::mysql;
$server='localhost';
$dbname='amavistat';
$table='virus';
$username='xxx';
$password='xxx';
$state="inheader";
$dbh=DBI->connect("DBI:mysql:$dbname:$server",$username,$password) or
die("Can't connect to MySQL");
$state="inheader";
while(<>) {
chomp;
if ($state eq "inheader") {
if (length($_)<2) {$state="inbody";}
elsif ($_=~/^Subject: VIRUS FROM <(.*)> \((.*)\)/) {
$virusfrom=$1;
$viruses=$2;
$viruswarn++;
}
} elsif ($state="inbody") {
if ($_=~/^-> <([^\@]+\@[^\@]+)>/) {
$virusto=$1;
if ($viruswarn) {do_something();}
}
}
}
sub do_something {
foreach $vname ($viruses) {
print "From: $virusfrom\nTo: $virusto\nVirus: $vname\n\n";
$sth = $dbh->prepare("insert into $table values
(0,now(),'$virusfrom','$virusto',
'$vname')");
$sth->execute;
$sth->finish;
}
}
------------------------------
Date: Mon, 30 Aug 2004 18:54:10 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: email parsing->mysql:: Can someone explain me this perl script?
Message-Id: <slrncj7fh2.keh.tadmc@magna.augustmail.com>
albatroz <alejandro.lengua@gmail.com> wrote:
> For this purpose I got this script (called amavistat), however
> I need that someone
^^^^^^^
^^^^^^^
> # Veghead 2001
> # changes 18.08.03 - Marcus Schopen <marcus@localguru.de>
Ask Veghead or Marcus, it is their (amateurish looking) program.
If they won't help, then you will need to learn some Perl
before you will be able to modify the Perl program.
What part of the program you posted are you having trouble figuring out?
If you tell us where you are stuck, we can probably help unstick you.
If you don't understand any of the parts, then go off and learn
Perl until you do, then come back here with any remaining questions.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 30 Aug 2004 20:45:22 GMT
From: Zebee Johnstone <zebee@zip.com.au>
Subject: Re: Execute Windows program from Perl script (??)
Message-Id: <slrncj744d.ck0.zebee@zeus.zipworld.com.au>
In comp.lang.perl.misc on 30 Aug 2004 09:31:21 -0700
Randal L. Schwartz <merlyn@stonehenge.com> wrote:
> *** post for FREE via your newsreader at post.newsfeed.com ***
>
>>>>>> "Zebee" == Zebee Johnstone <zebee@zip.com.au> writes:
>
>Zebee> I think that attitude of many perlprogs is why learn.perl.org was
>Zebee> started. The people there *want* folk to program in perl and are
>Zebee> willing to help them learn to do so.
>
> And here too. I dare you to show me one posting where a well-reasoned
> question is posted with relevant info that isn't answered in a FAQ, that
> doesn't get a serious answer in response.
>
I don't think that's really the point.
It might be if you are newsgroup experienced, and have a good idea what
you want and how to ask it.
But I think most people are lost and really dont' understand what to ask
yet. If they see 10 posts being bastards for every reasonable one, then
they are going to think "people are bastards", not reason out why one
gets one style and one gets another.
Intellectually lazy quite probably, human nature definitely.
Whereas a forum that educates politely is probably going to get more of
it across. Most people don't have the time or energy to do that, so a
place which has as its *reason* that style of education is a good thing.
I've been around long enough that I know the drill, and enough of a
thick skin to be able to say "I don't understand, please explain more".
It is possible that bitchiness will teach people that, I dunno it's so.
I would certainly prefer that everyone works hard themselves before
getting other people to do it for them, but I am also aware that many
people simply don't have the intellectual tools, they've never really
been taught *how* to think. I dunno clpm is the right place for them to
learn that, learn.perl.org, with the ethos of doing just that, might
well be.
It's certainly a less intimidating place to ask simple questions that
you can't answer for yourself even after reading the docs. ONe of the
hardest thing in the world, especially when confronted by heaps of
people who clearly know it all more or less and toss around line noise
they say is perlcode, is to say you don't understand some more basic
things, especially if you don't quite see what you don't know.
I'd rather people got help than not, pretty much.
Zebee
------------------------------
Date: Mon, 30 Aug 2004 18:11:10 GMT
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: how many days ago is 2003-07-20 ?
Message-Id: <etou0uk8pje.fsf@wilson.emschwar>
Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
> Anno Siegel wrote:
>> It would be necessary to describe exactly what DST may do and what
>> not (and to make sure that all local implementations of DST comply)
>> to establish the validity of the method. That is not trivial.
>
> Can you point me to the corresponding descriptions for Date::Calc and
> Date::Manip?
Frankly, I like using Date::Calc because it's trivially obvious what
it does, and I don't have to work out whether some yobbo on the
Internet wrote a date-diff function properly or not. :) The fact that
it does all sorts of other things, including diffs between date/time
pairs, is a nice bonus.
> I can't understand why you are trying to turn this trivial task into
> rocket science. You are reasoning as if it was a general purpose
> date/time module or a calendar app.
You're right, there's no reason I *couldn't* write such a function (or
just use yours) but I have absolutely no motivation to, given that
Date::Calc exists, and is relatively fast and easy to use.
-Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Mon, 30 Aug 2004 15:45:58 -0400
From: "CV" <cv@nospamadelphia.net>
Subject: Matching neighbouring words of a pattern using Regex
Message-Id: <S7OdnYSjY_-DGa7cRVn-iQ@adelphia.com>
How can I match 'n' number of neighbouring words of a pattern using regular
expressions?
For example, suppose I am looking for the pattern "length xyz cm" in some
text. where xyz is a number - integer or fraction or decimal point. How can
I also grab about 3-5 words on either side of the pattern "length xyz cm"?
The surrounding words are not always constant & may be variable. Also, the
original text to be matched is not just a single sentence, but lines from a
file concatenated together - so the text has many newline characters too. I
only want the words on the same line as the pattern.
I have tried using regex of the form
/\b(\w*)\b(\w*)\b(\w*)\b($pattern)\b(\w*)\b(\w*)\b(\w*), but this doesn't
work for some reason. Could someone please offer some suggestions?
thanks!
------------------------------
Date: Tue, 31 Aug 2004 00:09:34 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Matching neighbouring words of a pattern using Regex
Message-Id: <2phn2tFkp100U1@uni-berlin.de>
[ Reply not posted to the defunct group comp.lang.perl ]
CV wrote:
> How can I match 'n' number of neighbouring words of a pattern using
> regular expressions?
>
> For example, suppose I am looking for the pattern "length xyz cm"
> in some text. where xyz is a number - integer or fraction or
> decimal point. How can I also grab about 3-5 words on either side
> of the pattern "length xyz cm"? The surrounding words are not
> always constant & may be variable. Also, the original text to be
> matched is not just a single sentence, but lines from a file
> concatenated together - so the text has many newline characters
> too. I only want the words on the same line as the pattern.
>
> I have tried using regex of the form
> /\b(\w*)\b(\w*)\b(\w*)\b($pattern)\b(\w*)\b(\w*)\b(\w*), but this
> doesn't work for some reason.
It doesn't work for several reasons, such as:
- No space characters.
- '\w*\b\w*' is an impossible combination that can never match (check
out the description of \b in "perldoc perlre" to learn why).
- The \w character class does not include e.g. the '$' character,
while you mentioned that a "word" may be a variable.
> Could someone please offer some suggestions?
Try something like this:
/((?:\S+ +){0,3})\b($pattern)\b((?: +\S+){0,3})/
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 30 Aug 2004 18:39:14 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Matching neighbouring words of a pattern using Regex
Message-Id: <slrncj7el2.keh.tadmc@magna.augustmail.com>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> - '\w*\b\w*' is an impossible combination that can never match
It will match any string with at least one \w character in it:
$_ = 'hi';
print "matched '$&'\n" if /\w*\b\w*/;
> (check
> out the description of \b in "perldoc perlre" to learn why).
Check out this part too:
... counting the imaginary characters off the
beginning and end of the string as matching a \W
:-)
\W could be the beginning of string in the OP's regex.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 31 Aug 2004 00:27:35 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Matching neighbouring words of a pattern using Regex
Message-Id: <I3ABxz.HrA@news.boeing.com>
In article <S7OdnYSjY_-DGa7cRVn-iQ@adelphia.com>,
CV <cv@nospamadelphia.net> wrote:
>How can I match 'n' number of neighbouring words of a pattern using regular
>expressions?
>
>For example, suppose I am looking for the pattern "length xyz cm" in some
>text. where xyz is a number - integer or fraction or decimal point. How can
>I also grab about 3-5 words on either side of the pattern "length xyz cm"?
>The surrounding words are not always constant & may be variable. Also, the
>original text to be matched is not just a single sentence, but lines from a
>file concatenated together - so the text has many newline characters too. I
>only want the words on the same line as the pattern.
>
>I have tried using regex of the form
>/\b(\w*)\b(\w*)\b(\w*)\b($pattern)\b(\w*)\b(\w*)\b(\w*), but this doesn't
>work for some reason. Could someone please offer some suggestions?
>
You may be confused about the \b assertion. Did you intend for
something with \w and \W..? Also, what if the pattern falls
at the beginning or end of the line... do you want to capture
the patterns that may not have 3-5 surrounding words?
One possibility presuming you intend to capture 3-5 surrounding
words:
my $text = "...";
my $pattern = 'length ... cm ';
my $words = '(?:\w+[^\w\n]+){3,5}';
#my $words = '(?:\w+[^\w\n]+){0,5}'; # to catch every pattern
print $1 while /($words$pattern$words)/g;
[ Note the 3-5 surrounding words may consume another
adjacent $pattern instance but you don't specify what
to do in that case. }
hth,
--
Charles DeRykus
------------------------------
Date: Mon, 30 Aug 2004 18:24:17 GMT
From: "joe slash blow" <joeblow@nospam.com>
Subject: NEWBIE CGI HELP::Can I verify a user has logged on
Message-Id: <I39v4C.MH1@news.boeing.com>
I have very basic Perl knowledge and inherited a script for work.
If the user inputs a specific 4 character code in one of 3 places on a web
page, I have to verify that the user has logged onto an NT domain account
before I let them go to the next html page. If they don't use the 4
character code they can go on unchecked.
I don't want them to have to log on to the perl page, just verify that they
are logged onto the system.
Any help would be greatly appreciated.
T:I:A!
- D a r y l
------------------------------
Date: Mon, 30 Aug 2004 17:00:52 -0400
From: Chris Mattern <matternc@comcast.net>
Subject: Re: NEWBIE CGI HELP::Can I verify a user has logged on
Message-Id: <tJOdnd5-Re0ZCK7cRVn-gA@comcast.com>
joe slash blow wrote:
> I have very basic Perl knowledge and inherited a script for work.
> If the user inputs a specific 4 character code in one of 3 places on a web
> page, I have to verify that the user has logged onto an NT domain account
> before I let them go to the next html page. If they don't use the 4
> character code they can go on unchecked.
> I don't want them to have to log on to the perl page, just verify that
> they are logged onto the system.
> Any help would be greatly appreciated.
>
Er, how do you determine which NT user he's supposed to be? Does the
four character code ID him? Can you determine it from his IP address?
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
------------------------------
Date: Mon, 30 Aug 2004 19:01:16 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: newbie question
Message-Id: <slrncj7fuc.keh.tadmc@magna.augustmail.com>
soulshriek <mij@soulshiiek.com> wrote:
> i just started learning perl 2 days ago.
Have you seen the Posting Guidelines that are posted here frequently?
> but when i change
>
> until ($var == 1.2) into until ($var == 1.1)
>
> something strange happens
^^^^^^^^^^^^^^^^^
That information does not help us solve your problem.
A careful description of the symptoms is required if you expect
a reasonably accurate diagnosis.
What does "something strange" mean when you say it?
What did you observe that was "strange"?
Don't make us guess...
> could someone please explain this to me, i like to know why stuff happens
> because everything happens for a reason
To see what is happening, print the output like this instead:
printf "%30.20f\n", $var;
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 30 Aug 2004 13:08:41 -0700
From: djberg96@hotmail.com (Daniel Berger)
Subject: Re: Object Oriented programs, Perl and others
Message-Id: <6e613a32.0408301208.3b1ba288@posting.google.com>
Matthew Braid <mb@uq.net.au.invalid> wrote in message news:<cgttbd$hof$1@bunyip.cc.uq.edu.au>...
<snip>
> I'm beginning to get a little worried about perl6 - from what I've seen on its
> development it seems to be more and more driven on "hey, wouldn't it be cool if
> we could do this" or "look, I've defined yet another way to do X" and less and
> less on "this is a concise, non-ambiguous way of doing X". Hopefully I've just
> been looking in the wrong place.
>
> MB
No, you haven't been looking in the wrong place - you're spot on.
This is why I recommended at least considering Ruby or Python.
Regards,
Dan
------------------------------
Date: Mon, 30 Aug 2004 22:43:08 +0200
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: Object Oriented programs, Perl and others
Message-Id: <2phhquFkvb6uU1@uni-berlin.de>
Also sprach Daniel Berger:
> Matthew Braid <mb@uq.net.au.invalid> wrote in message news:<cgttbd$hof$1@bunyip.cc.uq.edu.au>...
><snip>
>
>> I'm beginning to get a little worried about perl6 - from what I've seen on its
>> development it seems to be more and more driven on "hey, wouldn't it be cool if
>> we could do this" or "look, I've defined yet another way to do X" and less and
>> less on "this is a concise, non-ambiguous way of doing X". Hopefully I've just
>> been looking in the wrong place.
>>
>> MB
>
> No, you haven't been looking in the wrong place - you're spot on.
> This is why I recommended at least considering Ruby or Python.
Do this recommendation once Perl6 has been seen in the wild. Such
statements are of no use today where all we have are those documents
describing the differences.
It's really just a case of contorted perception that everyting will be
new in Perl6. It's just so that no one bothered to list the stuff Perl5
and Perl6 will have in common.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Mon, 30 Aug 2004 18:36:13 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: OS/2 port of Perl 5.8 not adding CR to \n
Message-Id: <cgvs2t$2nst$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Shmuel (Seymour J.) Metz
<spamtrap@library.lspace.org.invalid>], who wrote in article <41336516$2$fuzhry+tra$mr2ice@news.patriot.net>:
> >Hint: a bug report
>
> I wanted to first confirm that I had installed the correct version.
"Correct"???
> >But trying to read your mind: are you using syswrite()?
> Print, with the default (STDOUT) file handle. Does that go through
> syswrite?
Only syswrite() "goes through syswrite()".
> If this is indeed the correcxt version, do I report the bug to CPAN?
What bug?
Hope this helps,
Ilya
------------------------------
Date: Tue, 24 Aug 2004 11:06:22 +0100
From: ardel26 <ardel26.1btd87@news.webfrustration.com>
Subject: output image & cookie together
Message-Id: <ardel26.1btd87@news.webfrustration.com>
error message
--
ardel26
------------------------------
Date: 30 Aug 2004 13:33:59 -0700
From: botfood@yahoo.com (dan baker)
Subject: problems with MIME:Lite timeout
Message-Id: <13685ef8.0408301233.4b5e369f@posting.google.com>
I am trying to build a simple little script using MIME:Lite to run
through about 200 email addresses and send a simple text message. I
seem to be having a problem with a timeout as it gets though 5 or ten
addresses and then quits with the message:
Failed to connect to mail server: Bad file descriptor
I have tried sending a 'hello' every time, but that doesn't seem to
change the behavior....
I am running perl from ActiveState precompiled for windows98 on a PC,
and attempting to send via SMTP thru my server. I am wondering if
there is any way to disconnect and reconnect every 5 addresses or
something like that?
here is a snippet, with some error checking removed for brevity:
foreach $Recipient ( @tempList ) {
$First_Name = '';
$Last_Name = '';
$email = '';
$MarriedName = '';
# split the raw CSV textline
if ( $Recipient =~ m/"(.*)","(.*)","(.*)","(.*)"/ ) {
$First_Name = $1 ;
$Last_Name = $2 ;
$email = $3 ;
$MarriedName = $4 ;
}
$Recipient = "$First_Name $Last_Name";
if ( $MarriedName ) { $Recipient .= "-$MarriedName" }
$Recipient = "\"$Recipient\"\<$email\>";
# handshake server again
MIME::Lite->send('smtp', $cSMTPserver ,
Hello=>$cSMTPserver , Timeout=>60 );
# send mail
# -----
$msg='';
$msg = MIME::Lite->new(
From => $Sender ,
To => $Recipient ,
Subject => $Subject ,
Type => $Type ,
Data => $Body
);
unless ( $msg->send() ) { # send it now
print "...send FAILED \n\n";
}
}
------------------------------
Date: Tue, 31 Aug 2004 00:18:17 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: problems with MIME:Lite timeout
Message-Id: <2phnjcFl98osU1@uni-berlin.de>
dan baker wrote:
> I am trying to build a simple little script using MIME:Lite to run
> through about 200 email addresses and send a simple text message. I
> seem to be having a problem with a timeout as it gets though 5 or
> ten addresses and then quits with the message:
> Failed to connect to mail server: Bad file descriptor
Sounds like a server configuration thing to me.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 30 Aug 2004 19:16:57 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: two's compliment?
Message-Id: <10j6v99av47bs36@corp.supernews.com>
In article <2ph7a3Fkssj2U1@uni-berlin.de>,
187 <bigal187.invalid@adexec.com> wrote:
: I'm hoping someone can clear up this little confusion here regarding
: binary not's.
:
: print unpack('H128', pack('N', ~4294966272));
:
: This gives: 000003ff
:
: Why is it on my TI86 I get FFFFFFFF000003FF. This seems more
: (Commands: (not 4294966272)->Hex )
:
: Which is correct? It seems more correct to me that the remaining bits
: be flipped from the not operation (0 -> 1), but why do c/c++/perl/etc
: not do this?
The perlfunc manpage's documentation for pack has the following
excerpt:
n An unsigned short in "network" (big-endian) order.
N An unsigned long in "network" (big-endian) order.
v An unsigned short in "VAX" (little-endian) order.
V An unsigned long in "VAX" (little-endian) order.
(These 'shorts' and 'longs' are _exactly_ 16 bits and
_exactly_ 32 bits, respectively.)
You're expecting 64-bit quantities, so you have to work a little
harder:
$ cat try
#! /usr/local/bin/perl
use warnings;
use strict;
BEGIN {
use Config;
*bequad = eval($Config{use64bitint} ? <<'EOHave64' : <<'EOStub');
sub {
my $val = shift;
{
no warnings "portable"; # 64-bit hex constants
pack(N => ($val & 0xFFFFFFFF00000000) >> 32) .
pack(N => $val & 0x00000000FFFFFFFF);
}
}
EOHave64
sub { die "quads not supported in this perl" }
EOStub
}
my $bits = ~4294966272;
my $hex = unpack "H*", bequad $bits;
print $hex, "\n";
$ ./try
ffffffff000003ff
Hope this helps,
Greg
--
It is incumbent on every generation to pay its own debts as it goes. A
principle which if acted on would save one-half the wars of the world.
-- Thomas Jefferson
------------------------------
Date: Mon, 30 Aug 2004 17:08:44 -0400
From: Chris Mattern <matternc@comcast.net>
Subject: Re: two's compliment?
Message-Id: <XPydnSQyfZTDCq7cRVn-iQ@comcast.com>
187 wrote:
> I'm hoping someone can clear up this little confusion here regarding
> binary not's.
>
> print unpack('H128', pack('N', ~4294966272));
>
> This gives: 000003ff
>
> Why is it on my TI86 I get FFFFFFFF000003FF. This seems more
> (Commands: (not 4294966272)->Hex )
>
> Which is correct?
The TI, of course.
> It seems more correct to me that the remaining bits be
> flipped from the not operation (0 -> 1), but why do c/c++/perl/etc not
> do this?
Because there *aren't* any "remaining bits". The computer
you're working on has 4-byte integers, and you overflowed
it--the number is too big for your data model. The
TI, with 8-byte integers, was plenty big enough to
hold your number. Look up the documentation for pack
and unpack on how to specify 8-byte integers. You
wanted to say 'Q', not 'N' (and that'll only work if you
have 64-bit support).
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
------------------------------
Date: 30 Aug 2004 13:09:03 -0700
From: teds@intex.com (Ted Sung)
Subject: use warnings; and use Warnings; give different results
Message-Id: <86dea8f5.0408301209.6b493ae7@posting.google.com>
D:\perl_scripts>perl -v
This is perl, v5.6.1 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
I have the following simple/trivial script, test.pl:
use strict;
use Warnings;
use Cwd;
When I run this as perl -w test.pl, I get the following:
D:\perl_scripts>perl -w test2.pl
Subroutine bits redefined at d:/perl/lib/warnings.pm line 285.
Subroutine import redefined at d:/perl/lib/warnings.pm line 304.
Subroutine unimport redefined at d:/perl/lib/warnings.pm line 314.
Subroutine __chk redefined at d:/perl/lib/warnings.pm line 325.
Subroutine enabled redefined at d:/perl/lib/warnings.pm line 373.
Subroutine warn redefined at d:/perl/lib/warnings.pm line 386.
Subroutine warnif redefined at d:/perl/lib/warnings.pm line 400.
Strangely, if I change the upper case 'W' to w so the script is like
this:
use strict;
use warnings;
use Cwd;
I don't see these warnings.
Also, if I remove the 'use Cwd;' line, I don't get any warnings
regardless of the case of 'W'.
What is going on here?
Thanks,
Ted
------------------------------
Date: Mon, 30 Aug 2004 18:22:19 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: use warnings; and use Warnings; give different results
Message-Id: <z9OdnQ3JQ6wGNa7cRVn-vA@adelphia.com>
Ted Sung wrote:
> D:\perl_scripts>perl -v
> This is perl, v5.6.1 built for MSWin32-x86-multi-thread
> (with 1 registered patch, see perl -V for more detail)
>
> I have the following simple/trivial script, test.pl:
>
> use strict;
> use Warnings;
> use Cwd;
>
> When I run this as perl -w test.pl, I get the following:
>
> D:\perl_scripts>perl -w test2.pl
> Subroutine bits redefined at d:/perl/lib/warnings.pm line 285.
> Subroutine import redefined at d:/perl/lib/warnings.pm line 304.
> Subroutine unimport redefined at d:/perl/lib/warnings.pm line 314.
> Subroutine __chk redefined at d:/perl/lib/warnings.pm line 325.
> Subroutine enabled redefined at d:/perl/lib/warnings.pm line 373.
> Subroutine warn redefined at d:/perl/lib/warnings.pm line 386.
> Subroutine warnif redefined at d:/perl/lib/warnings.pm line 400.
>
> Strangely, if I change the upper case 'W' to w so the script is like
> this:
>
> use strict;
> use warnings;
> use Cwd;
>
> I don't see these warnings.
>
> Also, if I remove the 'use Cwd;' line, I don't get any warnings
> regardless of the case of 'W'.
>
> What is going on here?
Case-insensitive file system. The name of the module as given in the
'use' statement is cached in %INC, so the module only gets parsed once.
The 'Cwd' module has 'use warnings', and in your second example
'warnings.pm' isn't loaded again because you've already loaded it.
In the first example, you (incorrectly) refer to it as Warnings, which
causes perl to read and parse 'Warnings.pm'. When Cwd's 'use warnings'
is found, 'warnings.pm' is loaded. But on a case-insensitive file
system, those are the same file; so you get 'Subroutine ... redefined'
warnings.
Avoid the warnings by correctly spelling the name of the module: It's
'warnings', as in your second example.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: 30 Aug 2004 12:39:34 -0700
From: x3v0-usenet@yahoo.com (Xevo)
Subject: What do the &= and &&= operators do?
Message-Id: <359b5621.0408301139.67816239@posting.google.com>
I can not find any information on what the "and equal" operators &=
and &&= do. I looked in the 'Programming Perl' book, searched
perldoc.com, and tried to google it, but to no avail. Can anyone fill
me in on how to use these strange operators?
------------------------------
Date: Mon, 30 Aug 2004 19:58:31 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: What do the &= and &&= operators do?
Message-Id: <HFLYc.18593$qY.3820@trndny05>
"Xevo" <x3v0-usenet@yahoo.com> wrote in message
news:359b5621.0408301139.67816239@posting.google.com...
> I can not find any information on what the "and equal" operators &=
> and &&= do. I looked in the 'Programming Perl' book, searched
> perldoc.com, and tried to google it, but to no avail. Can anyone fill
> me in on how to use these strange operators?
From perldoc perlop:
Assignment operators work as in C. That is,
$a += 2;
is equivalent to
$a = $a + 2;
although without duplicating any side effects that
dereferencing the lvalue might trigger, such as from tie().
Other assignment operators work similarly. The following
are recognized:
**= += *= &= <<= &&=
-= /= |= >>= ||=
.= %= ^=
x=
All operators of the form OP= have the same expansion form. So $x &= $y
is equivalent to $x = $x & $y, which means to take the bitwise and of
the two values $x and $y, and put the result back in $x. Similarly, $x
&&= $y is equivalent to $x = $x && $y, which means to take the logical
conjunction of the values $x and $y, and put the result back in $x.
Paul Lalli
------------------------------
Date: Mon, 30 Aug 2004 19:25:37 GMT
From: Antony Sequeira <usemyfullname@hotmail.com>
Subject: Re: Xah Lee's Unixism
Message-Id: <41337FC9.8070902@hotmail.com>
Andre Majorel wrote:
> On 2004-08-28, Rob Warnock <rpw3@rpw3.org> wrote:
>
>>Pascal Bourguignon <spam@mouse-potato.com> wrote:
>>+---------------
>>| $ telnet xahlee.org 80;
>>| Trying 208.186.130.4...
>>| Connected to xahlee.org.
>>| Escape character is '^]'.
>>| GET / HTTP/1.1
>>|
>>| HTTP/1.1 400 Bad Request
>>| Date: Fri, 27 Aug 2004 01:35:52 GMT
>>| Server: Apache/2.0.50 (Fedora)
>>| ^^^^^^^^^^^^^^^^^^^^^^
>>+---------------
>>
>>So are you complaining about the fact that his hosting provider
>>preloaded RedHat Fedora with Apache 2.0 for him?
>
>
> There is no shortage of Windows-based hosting companies, so why
> didn't he go there ? Whatever your opinions, it's best to put
> your money where your mouth is if you expect to be taken
> seriously.
>
Windows (MS) is not 'Unixism'?
-Antony
------------------------------
Date: 31 Aug 2004 01:15:18 +0200
From: Pascal Bourguignon <spam@mouse-potato.com>
Subject: Re: Xah Lee's Unixism
Message-Id: <87wtzgmd4p.fsf@thalassa.informatimago.com>
Antony Sequeira <usemyfullname@hotmail.com> writes:
> Windows (MS) is not 'Unixism'?
It's VMS'ism !
--
__Pascal Bourguignon__ http://www.informatimago.com/
Our enemies are innovative and resourceful, and so are we. They never
stop thinking about new ways to harm our country and our people, and
neither do we.
------------------------------
Date: Mon, 30 Aug 2004 19:19:04 -0500
From: rpw3@rpw3.org (Rob Warnock)
Subject: Re: Xah Lee's Unixism
Message-Id: <H7SdnZC1jO1lXq7cRVn-pg@speakeasy.net>
Pascal Bourguignon <spam@mouse-potato.com> wrote:
+---------------
| Antony Sequeira <usemyfullname@hotmail.com> writes:
| > Windows (MS) is not 'Unixism'?
|
| It's VMS'ism !
+---------------
Well, originally, certainly, in the core of the kernel.
But there are plenty enough "Unixisms" in the rest of it!
[Go re-read "Worse is Better", then see if you don't agree...]
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607
------------------------------
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 6935
***************************************