[25819] in Perl-Users-Digest
Perl-Users Digest, Issue: 8056 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 6 14:05:27 2005
Date: Fri, 6 May 2005 11:05:05 -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 Fri, 6 May 2005 Volume: 10 Number: 8056
Today's topics:
Assigning multiple hash entries with deref chain in fro (Konrad Eisele)
Re: Assigning multiple hash entries with deref chain in <1usa@llenroc.ude.invalid>
Re: Assigning multiple hash entries with deref chain in <tadmc@augustmail.com>
Re: Assigning multiple hash entries with deref chain in <tadmc@augustmail.com>
Re: Assigning multiple hash entries with deref chain in <1usa@llenroc.ude.invalid>
Re: Different POST encoding format <tadmc@augustmail.com>
Re: Different POST encoding format <djb@global.net.mt>
Re: FAQ 4.14 How can I compare two dates and find the d <mothra@nowhereatall.com>
install Mail::Internet via CPAN shell on Windows (newbi <harbell@beerburp.com>
Re: Offline Perl obfusquator ? <darkon.tdo@gmail.com>
Re: Offline Perl obfusquator ? <apeiron+usenet@coitusmentis.info>
Re: Offline Perl obfusquator ? xhoster@gmail.com
RFC: Google Groups grabber in Perl <ajo@nospam.andrew.cmu.edu>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 May 2005 04:56:27 -0700
From: eiselekd@web.de (Konrad Eisele)
Subject: Assigning multiple hash entries with deref chain in front
Message-Id: <ddbcd13.0505060356.2f1dc830@posting.google.com>
Assigning multiple hash with one statement is done with:
@a{'a','b'} = (1,2);
but how can I do it if I want to access the hash through
previous dereferences:
---------------------------
use Data::Dumper;
@a = ({'a'=>1,'b'=>2});
$b = \@a;
$b->[0]->{'a','b'} = (100,1000);
print Dumper(\@a);
---------------------------
$b->[0]->{'a','b'} = (1,2) doesn't work here.
How can I force list context?
-- Konrad
------------------------------
Date: Fri, 06 May 2005 12:24:59 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Assigning multiple hash entries with deref chain in front
Message-Id: <Xns964E557DBDC6asu1cornelledu@127.0.0.1>
eiselekd@web.de (Konrad Eisele) wrote in
news:ddbcd13.0505060356.2f1dc830@posting.google.com:
> Assigning multiple hash with one statement is done with:
> @a{'a','b'} = (1,2);
Assuming %a is a hash, that is referred to as, @a{'a','b'} is a hash
slice.
> but how can I do it if I want to access the hash through
> previous dereferences:
> ---------------------------
use strict;
use warnings;
> use Data::Dumper;
> @a = ({'a'=>1,'b'=>2});
@a now is an array containing a single element which is a reference to
an anonymous hash. BTW, you don't need to quote a and b above, that is
done automatically by using => for the keys you have chosen in this
case.
> $b = \@a;
$b now contains a reference to \@a. (Incidentally, $b is a package
variable used by sort, so it is not a good idea to use it for other
purposes).
> $b->[0]->{'a','b'} = (100,1000);
Well, $b->[0] is the reference to the hash you created above, so you
need to get a hash slice out of that first:
use strict;
use warnings;
my @x = ( { a => 1, b => 2 } );
my $y = \@x;
@{ %{$y->[0]} }{ qw(a b) } = (100, 1000);
use Data::Dumper;
print Dumper(\@x);
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Fri, 6 May 2005 08:08:08 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Assigning multiple hash entries with deref chain in front
Message-Id: <slrnd7mr1o.g2n.tadmc@magna.augustmail.com>
Konrad Eisele <eiselekd@web.de> wrote:
> Assigning multiple hash with one statement is done with:
> @a{'a','b'} = (1,2);
A "hash slice".
> but how can I do it if I want to access the hash through
> previous dereferences:
> ---------------------------
> use Data::Dumper;
> @a = ({'a'=>1,'b'=>2});
> $b = \@a;
> $b->[0]->{'a','b'} = (100,1000);
> print Dumper(\@a);
> ---------------------------
> How can I force list context?
You cannot force list context, but that doesn't matter because
your question is not related to context in any way.
Your real question is:
How do I dereference a hashref?
You can do that by applying "Use Rule 1" from
perldoc perlreftut
I like to do it in 3 steps.
Pretend you are slicing a plain-ol' hash:
@hash{'a','b'} = (100,1000);
Replace the _name_ with a block:
@{ }{'a','b'} = (100,1000);
Fill in the block with something that returns the right type of reference:
@{ $b->[0] }{'a','b'} = (100,1000);
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 6 May 2005 08:11:31 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Assigning multiple hash entries with deref chain in front
Message-Id: <slrnd7mr83.g9u.tadmc@magna.augustmail.com>
A. Sinan Unur <1usa@llenroc.ude.invalid> wrote:
> @{ %{$y->[0]} }{ qw(a b) } = (100, 1000);
^^ ^
^^ ^
Delete those 3 characters.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 06 May 2005 13:46:07 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Assigning multiple hash entries with deref chain in front
Message-Id: <Xns964E6340086CAasu1cornelledu@127.0.0.1>
Tad McClellan <tadmc@augustmail.com> wrote in
news:slrnd7mr83.g9u.tadmc@magna.augustmail.com:
> A. Sinan Unur <1usa@llenroc.ude.invalid> wrote:
>
>> @{ %{$y->[0]} }{ qw(a b) } = (100, 1000);
> ^^ ^
> ^^ ^
> Delete those 3 characters.
Done:
@{ $y->[0] }{ qw(a b) } = (100, 1000);
:)
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Fri, 6 May 2005 07:20:47 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Different POST encoding format
Message-Id: <slrnd7mo8v.g2n.tadmc@magna.augustmail.com>
David Joseph Bonnici <djb@global.net.mt> wrote:
> I managed to make a workaround.
Please share it here, for the benefit of others.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 6 May 2005 16:48:02 +0200
From: "David Joseph Bonnici" <djb@global.net.mt>
Subject: Re: Different POST encoding format
Message-Id: <d5g0a2$dd5$1@domitilla.aioe.org>
....
use HTTP::Request::Common qw(POST);
use URI::Escape;
....
and then do the request as follows. (It was quite painfull to find the right
manpage)
$response = $browser->request(POST $url,
Content => 'nc='.uri_escape('Fri May 6
03:09:09').'&Id='.'01'.'&'.'Insert%5Fdate'.'='.uri_escape('8/5/2005').'&key=1');
Like so, you have total control of what is sent in the post request.
I have a new problem now, being that: to have some sort of control of the
packet size of the request. Some post requests are splitted into several
small packets, and I think that this can be causing some problems, on the
server side (of which I have no control or debug information. I know that
the server should not bother about the transport layer, but you never know
how things are implemented.)
David
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnd7mo8v.g2n.tadmc@magna.augustmail.com...
> David Joseph Bonnici <djb@global.net.mt> wrote:
>
>> I managed to make a workaround.
>
>
> Please share it here, for the benefit of others.
>
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Fri, 6 May 2005 05:37:56 -0700
From: "mothra" <mothra@nowhereatall.com>
Subject: Re: FAQ 4.14 How can I compare two dates and find the difference?
Message-Id: <427b63ea$1@usenet.ugs.com>
PerlFAQ Server wrote:
>
> 4.14: How can I compare two dates and find the difference?
>
(snipped)
> However, if you don't know the precise format of your dates, then
> you should probably use either of the Date::Manip and Date::Calc
> modules from CPAN before you go hacking up your own parsing
> routine to handle arbitrary date formats.
What about adding the DateTime project to this FAQ
something like:
However, if you don't know the precise format of your dates, then
you should probably use either of the Date::Manip and Date::Calc
modules from CPAN or the DateTime project at http://datetime.perl.org/
before you go hacking up your own parsing routine to handle arbitrary
date formats.
Mothra
------------------------------
Date: Fri, 06 May 2005 16:28:29 GMT
From: Jaz <harbell@beerburp.com>
Subject: install Mail::Internet via CPAN shell on Windows (newbie question)
Message-Id: <f9pm71p1bvurure1q469vo90425maborkg@4ax.com>
I need advice on installing Mail-Internet.
My perl is simply unzipped ActivePerl-5.6.1.638-MSWin32-x86.zip
(C:\Perl\...) and I'd like to run CPAN shell to install Mail-Internet.
I googled for this due to this: I'm running perl scripts from DOS
(testing STAT antispam/virus for mercury/32 IMAP server running on
this host) and I'm getting the below error:
Can't locate auto/Mail/Internet/autosplit.ix in @INC (@INC contains:
c:/Perl/lib c:/Perl/site/lib .) at c:/Perl/lib/AutoLoader.pm line 146.
When I run CPAN install (from cygwin or DOS) I get the errors below.
Any advice for me?
TIA
Jaz
------------------------------------------------------
C:\Perl>perl -MCPAN -e shell
cpan shell -- CPAN exploration and modules installation (v1.7601)
ReadLine support enabled
cpan> i /mail::internet/
CPAN: Storable loaded ok
Going to read /home/jaz/.cpan/Metadata
Database was generated on Fri, 06 May 2005 07:04:53 GMT
Module id = Mail::Internet
DESCRIPTION Functions for RFC822 address manipulations
CPAN_USERID MARKOV (Mark Overmeer <mark@overmeer.net>)
CPAN_VERSION 1.67
CPAN_FILE M/MA/MARKOV/MailTools-1.67.tar.gz
DSLI_STATUS adpO (alpha,developer,perl,object-oriented)
INST_FILE (not installed)
cpan>
------------------------------------------------------
OR
------------------------------------------------------
cpan> install Mail::Internet
Running install for module Mail::Internet
Running make for M/MA/MARKOV/MailTools-1.67.tar.gz
CPAN: Digest::MD5 loaded ok
CPAN: Compress::Zlib loaded ok
Checksum for
/home/jaz/.cpan/sources/authors/id/M/MA/MARKOV/MailTools-1.67.tar.gz
ok
Scanning cache /home/jaz/.cpan/build for sizes
MailTools-1.67/
MailTools-1.67/t/
MailTools-1.67/t/internet.t
MailTools-1.67/t/mailer.t
MailTools-1.67/t/require.t
MailTools-1.67/t/send.t
MailTools-1.67/t/header.t
MailTools-1.67/t/extract.t
MailTools-1.67/t/mailcap.t
MailTools-1.67/Mail/
MailTools-1.67/Mail/Cap.pm
MailTools-1.67/Mail/Util.pm
MailTools-1.67/Mail/Field/
MailTools-1.67/Mail/Field/Date.pm
MailTools-1.67/Mail/Field/AddrList.pm
MailTools-1.67/Mail/Mailer/
MailTools-1.67/Mail/Mailer/sendmail.pm
MailTools-1.67/Mail/Mailer/rfc822.pm
MailTools-1.67/Mail/Mailer/smtp.pm
MailTools-1.67/Mail/Mailer/qmail.pm
MailTools-1.67/Mail/Mailer/testfile.pm
MailTools-1.67/Mail/Address.pm
MailTools-1.67/Mail/Mailer.pm
MailTools-1.67/Mail/Send.pm
MailTools-1.67/Mail/Header.pm
MailTools-1.67/Mail/Internet.pm
MailTools-1.67/Mail/Filter.pm
MailTools-1.67/Mail/Field.pm
MailTools-1.67/README
MailTools-1.67/MailTools.ppd
MailTools-1.67/Makefile.PL
MailTools-1.67/README.demos
MailTools-1.67/META.yml
MailTools-1.67/examples/
MailTools-1.67/examples/send_demo.PL
MailTools-1.67/examples/mail-mailer.pl
MailTools-1.67/examples/rplyto_demo.PL
MailTools-1.67/examples/forwd_demo.PL
MailTools-1.67/ChangeLog
MailTools-1.67/MANIFEST
Removing previously used /home/jaz/.cpan/build/MailTools-1.67
CPAN.pm: Going to build M/MA/MARKOV/MailTools-1.67.tar.gz
Checking for Net::SMTP...ok
Checking for Net::Domain...ok
Checking for IO::Handle...ok
Checking if your kit is complete...
Looks good
Writing Makefile for Mail
-- NOT OK
Running make test
Can't test without successful make
Running make install
make had returned bad status, install seems impossible
cpan>
------------------------------------------------------
(Please excuse the 'burp' when replying (b))
------------------------------
Date: Fri, 06 May 2005 15:40:27 -0000
From: "David K. Wall" <darkon.tdo@gmail.com>
Subject: Re: Offline Perl obfusquator ?
Message-Id: <Xns964E76C163E2Edkwwashere@216.168.3.30>
John W. Krahn <someone@example.com> wrote:
> Jazeker wrote:
>>
>> As I am making a piece of Perl code that contains some policies
>> (disallowing people to send spam, etc...) I want to higher the
>> treshold for people to change those lines of code. (some will...
>> I know).
>>
>> That would require me to have some script or program that can
>> obfusquate (even by just playing with the code layout) a few
>> blocks of code. I am not looking for an obfusquator that would
>> completely change all variable names, etc... but that would just
>> make a few blocks of code very hard to read so only Perl wizzards
>> would know what to do (and I expect those wizards not to be
>> needing my software to annoy the world ;-) )
>>
>> Any hints, links or other would be appreciated.
>>
>> PS : not looking for an online obfusquator as well... just an
>> offline script would be ok.
>
> http://search.cpan.org/~dconway/Acme-Bleach-1.12/
If I recall correctly, Acme::Morse does about the same thing, except
that instead of converting the code to spaces it converts it to Morse
code. I'm not sure which is more evil.
------------------------------
Date: 06 May 2005 16:34:15 GMT
From: Christopher Nehren <apeiron+usenet@coitusmentis.info>
Subject: Re: Offline Perl obfusquator ?
Message-Id: <slrnd7n747.1gf.apeiron+usenet@prophecy.dyndns.org>
On 2005-05-06, John W. Krahn scribbled these
curious markings:
>> That would require me to have some script or program that can obfusquate
>> (even by just playing with the code layout) a few blocks of code.
>
> http://search.cpan.org/~dconway/Acme-Bleach-1.12/
Keep in mind that any code obfuscator in the Bleach line is not perfect.
perl still needs a way to read the program, and if perl needs a way to
read the program, then there *is* still a way to programmatically read
the program. A user need only do a small amount of research before they
figure out how to read and change the program. Read the relevant FAQ
entry: perldoc -q 'hide the source'.
Best Regards,
Christopher Nehren
--
I abhor a system designed for the "user", if that word is a coded
pejorative meaning "stupid and unsophisticated". -- Ken Thompson
If you ask the wrong questions, you get answers like "42" and "God".
Unix is user friendly. However, it isn't idiot friendly.
------------------------------
Date: 06 May 2005 17:06:45 GMT
From: xhoster@gmail.com
Subject: Re: Offline Perl obfusquator ?
Message-Id: <20050506130645.153$5f@newsreader.com>
Christopher Nehren <apeiron+usenet@coitusmentis.info> wrote:
> On 2005-05-06, John W. Krahn scribbled these
> curious markings:
> >> That would require me to have some script or program that can
> >> obfusquate (even by just playing with the code layout) a few blocks of
> >> code.
> >
> > http://search.cpan.org/~dconway/Acme-Bleach-1.12/
>
> Keep in mind that any code obfuscator in the Bleach line is not perfect.
It was pretty clear that the OP already had this in mind. No need for
pointless harping.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Fri, 6 May 2005 13:40:33 -0400 (EDT)
From: "Arthur J. O'Dwyer" <ajo@nospam.andrew.cmu.edu>
Subject: RFC: Google Groups grabber in Perl
Message-Id: <Pine.LNX.4.60-041.0505061320410.8430@unix40.andrew.cmu.edu>
Just a request-for-comments and minor self-promotion:
http://www.contrib.andrew.cmu.edu/~ajo/usenet_archive/retrieve.txt
I've written a little Perl script that goes through Google Groups
Classic's archive and extracts the texts of all my Usenet posts
(that is, all the posts found with a given "author:foo" search string).
(As a bonus, 'ls' in the resulting directory produces a Message-ID list
ready to submit to http://groups-beta.google.com/groups/msgs_remove !)
I would appreciate comments on:
(1) Does it have any security holes? I'm leery of the way it calls
Lynx, even with '' quotes present, and I wonder what could go wrong
by using the Message-ID itself as a unique filename for each message
text.
(2) How is it bad Perl code? I'm not an even semi-regular Perl user,
so I know this source code is naive and clumsy. So if you have the
inclination to critique Perl code, go right ahead.
(3) [more for comp.programming] Is it useful? What other tools exist
for Usenet scraping? What more sensible naming scheme or file format
could I use to store Usenet posts and headers, numbered in the low
thousands? (How do Usenet servers do it?)
I release the code to the public domain; please take it, use it, and
promulgate it if you find it useful. But hurry --- the door of opportunity
is shutting quickly!
http://www.contrib.andrew.cmu.edu/~ajo/usenet_archive/retrieve.txt
Thanks,
-Arthur
http://www.contrib.andrew.cmu.edu/~ajo/dont-be-evil.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 8056
***************************************