[31645] in Perl-Users-Digest
Perl-Users Digest, Issue: 2908 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 12 16:09:46 2010
Date: Mon, 12 Apr 2010 13:09:19 -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, 12 Apr 2010 Volume: 11 Number: 2908
Today's topics:
Download a zip file and extract to a directory <davidmichaelkarr@gmail.com>
Re: Download a zip file and extract to a directory <davidmichaelkarr@gmail.com>
Re: FAQ 3.4 How do I find which modules are installed o <brian.d.foy@gmail.com>
Matchtable <boerni_s@bluewin.ch>
Re: Matchtable <cartercc@gmail.com>
Re: Matchtable <smallpond@juno.com>
Net::SMTP errors <davidmichaelkarr@gmail.com>
Re: Net::SMTP errors <hjp-usenet2@hjp.at>
Req Help to install IPC::SysV on WinXP + ActiveState Pe <feltra@gmail.com>
Re: Req Help to install IPC::SysV on WinXP + ActiveStat <smallpond@juno.com>
Re: Req Help to install IPC::SysV on WinXP + ActiveStat <feltra@gmail.com>
Re: software requirements again, take 483 <cwilbur@chromatico.net>
Re: software requirements again, take 483 <tzz@lifelogs.com>
Re: software requirements again, take 483 (aka ? the Platypus)
Re: software requirements again, take 483 <cwilbur@chromatico.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 9 Apr 2010 15:34:57 -0700 (PDT)
From: "david.karr" <davidmichaelkarr@gmail.com>
Subject: Download a zip file and extract to a directory
Message-Id: <175fdcbf-cbb9-4ae5-a36b-7d95d37e63f6@y17g2000yqd.googlegroups.com>
I've written some scripts that manipulate Zip files using
Archive::Zip. I'm now working on a script that uses "LWP::Simple" to
download data from a URL. As part of this process I'm going to have
to download a zip file from a URL and then extract that zip file to a
particular directory.
Can I use LWP::Simple to download a binary file directly into a
variable?
I've looked at the Archive::Zip methods, and it doesn't appear as if I
can create the Zip object directly from the contents of a variable.
Will I have to download the zip file directly to a temporary file
(using "getstore($url, $file)"), I would imagine), and then create the
Zip object from that?
I see the "extractToFileHandle( $fh )" method on Archive::Zip. Is that
file handle supposed to be a directory?
------------------------------
Date: Fri, 9 Apr 2010 16:27:55 -0700 (PDT)
From: "david.karr" <davidmichaelkarr@gmail.com>
Subject: Re: Download a zip file and extract to a directory
Message-Id: <990aab7f-4655-452f-b5bc-774faef7732c@s9g2000yqa.googlegroups.com>
On Apr 9, 3:34=A0pm, "david.karr" <davidmichaelk...@gmail.com> wrote:
> I've written some scripts that manipulate Zip files using
> Archive::Zip. =A0I'm now working on a script that uses "LWP::Simple" to
> download data from a URL. =A0As part of this process I'm going to have
> to download a zip file from a URL and then extract that zip file to a
> particular directory.
>
> Can I use LWP::Simple to download a binary file directly into a
> variable?
>
> I've looked at the Archive::Zip methods, and it doesn't appear as if I
> can create the Zip object directly from the contents of a variable.
> Will I have to download the zip file directly to a temporary file
> (using "getstore($url, $file)"), I would imagine), and then create the
> Zip object from that?
>
> I see the "extractToFileHandle( $fh )" method on Archive::Zip. Is that
> file handle supposed to be a directory?
Oh, never mind. Using "Archive::Extract" is much easier for
extraction.
------------------------------
Date: Sat, 10 Apr 2010 11:01:05 +0200
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 3.4 How do I find which modules are installed on my system?
Message-Id: <100420101101051627%brian.d.foy@gmail.com>
In article <aKrvn.219961$Dv7.4545@newsfe17.iad>, Steve M
<stevem_clipthis_@clubtrout.com> wrote:
> Often times I'm working on a web site for someone where I do not have
> command line access, only web browser access, and I wish to check for
> specific modules that are a little off the beaten path, such as
> Spreadsheet::WriteExcel.
>
> In such a case, the above examples are perhaps not as 'to the point' as
> a reader might wish.
I think you missed the ExtUtils::Installed example.
Also, remember it's not the FAQs job to handle every situation someone
might dream up. It's your job to take the information in the FAQ and
adapt it to your situation. There's plenty of information there for you
to do that. :)
------------------------------
Date: Mon, 12 Apr 2010 10:41:21 +0200
From: Bernard <boerni_s@bluewin.ch>
Subject: Matchtable
Message-Id: <hpumbg$uq2$1@speranza.aioe.org>
Hi all
I already searched on Google, but unfortunately I don't know what it's
exactly called what I'm looking for.
So what I'd like to do is to create a (text-)table and have a script to
find the best match. (Sorry... my english...)
So here's an example:
Table:
#field1 |field2 |field3 |Output
* |* |* |Line1
t* |* |* |Line2
t* |x* |* |Line3
* |x* |x* |Line4
Cases:
Field 1: abc
Field 2: abc
Field 3: abc
Should Match Line1
Field 1: test
Field 2: abc
Field 3: abc
Should match Line2
Field 1: test
Field 2: xyz
Field 3: abc
Should match Line3
Field 1: test
Field 2: xyz
Field 3: xyz
Should match Line4
and so on...
So I'm looking for a way to find the most exact match for given Input.
Is there a module that does this. If not how would you solve it? I know
I should include a some code of what I've already tried, but all the
ways I thought of, are just to complicated and I'm sure there must be an
easier way.
So what I thought of is:
- Build a Hash and then sort by length of key (field 1)... but that
wouldn't work for the 4th example.
- Build 3 Hashes with field 1-3 as keys and sort again by length and
give some kind of rating to the matches (so if field 1 matches with a
String with a lenght of 3 Characters it will get 3 Points)
Thank you very much in advance
Bernard
------------------------------
Date: Mon, 12 Apr 2010 07:43:03 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Matchtable
Message-Id: <8b0a78e2-bc25-4f61-90a0-ef5e0662cfea@z7g2000yqb.googlegroups.com>
On Apr 12, 4:41=A0am, Bernard <boern...@bluewin.ch> wrote:
> So what I'd like to do is to create a (text-)table and have a script to
> find the best match.
This is simply a logic problem. The easy part is building the data
structure. See script below. After you load your data into memory, you
can access it through the keys. The problem is even with small levels
of keys, the number of permutations becomes enormous. The logic you
use isn't tied to Perl, or any other language, but depends on your
data.
Here's how I would do it. It builds a three level data structure, and
then prints all the permutations. Your logic would replace the print
statement.
CC
--------script-----------
#! perl
use strict;
use warnings;
my %table;
while(<DATA>)
{
next if /^#/;
chomp;
my ($k1, $k2, $k3, $v) =3D split /\|/;
$table{$k1}{$k2}{$k3} =3D $v;
}
foreach my $k1 (keys %table)
{ foreach my $k2 (keys %{$table{$k1}})
{ foreach my $k3 (keys %{$table{$k1}{$k2}})
{ print "$k1 -- $k2 -- $k3 =3D=3D $table{$k1}{$k2}{$k3}\n";
}
}
}
exit(0);
__DATA__
#field1 |field2 |field3 |Output
* |* |* |Line1
t* |* |* |Line2
t* |x* |* |Line3
* |x* |x* |Line4
-----------output-------------
D:\PerlLearn\learning>perl table.plx
t* -- * -- * =3D=3D Line2
t* -- x* -- * =3D=3D Line3
* -- * -- * =3D=3D Line1
* -- x* -- x* =3D=3D Line4
------------------------------
Date: Mon, 12 Apr 2010 12:48:24 -0400
From: Steve C <smallpond@juno.com>
Subject: Re: Matchtable
Message-Id: <hpvit8$990$1@news.eternal-september.org>
Bernard wrote:
>
> Hi all
>
> I already searched on Google, but unfortunately I don't know what it's
> exactly called what I'm looking for.
>
> So what I'd like to do is to create a (text-)table and have a script to
> find the best match. (Sorry... my english...)
>
> So here's an example:
>
> Table:
> #field1 |field2 |field3 |Output
> * |* |* |Line1
> t* |* |* |Line2
> t* |x* |* |Line3
> * |x* |x* |Line4
>
>
> Cases:
>
> Field 1: abc
> Field 2: abc
> Field 3: abc
> Should Match Line1
>
> Field 1: test
> Field 2: abc
> Field 3: abc
> Should match Line2
>
> Field 1: test
> Field 2: xyz
> Field 3: abc
> Should match Line3
>
> Field 1: test
> Field 2: xyz
> Field 3: xyz
> Should match Line4
>
> and so on...
>
> So I'm looking for a way to find the most exact match for given Input.
> Is there a module that does this. If not how would you solve it? I know
> I should include a some code of what I've already tried, but all the
> ways I thought of, are just to complicated and I'm sure there must be an
> easier way.
>
> So what I thought of is:
> - Build a Hash and then sort by length of key (field 1)... but that
> wouldn't work for the 4th example.
> - Build 3 Hashes with field 1-3 as keys and sort again by length and
> give some kind of rating to the matches (so if field 1 matches with a
> String with a lenght of 3 Characters it will get 3 Points)
>
You don't define "best" or "most exact", so how does this problem have
any solution?
When I've seen truth tables like this, the order matters. You put
the best match at the top, and the least specific later and stop on
the first match. The last line would be your catchall "* * *"
which matches anything.
The following table would implement this:
#field1 |field2 |field3 |Output
* |x* |x* |Line4
t* |x* |* |Line3
t* |* |* |Line2
* |* |* |Line1
I don't see an objective way to decide whether "test xyz xyz" should
output Line4 or Line3 unless you make it explicit in the table by
putting one of the two first.
------------------------------
Date: Mon, 12 Apr 2010 11:31:31 -0700 (PDT)
From: "david.karr" <davidmichaelkarr@gmail.com>
Subject: Net::SMTP errors
Message-Id: <45022a07-aed7-4312-beca-aaab40fecf9b@12g2000yqi.googlegroups.com>
I'm putting some code in an existing script to send an email
notification. I've read the Net::SMTP CPAN page. I'm not doing
anything complicated. I appear to be getting SMTP errors, but I don't
understand how to fix this.
The method I wrote to send the message is the following (some data
elided):
sub sendUpdateNotification($$$) {
my ($message, $mailhost, $maildest) = @_;
my $smtp = Net::SMTP->new($mailhost,
Hello => "<mydomain>",
Debug => 1);
print "domain[" . $smtp->domain . "] maildest[" . $maildest . "]
\n";
print "message[" . $message . "]\n";
$smtp->mail($ENV{USER});
$smtp->to($maildest, {Notify => ['SUCCESS','FAILURE','DELAY']});
$smtp->data($message);
$smtp->quit;
}
The output I see is the following (some fields elided):
Net::SMTP>>> Net::SMTP(2.31)
Net::SMTP>>> Net::Cmd(2.29)
Net::SMTP>>> Exporter(5.62)
Net::SMTP>>> IO::Socket::INET(1.31)
Net::SMTP>>> IO::Socket(1.30_01)
Net::SMTP>>> IO::Handle(1.27)
Net::SMTP=GLOB(0x10b822c0)<<< 220 <our smtp host> ESMTP Sendmail
8.14.2/8.14.2; Mon, 12 Apr 2010 11:22:16 -0700
Net::SMTP=GLOB(0x10b822c0)>>> EHLO att.com
Net::SMTP=GLOB(0x10b822c0)<<< 250-<our smtp host> Hello <myhost>
[<myip>], pleased to meet you
Net::SMTP=GLOB(0x10b822c0)<<< 250-ENHANCEDSTATUSCODES
Net::SMTP=GLOB(0x10b822c0)<<< 250-PIPELINING
Net::SMTP=GLOB(0x10b822c0)<<< 250-8BITMIME
Net::SMTP=GLOB(0x10b822c0)<<< 250-SIZE 16000000
Net::SMTP=GLOB(0x10b822c0)<<< 250-DSN
Net::SMTP=GLOB(0x10b822c0)<<< 250-ETRN
Net::SMTP=GLOB(0x10b822c0)<<< 250-DELIVERBY
Net::SMTP=GLOB(0x10b822c0)<<< 250 HELP
Net::SMTP=GLOB(0x10b822c0)>>> MAIL FROM:<<myid>>
Net::SMTP=GLOB(0x10b822c0)<<< 553 5.5.4 <<myid>>... Domain name
required for sender address <myid>
Net::SMTP=GLOB(0x10b822c0)>>> RCPT TO:<<myid>@<mydomain>>
NOTIFY=SUCCESS,FAILURE,DELAY
Net::SMTP=GLOB(0x10b822c0)<<< 503 5.0.0 Need MAIL before RCPT
Net::SMTP=GLOB(0x10b822c0)>>> DATA
Net::SMTP=GLOB(0x10b822c0)<<< 503 5.0.0 Need MAIL command
Net::SMTP=GLOB(0x10b822c0)>>> QUIT
Net::SMTP=GLOB(0x10b822c0)<<< 221 2.0.0 <our smtp host> closing
connection
------------------------------
Date: Mon, 12 Apr 2010 20:48:42 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Net::SMTP errors
Message-Id: <slrnhs6qoa.hd.hjp-usenet2@hrunkner.hjp.at>
On 2010-04-12 18:31, david.karr <davidmichaelkarr@gmail.com> wrote:
> I'm putting some code in an existing script to send an email
> notification. I've read the Net::SMTP CPAN page. I'm not doing
> anything complicated. I appear to be getting SMTP errors, but I don't
> understand how to fix this.
>
> The method I wrote to send the message is the following (some data
> elided):
>
> sub sendUpdateNotification($$$) {
> my ($message, $mailhost, $maildest) = @_;
> my $smtp = Net::SMTP->new($mailhost,
> Hello => "<mydomain>",
> Debug => 1);
>
> print "domain[" . $smtp->domain . "] maildest[" . $maildest . "]
> \n";
> print "message[" . $message . "]\n";
>
> $smtp->mail($ENV{USER});
> $smtp->to($maildest, {Notify => ['SUCCESS','FAILURE','DELAY']});
> $smtp->data($message);
>
> $smtp->quit;
> }
>
> The output I see is the following (some fields elided):
[...]
> Net::SMTP=GLOB(0x10b822c0)>>> MAIL FROM:<<myid>>
> Net::SMTP=GLOB(0x10b822c0)<<< 553 5.5.4 <<myid>>... Domain name
> required for sender address <myid>
Isn't that clear enough? Your SMTP server only accepts sender addresses
with a domain name.
hp
------------------------------
Date: Mon, 12 Apr 2010 04:06:44 -0700 (PDT)
From: feltra <feltra@gmail.com>
Subject: Req Help to install IPC::SysV on WinXP + ActiveState Perl
Message-Id: <c545ca4e-265a-4fec-9930-b4533e2e883c@k33g2000yqc.googlegroups.com>
Hi,
First off, hope this is the right place for this question (or at least
its not the wrong place).
Am trying to understand how to use Shared memory in ActivePerl -
unfortunately AP doesn't seem to support it in its built-in libs.
Trying to download and install IPC::SysV thru CPAN (using ppm) gives
"OS unsupported error". I tried this both from the Cygwin-bash shell
(in which i usually work) and also from the MS-Command window - same
error. The shell displays the envar "OS" as Windows_NT.
My PC config in brief:
HP(Compaq) AMD Athlon LE-1640, 2.41GHz, 1.87G RAM
running MS-WinXP 2002 SP2
I have been able to successfully install ActivePerl and run several of
my programs, so I don't think it's anything to do with Perl per se.
How do I make this package (IPC::SysV) available? OR Should i be
using some other Shared-memory package? What would it be?
Kindly help with any / all pointers, or if more info is needed, please
indicate.
Advance thanks for all the help...
Best Regards,
-feltra
------------------------------
Date: Mon, 12 Apr 2010 12:02:35 -0400
From: Steve C <smallpond@juno.com>
Subject: Re: Req Help to install IPC::SysV on WinXP + ActiveState Perl
Message-Id: <hpvg77$l28$1@news.eternal-september.org>
feltra wrote:
> Hi,
>
> First off, hope this is the right place for this question (or at least
> its not the wrong place).
>
> Am trying to understand how to use Shared memory in ActivePerl -
> unfortunately AP doesn't seem to support it in its built-in libs.
>
> Trying to download and install IPC::SysV thru CPAN (using ppm) gives
> "OS unsupported error". I tried this both from the Cygwin-bash shell
> (in which i usually work) and also from the MS-Command window - same
> error. The shell displays the envar "OS" as Windows_NT.
>
> My PC config in brief:
> HP(Compaq) AMD Athlon LE-1640, 2.41GHz, 1.87G RAM
> running MS-WinXP 2002 SP2
>
> I have been able to successfully install ActivePerl and run several of
> my programs, so I don't think it's anything to do with Perl per se.
>
> How do I make this package (IPC::SysV) available? OR Should i be
> using some other Shared-memory package? What would it be?
>
> Kindly help with any / all pointers, or if more info is needed, please
> indicate.
> Advance thanks for all the help...
>
To the best of my knowledge, Windows XP is not a SysV operating system.
The shared memory API that I know of in Windows is shared memory-mapped
files. You might have a look at Win32::SharedFileOpen.
------------------------------
Date: Mon, 12 Apr 2010 11:00:16 -0700 (PDT)
From: feltra <feltra@gmail.com>
Subject: Re: Req Help to install IPC::SysV on WinXP + ActiveState Perl
Message-Id: <54d95b5b-eae7-4515-af79-3ca88e588723@g30g2000yqc.googlegroups.com>
On Apr 12, 9:02=A0pm, Steve C <smallp...@juno.com> wrote:
> feltra wrote:
> > Hi,
>
> > First off, hope this is the right place for this question (or at least
> > its not the wrong place).
>
> > Am trying to understand how to use Shared memory in ActivePerl -
> > unfortunately AP doesn't seem to support it in its built-in libs.
>
> > Trying to download and install IPC::SysV thru CPAN (using ppm) gives
> > "OS unsupported error". =A0 I tried this both from the Cygwin-bash shel=
l
> > (in which i usually work) and also from the MS-Command window - same
> > error. =A0 The shell displays the envar "OS" as Windows_NT.
>
> > My PC config in brief:
> > HP(Compaq) AMD Athlon LE-1640, 2.41GHz, 1.87G RAM
> > running MS-WinXP 2002 SP2
>
> > I have been able to successfully install ActivePerl and run several of
> > my programs, so I don't think it's anything to do with Perl per se.
>
> > How do I make this package (IPC::SysV) available? =A0OR =A0Should i be
> > using some other Shared-memory package? =A0 What would it be?
>
> > Kindly help with any / all pointers, or if more info is needed, please
> > indicate.
> > Advance thanks for all the help...
>
> To the best of my knowledge, Windows XP is not a SysV operating system.
> The shared memory API that I know of in Windows is shared memory-mapped
> files. =A0You might have a look at Win32::SharedFileOpen.
Thanks for the response, Steve. You are right. I also know that
WinXP is not SysV OS, but I was hoping that someone had implemented
IPC::SysV for WinXP. Turns out it is not. All I wanted was to use
Shared memory in ActivePerl, and (as you rightly said), the packages
Win32::MMF and Win32::MMF::Shareable (already available in
Activestate) seems to be the way to go... I am studying those now...
Thanks a lot once again & Best Regards,
-feltra
------------------------------
Date: Fri, 09 Apr 2010 11:33:41 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: software requirements again, take 483
Message-Id: <86r5mo1vze.fsf@mithril.chromatico.net>
>>>>> "EP" == Eric Pozharski <whynot@pozharski.name> writes:
EP> with <86vdc31lyy.fsf@mithril.chromatico.net> Charlton Wilbur wrote:
>> If you want help, you've come to the right place. If you want to
>> vent about how miserable your life is and how nobody understands
>> you, livejournal is that way.
EP> That's not the first time you're producing sigs. Quite a habit.
It has become apparent that coming up with terse bits of wisdom that fit
comfortably within four lines may be my only real shot at immortality.
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Fri, 09 Apr 2010 10:55:54 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: software requirements again, take 483
Message-Id: <87iq80r56d.fsf@lifelogs.com>
On Fri, 09 Apr 2010 11:33:41 -0400 Charlton Wilbur <cwilbur@chromatico.net> wrote:
CW> It has become apparent that coming up with terse bits of wisdom that fit
CW> comfortably within four lines may be my only real shot at immortality.
Hey, it worked for Martial (http://en.wikipedia.org/wiki/Martial)
Ted
------------------------------
Date: 11 Apr 2010 02:36:15 GMT
From: "David Formosa (aka ? the Platypus)" <dformosa@usyd.edu.au>
Subject: Re: software requirements again, take 483
Message-Id: <4bc1359f$0$27811$c3e8da3@news.astraweb.com>
On Thu, 01 Apr 2010 20:25:52 -0400, Charlton Wilbur
<cwilbur@chromatico.net> wrote:
[...]
> The fundamental rule, however, is that before you type a single
> character of Perl you should have a clear, unambiguous statement, agreed
> to by the business owner of the process you're automating or
> facilitating, of what the requirements are for the phase of development
> that you're in.
In most orginisations that will never ever happen.
------------------------------
Date: Sun, 11 Apr 2010 18:43:46 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: software requirements again, take 483
Message-Id: <867hod1ufx.fsf@mithril.chromatico.net>
>>>>> "DF" == David Formosa (aka ? the Platypus) <dformosa@usyd.edu.au> writes:
DF> On Thu, 01 Apr 2010 20:25:52 -0400, Charlton Wilbur
DF> <cwilbur@chromatico.net> wrote:
>> The fundamental rule, however, is that before you type a single
>> character of Perl you should have a clear, unambiguous statement,
>> agreed to by the business owner of the process you're automating
>> or facilitating, of what the requirements are for the phase of
>> development that you're in.
DF> In most orginisations that will never ever happen.
I refuse to believe that my organization is that unusual. Admittedly,
the statements tend to start out at a high-level, but the high-level
requirements and most of the medium-level requirements are in place
before any coding starts. A lot of the low-level requirements are
hashed out between developers and business owners when the need for them
becomes apparent.
Do people in "most organizations" *really* start coding madly before
anyone has a clear idea of what the problem to be solved is?
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
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:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 V11 Issue 2908
***************************************