[25500] in Perl-Users-Digest
Perl-Users Digest, Issue: 7744 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 6 14:05:51 2005
Date: Sun, 6 Feb 2005 11:05:22 -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 Sun, 6 Feb 2005 Volume: 10 Number: 7744
Today's topics:
Re: Exception handling in class: question <nobull@mail.com>
Re: explain "Larry expects that he'll be certified..." <tadmc@augustmail.com>
Re: explain "Larry expects that he'll be certified..." <bernie@fantasyfarm.com>
Re: Extracting .jpg from mbox file with MIME::Base64 <zentara@highstream.net>
Re: Extracting .jpg from mbox file with MIME::Base64 <sshears@theWorld.com>
Re: Invisible cache for LWP / Mechanize? <jakob.fix@gmail.com>
Re: Invisible cache for LWP / Mechanize? (Anno Siegel)
Perl - permute? <justsurge@mailcan.com>
Re: Perl - permute? <abigail@abigail.nl>
Re: Perl - permute? <1usa@llenroc.ude.invalid>
Re: Perl - permute? <see_sig@invalid>
Re: Perl - permute? <wksmith@optonline.net>
Re: Perl - permute? charley@pulsenet.com
Re: perl style: can I combine two steps into one? (Anno Siegel)
Re: perl style: can I combine two steps into one? <abigail@abigail.nl>
Perl Versus Python surfunbear@yahoo.com
Re: Perl Versus Python <1usa@llenroc.ude.invalid>
Re: Problem with binary numbers (Anno Siegel)
Re: Problem with binary numbers <tadmc@augustmail.com>
Re: Problem with binary numbers perldude@nospam.com
Re: starting CGi shell script (Anno Siegel)
Re: Why aren't 'warnings' on by default? <abigail@abigail.nl>
Re: Why aren't 'warnings' on by default? <abigail@abigail.nl>
Re: Why aren't 'warnings' on by default? <spam-collector@pense-online.de>
Re: Why aren't 'warnings' on by default? <abigail@abigail.nl>
Re: XML & Perl - Error <bart.lateur@pandora.be>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 Feb 2005 09:30:27 -0800
From: "nobull@mail.com" <nobull@mail.com>
Subject: Re: Exception handling in class: question
Message-Id: <1107711027.528037.188480@g14g2000cwa.googlegroups.com>
Anno Siegel wrote:
> As for your question, it is unclear why you use "eval" at all. It is
not
> the standard error handling mechanism in Perl.
Er, it's one of them.
> If you must use it, make
> its scope as small as possible, that is, treat every case
individually.
I would agree with that.
> Only use it if the exception can't be otherwise anticipated. Don't
catch
> division by zero that way, for instance.
I completely disagree with Anno on that. If you want to cope with the
possibility of numeric overflow you should figure out where it can
happen and wrap that code in eval{}. Trying to anticipate numeric
overflow is inefficient and error promne
> Standard error handling is through the standard module Carp.
The use of Carp is orthogonal to the decision to use an a throw-catch
approach.
> OTOH, if you deliberately want to use "eval" for exception handling,
> take a look at some of the "Exception" modules on CPAN, or write your
> own. Don't use "eval" directly for that.
Out of interest, why?
------------------------------
Date: Sun, 6 Feb 2005 08:27:53 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: explain "Larry expects that he'll be certified..."
Message-Id: <slrnd0cab9.ndf.tadmc@magna.augustmail.com>
Calle Dybedahl <posted@cyberpomo.com> wrote:
>>>>>> "Sherm" == Sherm Pendley <spamtrap@dot-app.org> writes:
>
>> Peter Wyzl wrote:
>>> Think 'certifiably mad'.
>> ...
>>> Think 'Microsoft Certified'
>
>> There's a difference???
>
> Yes, the Microsoft version is much more expensive.
And it requires frequent upgrades.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 06 Feb 2005 12:37:06 -0500
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: explain "Larry expects that he'll be certified..."
Message-Id: <kalc015hq3isl9bi85abioslvg6k40bakq@library.airnews.net>
brandonwalsh_9@hotmail.com (Brandon Walsh) wrote:
} Can someone please explain this quote from perlfaq2: "Larry expects
} that he'll be certified before Perl is."
}
} What does the word "certified" means here?
Two different things. From the online Webster's:
Main Entry: cer·ti·fy
Pronunciation: 's&r-t&-"fI
Function: transitive verb
Inflected Form(s): -fied; -fy·ing
Etymology: Middle English certifien, from Middle French certifier, from
Late Latin certificare, from Latin certus certain -- more at CERTAIN
1 : to attest authoritatively: as a : CONFIRM b : to present in formal
communication c : to attest as being true or as represented or as meeting a
standard d : to attest officially to the insanity of
I suspect that it is 1d for larry and 1c for perl...:o)
/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
bernie@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
------------------------------
Date: Sun, 06 Feb 2005 08:54:03 -0500
From: zentara <zentara@highstream.net>
Subject: Re: Extracting .jpg from mbox file with MIME::Base64
Message-Id: <k07c01tq9vt2lpop0i8v2bp5dnomn9gdf3@4ax.com>
On Fri, 04 Feb 2005 23:43:14 -0500, Sally Shears <sshears@theWorld.com>
wrote:
>Can anyone help me with this... How to extract a .jpg file from an
>attachment in a message in an mbox file?
>
>I'm trying with MIME::Base64 but I'll take any suggestions. Thanks.
>
> -- Sally
#!/usr/bin/perl
use strict;
use IO::File;
use Mail::Message::Attachment::Stripper;
#by Roger of Perlmonks
my $m = Mail::Message::Attachment::Stripper->new($mail);
my @attachments = $m->attachments;
foreach my $a(@attachments) {
next if $a->{content_type} !~ /jpe?g|gif/i;
# ignore non-jpg/gif attachemnts
my $f = new IO::File "/home/$user_folder/" . $a->{filename}, "w" or
die "Can not create file!";
print $f $a->{payload};
}
#There are many ways to do this. I recommend the following
#modules: Mail::Box to manage the mail box and
#Mail::Message::Attachment::Stripper to strip (multiple)
#attachments.
#Batch mode - I would use the powerful Mail::Box module to
#parse each user's mailbox, and for each of the user's mail
#messages, extract the (folder) name of the user from the
#email address line, strip all the attachments with
#Mail::Message::Attachment::Stripper (or similar module),
#and put the attachments into user's folder.
#Procmail mode - When email message comes in, load it into
#a scalar, extract the folder name from email address, and
#use Mail::Message::Attachment::Stripper to strip the
#attachments. You might also want to delete the attachment
#from the original email, just save the email message, and
#append some sort of notice to the modified mail message
#that their mail attachments are saved under their user
#directories.
# load the mail message into $mail
# extract user folder path into $user_folder
#...
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
------------------------------
Date: Sun, 06 Feb 2005 08:55:04 -0500
From: Sally Shears <sshears@theWorld.com>
Subject: Re: Extracting .jpg from mbox file with MIME::Base64
Message-Id: <060220050855047376%sshears@theWorld.com>
In article <040220052343143053%sshears@theWorld.com>, Sally Shears
<sshears@theWorld.com> wrote:
> Can anyone help me with this... How to extract a .jpg file from an
> attachment in a message in an mbox file?
>
> I'm trying with MIME::Base64 but I'll take any suggestions. Thanks.
>
> -- Sally
>
>
> In article <030220052140038558%SallyShears@gmail.com>, Sally Shears
> <SallyShears@gmail.com> wrote:
>
> > I have an email message in an mbox file with a jpg attachment.
> >
> > I want a program I can run with cron or procmail to extract the .jpg
> > attachment from the last message in the mbox. That is, to store the
> > .jpg as a normal file to be served up by Apache.
> >
> > The attachment is encoded base64.
> >
> > I read the whole encoded portion of the mbox file into a character
> > string and then attempt to decode it with MIME::Base64::decode($str)
FWIW, I'm able to do it with mimencode
mimencode -u
..will take the Base64 encoded attachment and give me a .jpg file for
the web server.
-- Sally
------------------------------
Date: 6 Feb 2005 06:54:42 -0800
From: "jfix" <jakob.fix@gmail.com>
Subject: Re: Invisible cache for LWP / Mechanize?
Message-Id: <1107701682.224430.66430@o13g2000cwo.googlegroups.com>
Anno,
Anno Siegel wrote:
> jfix <jakob.fix@gmail.com> wrote in comp.lang.perl.misc:
>
> Please give an attribution.
excuse me, but I don't understand what you mean with this.
> > Gisle,
> > > $ua->default_header( Cache_Control => "no-cache" );
> >
> > you're right, of course, as regards the shortcutting. however,
using
> > strict I cannot use the bareword Cache_Control.
>
> Yes, you can. See "perldoc perldata, look for "=>".
Great! I didn't know that. Thanks,
Jakob.
------------------------------
Date: 6 Feb 2005 16:16:24 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Invisible cache for LWP / Mechanize?
Message-Id: <cu5fso$mdu$1@mamenchi.zrz.TU-Berlin.DE>
jfix <jakob.fix@gmail.com> wrote in comp.lang.perl.misc:
> Anno,
>
> Anno Siegel wrote:
> > jfix <jakob.fix@gmail.com> wrote in comp.lang.perl.misc:
> >
> > Please give an attribution.
>
> excuse me, but I don't understand what you mean with this.
An attribution is a line that identifies the poster of the text you
are replying to. You did give one this time: "Anno Siegel wrote:".
Please see the posting guidelines to this group. They are posted
frequently.
Anno
------------------------------
Date: Sun, 06 Feb 2005 16:57:13 GMT
From: Ej <justsurge@mailcan.com>
Subject: Perl - permute?
Message-Id: <1107709033.0d15271ffc45f8463e1fcde7dddd2c79@bubbanews>
Hi,
How can I take an array (a,b,c,d,e) and list ALL possible [3 LETTER] combos
of these letters, I want the output to look like
abc
acb
aab
aaa
how can I Using perl
Thanks Ej
------------------------------
Date: 06 Feb 2005 17:10:59 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Perl - permute?
Message-Id: <slrnd0cjt3.g2.abigail@alexandra.abigail.nl>
Ej (justsurge@mailcan.com) wrote on MMMMCLXXVII September MCMXCIII in
<URL:news:1107709033.0d15271ffc45f8463e1fcde7dddd2c79@bubbanews>:
`` Hi,
`` How can I take an array (a,b,c,d,e) and list ALL possible [3 LETTER] combos
`` of these letters, I want the output to look like
``
`` abc
`` acb
`` aab
`` aaa
foreach my $i (@array) {
foreach my $j (@array) {
foreach my $k (@array) {
print "$i$j$k\n";
}
}
}
Abigail
--
BEGIN {$^H {q} = sub {pop and pop and print pop}; $^H = 2**4.2**12}
"Just "; "another "; "Perl "; "Hacker\n";
------------------------------
Date: Sun, 06 Feb 2005 17:26:25 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Perl - permute?
Message-Id: <Xns95F57E98D2109asu1cornelledu@127.0.0.1>
Ej <justsurge@mailcan.com> wrote in
news:1107709033.0d15271ffc45f8463e1fcde7dddd2c79@bubbanews:
> Hi,
> How can I take an array (a,b,c,d,e) and list ALL possible [3 LETTER]
> combos of these letters, I want the output to look like
>
> abc
> acb
> aab
> aaa
>
> how can I Using perl
It all begins with using all the goodies available to you.
For the following, I just used the first module CPAN gave me when I
searched for the word 'permute'. I have no idea if it is the best, for
that you will have to do some work yourself.
http://search.cpan.org/~edpratomo/Algorithm-Permute-0.06/Permute.pm
#! /usr/bin/perl
use strict;
use warnings;
use Algorithm::Permute;
my $p = Algorithm::Permute->new(['a' .. 'c']);
while(my @a_permutation = $p->next) {
print "@a_permutation\n";
}
__END__
D:\Home\asu1\UseNet\clpmisc> p
c b a
b c a
b a c
c a b
a c b
a b c
You will note that Algorithm::Permute won't do all 3-letter permutations
out of 5 letters. Now, it is your turn to do some work. You can start by
reading the posting guidelines.
Sinan
------------------------------
Date: Sun, 06 Feb 2005 12:53:57 -0500
From: Bob Walton <see_sig@invalid>
Subject: Re: Perl - permute?
Message-Id: <42065a4b$2_2@127.0.0.1>
Ej wrote:
> Hi,
> How can I take an array (a,b,c,d,e) and list ALL possible [3 LETTER] combos
> of these letters, I want the output to look like
>
> abc
> acb
> aab
> aaa
>
> how can I Using perl
> Thanks Ej
That's a FAQ:
perldoc -q permute
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
------------------------------
Date: Sun, 6 Feb 2005 13:30:15 -0500
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: Perl - permute?
Message-Id: <JntNd.120$Ry1.31@fe12.lga>
"Ej" <justsurge@mailcan.com> wrote in message
news:1107709033.0d15271ffc45f8463e1fcde7dddd2c79@bubbanews...
> Hi,
> How can I take an array (a,b,c,d,e) and list ALL possible [3 LETTER]
combos
> of these letters, I want the output to look like
>
> abc
> acb
> aab
> aaa
>
The required function should not
be called 'permute'. A quick
check in the book 'Concrete
Mathematics' by Knuth, et. al.
confirmed my suspicion that
permutations are the ways that
n objects can be arranged in a
row. The Permute module will only return the true permutations.
There probably is a name for your
function, but I do not know it. If the required module exists, it
would be hard to find without an
accurate name. I recommend do-it-
yourself, using Abigail's method.
Bill
------------------------------
Date: 6 Feb 2005 10:54:50 -0800
From: charley@pulsenet.com
Subject: Re: Perl - permute?
Message-Id: <1107716090.165769.285450@l41g2000cwc.googlegroups.com>
Ej wrote:
> Hi,
> How can I take an array (a,b,c,d,e) and list ALL possible [3 LETTER]
combos
> of these letters, I want the output to look like
>
> abc
> acb
> aab
> aaa
Hello,
This will do what you want:
my $items = "a,b,c,d,e";
print join "\n", glob "{$items}" x 3;
Chris
------------------------------
Date: 6 Feb 2005 14:12:37 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <cu58kl$ij3$1@mamenchi.zrz.TU-Berlin.DE>
John Bokma <postmaster@castleamber.com> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
>
> > John Bokma <postmaster@castleamber.com> wrote in comp.lang.perl.misc:
> >> Anno Siegel wrote:
> > It is more frequently used, but for no good reason. Pre-increment is
> > the simpler process, not only implementationally. There are two
> > values involved in $x++, but only one in ++$x.
>
> A programmer shouldn't be bothered by that in normal cases.
If "normal case" includes use of the return value of $x++, it can't
be ignored.
Anno
------------------------------
Date: 06 Feb 2005 15:32:14 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <slrnd0ce3t.g2.abigail@alexandra.abigail.nl>
Henrik () wrote on MMMMCLXXVII September MCMXCIII in
<URL:news:4205dced$0$166$edfadb0f@dtext01.news.tele.dk>:
|| John Bokma skrev:
||
|| > Anno Siegel wrote:
|| > > John Bokma <postmaster@castleamber.com> wrote in
|| > > comp.lang.perl.misc:
|| > >> Michael Slass wrote:
|| > >> >| ++$hack_count{$1};
|| > >>
|| > >> I recommend using $hack_count{$1}++;
|| > >
|| > > Why?
|| >
||
|| Another good(?) reason, which also applies to C-code, is that
|| accidental omision of one + is caught at commpile time, but only if you
|| use post incrementation.
If you use '+ $var' in void context, having warnings turned on will
give a warning.
Abigail
--
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))
------------------------------
Date: 6 Feb 2005 05:18:20 -0800
From: surfunbear@yahoo.com
Subject: Perl Versus Python
Message-Id: <1107695900.340876.270130@g14g2000cwa.googlegroups.com>
I've read some posts on Perl versus Python and studied a bit of my
Python book.
I'm a software engineer, familiar with C++ objected oriented
development, but have been using Perl because it is great for pattern
matching, text processing, and automated testing. Our company is really
fixated on risk managnemt and the only way I can do enough testing
without working overtime (which some people have ended up doing) is by
automating my testing. That's what got me started on Perl.
I've read that many people prefer Python and that it is better than
Perl. However, I want to ask a few other questions.
1. Perl seems to have alot of packaged utilities available through
CPAN, the comprehensive perl network. These can aid in building
parsers, web development, perl DBI is heavily used. This seems to be a
very important benifit. I'm not sure that Python is as extenive at all
in that regard ? Perl also has excellent pattern matching compared to
sed, not sure about how Python measures up,
but this seems to make perl ideally suited to text processing.
2. Python is apparantly better at object oriented. Perl has some kind
of name spacing, I have used that in a limited way. Does Perl use a
cheap and less than optimal Object oriented approach ?
That was what someone at work said, he advocates Python.
Is it likely that Perl will improve it's object oriented features
in the next few years ?
3. Perl is installed on our system and alot of other systems.
You don't have to make sys admins go out of there way to make it
available. It's usualy allready there. I also did a search of job
postings on a popular website. 108 jobs where listed that require
knowledge of Perl, only 17 listed required Python. Becomeing more
familiar with Perl might then be usefull for ones resume ?
If Python is better than Perl, I'm curious how really significant
those advantages are ?
------------------------------
Date: Sun, 06 Feb 2005 14:25:22 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Perl Versus Python
Message-Id: <Xns95F55FE57E920asu1cornelledu@127.0.0.1>
surfunbear@yahoo.com wrote in news:1107695900.340876.270130
@g14g2000cwa.googlegroups.com:
> I'm a software engineer, familiar with C++ objected oriented
> development,
Good for you.
...
> I've read that many people prefer Python and that it is better than
> Perl. However, I want to ask a few other questions.
This is a FAQ. Please see:
perldoc -q "How does Perl compare"
Sinan
------------------------------
Date: 6 Feb 2005 16:33:25 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Problem with binary numbers
Message-Id: <cu5gsl$n3p$1@mamenchi.zrz.TU-Berlin.DE>
<perldude@nospam.com> wrote in comp.lang.perl.misc:
> A third-party module that I'm using has a couple of binary constants defined:
>
> GENERIC_READ=10000000000000000000000000000000
> GENERIC_EXECUTE=100000000000000000000000000000
>
> The binary value for GENERIC_READ|GENERIC_EXECUTE would be:
> 10100000000000000000000000000000
>
> I'm trying to check if a field in an object created by the module equals
> GENERIC_READ|GENERIC_EXECUTE, but I'm running into a problem. If I print out
> the value for a field that I know equals GENERIC_READ|GENERIC_EXECUTE, then it
> prints out -1610612736.
> But when I have the statement "print GENERIC_READ|GENERIC_EXECUTE", it prints
> out 2684354560.
>
> The following statements both print out 10100000000000000000000000000000:
> printf("%0b\n", 2684354560);
> printf("%0b\n", -1610612736);
>
> So the binary representation for GENERIC_READ|GENERIC_EXECUTE has 2 different
> decimal representations, a positive one and a negative one.
Put it the other way round: The bit pattern has two different numeric
interpretations -- one as an unsigned integer and one as a signed integer.
Perl integers contain a flag that says which interpretation is valid.
To see the difference:
use Devel::Peek;
Dump 2684354560;
Dump -1610612736;
> Why does the
> field in the object created by the third-party module have a negative decimal
> representation, while my own code has a positive decimal representation?
All you told us about the module is that it is "third party", so how can
you expect anyone to answer a question about it? It may be a bug in the
module or it may be deliberate, who knows.
If you use the numbers as masks to test against flags like GENERIC_READ
etc, the difference doesn't matter. If you must compare them for equality,
you can use sprintf( "%u", $x) == sprintf( "%u", $y).
Anno
------------------------------
Date: Sun, 6 Feb 2005 09:48:47 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Problem with binary numbers
Message-Id: <slrnd0cf2v.ndf.tadmc@magna.augustmail.com>
perldude@nospam.com <perldude@nospam.com> wrote:
> A third-party module that I'm using has a couple of binary constants defined:
>
> GENERIC_READ=10000000000000000000000000000000
> GENERIC_EXECUTE=100000000000000000000000000000
That is not how you define constants in Perl.
Please show real Perl code.
> The binary value for GENERIC_READ|GENERIC_EXECUTE would be:
> 10100000000000000000000000000000
>
> I'm trying to check if a field in an object created by the module equals
^^^^^^^^^^
> GENERIC_READ|GENERIC_EXECUTE,
Where is the Perl code for your attempts?
> but I'm running into a problem.
If we cannot see the code, we cannot debug the code.
> If I print out
> the value
How do you print it out?
If we cannot see the code, we cannot debug the code.
> for a field that I know equals GENERIC_READ|GENERIC_EXECUTE, then it
> prints out -1610612736.
How do "know" that it is equal?
> But when I have the statement "print GENERIC_READ|GENERIC_EXECUTE",
We finally get to some Real Perl Code. Thank you.
> it prints
> out 2684354560.
> So the binary representation for GENERIC_READ|GENERIC_EXECUTE has 2 different
> decimal representations, a positive one and a negative one. Why does the
> field in the object created by the third-party module
You cannot really expect that we would be able to comment on the
internals of a module without even knowing the module's name, do you?
> have a negative decimal
> representation, while my own code has a positive decimal representation?
If you post a short and complete program *that we can run*, then
we will be able to explain it.
The program below makes output for me. If your code is doing
something different, then show that code and we will help
you fix it.
--------------------------------
#!/usr/bin/perl
use warnings;
use strict;
use constant GENERIC_READ => 0b10000000000000000000000000000000;
use constant GENERIC_EXECUTE => 0b100000000000000000000000000000;
my $ored = 0b10100000000000000000000000000000;
print "equal\n" if $ored == GENERIC_READ | GENERIC_EXECUTE;
--------------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 06 Feb 2005 14:11:00 -0500
From: perldude@nospam.com
Subject: Re: Problem with binary numbers
Message-Id: <cdqc01lcb9q5pk72em2hl3h2lq8icr4qho@4ax.com>
Sorry I didn't include working code. The module I am using is Win32::Perms,
which is available at http://www.roth.net/perl/perms/
Here is simplified code (running on my Windows 2000 machine with ActivePerl
5.8.3) which shows the problem:
#############################################
use Data::Dumper;
use Win32::Perms;
@securityDescriptor;
$permsObject;
# dump the security descriptor for c:\winnt\system32 into the array
$permsObject = new Win32::Perms("c:\\winnt\\system32");
$permsObject->Dump(\@securityDescriptor);
$permsObject->Close();
# remove all entries in the array that aren't "DACL". all the "DACL" entries
# are at the front of the array
$index = 0;
while ($securityDescriptor[$index]->{"Entry"} eq "DACL") {
$index++;
}
splice @securityDescriptor, $index;
# interate through the array and print out info about each ACE
$index = 1;
while ($index <= scalar(@securityDescriptor)) {
$aceRef = $securityDescriptor[$index-1];
print "-------------------------------------------------------\n";
print "ACE #$index:\n\n";
@decodedValues;
$decodedString;
Win32::Perms::DecodeMask($aceRef, \@decodedValues);
$decodedString = Data::Dumper->Dump(\@decodedValues);
print "Win32::Perms says that the ACE's Mask value is made up
of:\n$decodedString\n";
$gr_binary = sprintf("%0b", GENERIC_READ);
$ge_binary = sprintf("%0b", GENERIC_EXECUTE);
$gr_OR_ge = (GENERIC_READ|GENERIC_EXECUTE);
$gr_OR_ge_binary = sprintf("%0b", $gr_OR_ge);
print "GENERIC_READ in binary=$gr_binary\n";
print "GENERIC_EXECUTE in binary=$ge_binary\n";
print "GENERIC_READ|GENERIC_EXECUTE in binary=$gr_OR_ge_binary\n";
print "GENERIC_READ|GENERIC_EXECUTE in decimal=$gr_OR_ge\n";
$mask = $aceRef->{"Mask"};
$mask_binary = sprintf("%0b", $mask);
print "The ACE's Mask value in binary is: $mask_binary\n";
print "The ACE's Mask value in decimal is: $mask\n";
print "\n";
$index++;
}
###########################################
When I run that code, I get some output. Here is the output for the second
ACE, which is relevant since it's Mask value == GENERIC_READ|GENERIC_EXECUTE:
-------------------------------------------------------
ACE #2:
Win32::Perms says that the ACE's Mask value is made up of:
$VAR1 = 'GENERIC_EXECUTE';
$VAR2 = 'GENERIC_READ';
GENERIC_READ in binary=10000000000000000000000000000000
GENERIC_EXECUTE in binary=100000000000000000000000000000
GENERIC_READ|GENERIC_EXECUTE in binary=10100000000000000000000000000000
GENERIC_READ|GENERIC_EXECUTE in decimal=2684354560
The ACE's Mask value in binary is: 10100000000000000000000000000000
The ACE's Mask value in decimal is: -1610612736
------------------------------------------------------
As you can see from the output, I know that the ACE's Mask value is
GENERIC_READ|GENERIC_EXECUTE because the call to Win32::Perms::DecodeMask()
said so. When I print out the decimal value of the Mask value, it is a
negative number, but when I print out the decimal value of
GENERIC_READ|GENERIC_EXECUTE, it is a positive number.
While writing up this post, I realized that I can just use sprintf on those
two values to get their binary values and then compare them. But I'm still
curious as to why the decimal values are different. Thanks for your help.
------------------------------
Date: 6 Feb 2005 17:11:58 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: starting CGi shell script
Message-Id: <cu5j4u$o2n$1@mamenchi.zrz.TU-Berlin.DE>
Joe Smith <joe@inwap.com> wrote in comp.lang.perl.misc:
> Reinhard Pagitsch wrote:
> >> $out=qx(script.sh) does not work, $out is still "" afterwards.
> >
> > I think you should use backticks:
> > $out=`script.sh`;
>
> You obviously don't know what the qx() operator does.
That seems to be endemic in this thread. I have rarely seen so many
replies miss the point entirely.
Anno
------------------------------
Date: 06 Feb 2005 15:35:44 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Why aren't 'warnings' on by default?
Message-Id: <slrnd0ceaf.g2.abigail@alexandra.abigail.nl>
DJO (d@adelphia.net) wrote on MMMMCLXXVII September MCMXCIII in
<URL:news:ltadncQuENLjSJjfRVn-hw@adelphia.com>:
() Chris Richmond - MD6-FDC ~ wrote:
() > Seems to me that nobody will support help requests until warnings
() > are turned on, let alone maybe strict. Why isn't it turned on
() > by default? Its a good idea 99.99% of the time. Then the
() > .01% when it isn't, make the user shut it off.
() >
() > Chris
() >
() Because strict and warnings pragmas were not built in to early Perl
() versions. Generally, Perl version updates strive to not break existing
() code. Defaulting to strictures and warnings being "on" would definately
() break older code that didn't count on them being there.
Turning warnings on by default also means it becomes more awkward to
write one-liners.
Abigail
--
A perl rose: perl -e '@}>-`-,-`-%-'
------------------------------
Date: 06 Feb 2005 15:37:31 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Why aren't 'warnings' on by default?
Message-Id: <slrnd0cedr.g2.abigail@alexandra.abigail.nl>
Peter Wyzl (wyzelli@yahoo.com) wrote on MMMMCLXXVII September MCMXCIII in
<URL:news:C9mNd.149958$K7.139392@news-server.bigpond.net.au>:
** "RedGrittyBrick" <Red.Grittybrick@SpamWeary.Foo> wrote in message
** news:cu4qb8$q84$1@hercules.btinternet.com...
** : Chris Mattern wrote:
** : > mjl69 wrote:
**
** <snip>
**
** :
** : Hmm, maybe perl (the interpreter) could check the date on the file of
** : Perl statements and adjust its behaviour accordingly?
** :
** : e.g.
** : foo.pl has last modified date < 1/1/2006 : strict & warnings *off*
** : unless specifically turned on.
** : foo.pl has last modified date >= 1/1/2006 : strict & warnings *on*
** : unless specifically turned off.
**
**
** So if I do a minor edit on an old program suddenly everything gets broken
** with no obvious reason? If the interpreter/compiler changes behaviour based
** on the file date, imagine the difficulty in troubleshooting. "All I did was
** copy the file from one place to another and now it has all these errors!"
Yeah, but it means that a common DOS/Windows trick to "fix" broken programs
works: just set back the clock (and copy the file again).
But I agree. A very, very bad idea.
Abigail
--
A perl rose: perl -e '@}-`-,-`-%-'
------------------------------
Date: Sun, 6 Feb 2005 17:21:44 +0100
From: Joachim Pense <spam-collector@pense-online.de>
Subject: Re: Why aren't 'warnings' on by default?
Message-Id: <u20nstbq1jo2$.1xmk3cqpwqt24$.dlg@40tude.net>
Am 06 Feb 2005 15:35:44 GMT schrieb Abigail:
>
> Turning warnings on by default also means it becomes more awkward to
> write one-liners.
>
I do not think a one-letter no-warnings option would really hurt.
Joachim
------------------------------
Date: 06 Feb 2005 16:31:40 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Why aren't 'warnings' on by default?
Message-Id: <slrnd0chjc.g2.abigail@alexandra.abigail.nl>
Joachim Pense (spam-collector@pense-online.de) wrote on MMMMCLXXVII
September MCMXCIII in <URL:news:u20nstbq1jo2$.1xmk3cqpwqt24$.dlg@40tude.net>:
() Am 06 Feb 2005 15:35:44 GMT schrieb Abigail:
()
() >
() > Turning warnings on by default also means it becomes more awkward to
() > write one-liners.
() >
()
() I do not think a one-letter no-warnings option would really hurt.
Well, it seems that people think a one-letter warnings option does hurt.
So, by that token, a one-letter no-warning would hurt as well.
Abigail
--
sub _ {$_ = shift and y/b-yB-Y/a-yB-Y/ xor !@ _?
exit print :
print and push @_ => shift and goto &{(caller (0)) [3]}}
split // => "KsvQtbuf fbsodpmu\ni flsI " xor & _
------------------------------
Date: Sun, 06 Feb 2005 11:34:49 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: XML & Perl - Error
Message-Id: <p7vb011v0jf0tpda4sriq4uu81q7jt73e2@4ax.com>
Sherm Pendley wrote:
>XML::LibXML isn't part of the core Perl distribution, so you'll have to
>install it separately. Go to the URL you listed above and follow their
>instructions for obtaining and installing a compiled and packaged PPM of
>the module.
Note that this module requires a DLL from the LibXML project (and I was
sure that there was a "2" in that name...) that is not installed but the
PPM. You need to get it separately, preferably first.
Oh that's right. See
<http://cpan.uwinnipeg.ca/htdocs/XML-LibXML/README.html>
Prior to installation you MUST have installed the libxml2
library. You can get the latest libxml2 version from
http://xmlsoft.org
Without libxml2 installed this module will neither build nor
run.
But that is actually the info for installing the module from CPAN.
(Either with or without CPAN.pm). But I recall that that DLL *does not
come* with the module, even when you use PPM. All in all I can say that
install of this particular module is definitely not the easiest install
you could ever have to do.
The same site does provide some pointers to PPM modules: see the bottom
of
<http://cpan.uwinnipeg.ca/dist/XML-LibXML>
which points into (for 5.8.x):
<http://theoryx5.uwinnipeg.ca/ppms/>
A Google search of this type is pretty always successful in hunting one
down: search for both module name and "PPD":
<http://www.google.com/search?q=XML::LibXML+PPD>
The first result of this search points into Apache's repository, a very
broad PPM repository in general. Please take care to use one of the many
mirrors for larger downloads.
<http://www.apache.org/dyn/closer.cgi>
under whatever mirror you picked, dig into the subdirectory
perl/win32-bin/ppms/
and you'll find the PPD files there.
--
Bart.
------------------------------
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 7744
***************************************