[32141] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3406 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 8 11:09:25 2011

Date: Wed, 8 Jun 2011 08:09:07 -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           Wed, 8 Jun 2011     Volume: 11 Number: 3406

Today's topics:
    Re: how to access thunderbird's address book. <news@lawshouse.org>
    Re: how to access thunderbird's address book. <justin.1104@purestblue.com>
    Re: how to access thunderbird's address book. <news@lawshouse.org>
    Re: How to keep SQL statement preparation and executing <rweikusat@mssgmbh.com>
    Re: How to keep SQL statement preparation and executing <m@rtij.nl.invlalid>
    Re: Howto conjoin information from two hash tables? <scottie383@gmail.com>
    Re: Installing Perl without man pages? <sherm.pendley@gmail.com>
    Re: Installing Perl without man pages? <sherm.pendley@gmail.com>
    Re: Installing Perl without man pages? <sherm.pendley@gmail.com>
    Re: Installing Perl without man pages? <sherm.pendley@gmail.com>
    Re: Installing Perl without man pages? <uri@StemSystems.com>
    Re: Module for parsing .authinfo? <mvdwege@mail.com>
    Re: Module for parsing .authinfo? <tzz@lifelogs.com>
    Re: Module for parsing .authinfo? <tzz@lifelogs.com>
        parameter value to perl script <moonhkt@gmail.com>
        Warning in one statement, not in apparently identical o <news@lawshouse.org>
    Re: Warning in one statement, not in apparently identic <NoSpamPleaseButThisIsValid3@gmx.net>
    Re: Warning in one statement, not in apparently identic <news@lawshouse.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 08 Jun 2011 12:14:07 +0100
From: Henry Law <news@lawshouse.org>
Subject: Re: how to access thunderbird's address book.
Message-Id: <Y6KdnahQhukdxHLQnZ2dnUVZ8vOdnZ2d@giganews.com>

On 05/06/11 10:09, Andre wrote:
> I am writing a script that send file by e-mail. I would like to select e-
> mail adresses from thunderbird's address book. Is there a way to do this??

This is notoriously hard: Thunderbird stores its address book in an 
obscure semi-proprietary format which (IIRC) nobody outside the 
development team understands clearly and for which no-one, it seems, has 
written any access modules.

You can export the address book to LDAP format and read it, but if the 
book changes often that may not be what you want.

If you have a real heavy-duty requirement to do this the best option is 
probably to go the other way round: get Thunderbird to use an external 
LDAP directory for its addresses, then write Perl to do the same (there 
are CPAN modules which will help).

-- 

Henry Law            Manchester, England


------------------------------

Date: Wed, 8 Jun 2011 14:34:47 +0100
From: Justin C <justin.1104@purestblue.com>
Subject: Re: how to access thunderbird's address book.
Message-Id: <nca4c8-io2.ln1@zem.masonsmusic.co.uk>

On 2011-06-08, Henry Law <news@lawshouse.org> wrote:
> On 05/06/11 10:09, Andre wrote:
>> I am writing a script that send file by e-mail. I would like to select e-
>> mail adresses from thunderbird's address book. Is there a way to do this??
>
> This is notoriously hard: Thunderbird stores its address book in an 
> obscure semi-proprietary format which (IIRC) nobody outside the 
> development team understands clearly and for which no-one, it seems, has 
> written any access modules.

AIUI Thunderbird source is available, I can hardly see that the address
format cannot be found/understood by someone who really wants to know.

   Justin.

-- 
Justin C, by the sea.


------------------------------

Date: Wed, 08 Jun 2011 15:51:30 +0100
From: Henry Law <news@lawshouse.org>
Subject: Re: how to access thunderbird's address book.
Message-Id: <9fednQIiQ7fpEXLQnZ2dnUVZ8hydnZ2d@giganews.com>

On 08/06/11 14:34, Justin C wrote:
> AIUI Thunderbird source is available, I can hardly see that the address
> format cannot be found/understood by someone who really wants to know.

Justin, that's true, and so what you say is true in theory.  But if you 
were to look at the Perl modules which do access the Mork DB format you 
would see that the job still isn't exactly easy, even though one could 
in theory find out everything about the format by reading the Mozilla 
code.  Look at 
http://search.cpan.org/~simonw/File-Mork-0.3/lib/File/Mork.pm#THE_UGLY_TRUTH_LAID_BARE 
for example.

Anyway, I judged from the original post that we are not dealing with a 
Mozilla code hacker here, and was trying to be helpful.  If I didn't 
post the whole truth as a result, ok you win.

-- 

Henry Law            Manchester, England


------------------------------

Date: Wed, 08 Jun 2011 15:55:21 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: How to keep SQL statement preparation and executing code together
Message-Id: <878vtcpe3q.fsf@sapphire.mobileactivedefense.com>

Martijn Lievaart <m@rtij.nl.invlalid> writes:
> On Sun, 05 Jun 2011 16:29:38 +0100, Rainer Weikusat wrote:
>
>> The distance from here (Reading, UK) to Brisbane is also 'pretty close
>> to zero', compared to the distance between earth and say, Sirius. OTOH,
>> I will be going into the city to buy a couple of things later and I
>> won't first travel to Brisbane and back just because this distance can
>> be regarded as 'pretty close to zero' when viewed from a particular
>> perspective.
>
> But if you're going to Sirius and back, going to Brisbane for prepare()
> ation may be sensible.
>
> You are really advocating premature optimization here.

Consider to stop using terms you don't understand in contexts they
were never supposed to apply to. In case of the 'premature
optimization' the criticized behaviour was 'trying to come up with an
optimal machine code implementation of some algorithm instead of
focussing on producing a working one first'. It makes a lot of sense
in this context. It make exactly no sense here because different
'working solutions' were presented and their technical properties
discussed.

[...]

> Mind you, I'm not saying that in this particular case the code gets any 
> better (or worse), I just want to point out the fallacy of the above 
> argument.

There is no fallacy in the analogy presented above because it was
supposed to demonstrate that 'pretty close to zero' is not a technical
property but a judgement someone made about something, as seen from a
specific perspective, and that what is considered to be 'pretty close
to zero' when viewed from a specific angle might as well be
'prohibitively expensive' when viewed from another.


------------------------------

Date: Wed, 8 Jun 2011 13:48:41 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: How to keep SQL statement preparation and executing code together
Message-Id: <p544c8-2nv.ln1@news.rtij.nl>

On Sun, 05 Jun 2011 16:29:38 +0100, Rainer Weikusat wrote:

> The distance from here (Reading, UK) to Brisbane is also 'pretty close
> to zero', compared to the distance between earth and say, Sirius. OTOH,
> I will be going into the city to buy a couple of things later and I
> won't first travel to Brisbane and back just because this distance can
> be regarded as 'pretty close to zero' when viewed from a particular
> perspective.

But if you're going to Sirius and back, going to Brisbane for prepare()
ation may be sensible.

You are really advocating premature optimization here. If the code 
becomes more maintainable at a negligible runtime cost, do it.

Mind you, I'm not saying that in this particular case the code gets any 
better (or worse), I just want to point out the fallacy of the above 
argument.

M4


------------------------------

Date: Wed, 8 Jun 2011 04:42:35 -0700 (PDT)
From: Scottie <scottie383@gmail.com>
Subject: Re: Howto conjoin information from two hash tables?
Message-Id: <c7b84f65-d5d3-454f-91f7-7ba1b1042ab4@v10g2000yqn.googlegroups.com>

Hi everyone!
It's me again, Scottie - the ordinary programmer. :-/
Now I've a problem with deleting the values from the array. I wrote a
piece of code. This is not working well and I know that this is
terrible. Well, look below.

------------------ 8< ------------------
#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;

my %channel = (
    ch1 => [
        'allocated channel: ch1',
        'channel ch1: SID=596 device type=DISK',
        'channel ch1: starting compressed full datafile backup set',
        'channel ch1: specifying datafile(s) in backup set',
        'exit'
    ],
    ch2 => [
        'allocated channel: ch2',
        'channel ch2: SID=15 device type=DISK',
        'channel ch2: starting compressed full datafile backup set',
        'channel ch2: specifying datafile(s) in backup set',
        'exit'
    ],
);


foreach (keys %channel) {
    next if /exit/;
    shift ( @{$channel{$_}} );
}

print Dumper \%channel;
------------------ 8< ------------------

This code creates the following output:
$VAR1 = {
          'ch2' => [
                     'channel ch2: SID=15 device type=DISK',
                     'channel ch2: starting compressed full datafile
backup set',
                     'channel ch2: specifying datafile(s) in backup
set',
                     'exit'
                   ],
          'ch1' => [
                     'channel ch1: SID=596 device type=DISK',
                     'channel ch1: starting compressed full datafile
backup set',
                     'channel ch1: specifying datafile(s) in backup
set',
                     'exit'
                   ]
};

As you can see, there is no first lines ("$channel{ch1}[0]" and
"$channel{ch2}[0]"), but I expect that output will be as follows:
$VAR1 = {
          'ch2' => [
                     'exit'
                   ],
          'ch1' => [
                     'exit'
                   ]
};

Can you enlighten me once again, please.

Best regards,
--
Scottie


------------------------------

Date: Wed, 08 Jun 2011 01:48:27 -0400
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: Installing Perl without man pages?
Message-Id: <m2hb80kh5g.fsf@sherm.shermpendley.com>

Keith Thompson <kst-u@mib.org> writes:

> Sherm Pendley <sherm.pendley@gmail.com> writes:
>> What's the secret sauce for installing Perl without man pages?
>>
>> I've tried configuring with "-Dman1dir=' ' -Dman3dir=' '" and with
>> "-Uman1dir -Uman3dir", and both resulted in the man pages all being
>> dumped into my top-level install directory.
>
> Would installing it with man pages and then deleting the directory
> satisfy your requirements?

That's what I do now, as a workaround. But building them just to delete
them immediately afterword increases the build time for no good reason.

> Why don't you want the man pages?

This is for an embedded install of libperl.a in an application framework,
so I'm trying to trim it down to the bare minimum required at run time.

sherm--


------------------------------

Date: Wed, 08 Jun 2011 01:59:09 -0400
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: Installing Perl without man pages?
Message-Id: <m2d3iokgnm.fsf@sherm.shermpendley.com>

"Uri Guttman" <uri@StemSystems.com> writes:

> so setting man1dir to '' should work

I tried that earlier, but admittedly didn't let it finish - the first
four lines of output from Configure were:

    Configure: use '-U symbol=', not '-D symbol='.
    Configure: ignoring -D man1dir=
    Configure: use '-U symbol=', not '-D symbol='.
    Configure: ignoring -D man3dir=

I killed Configure & restarted it with -U as soon as I saw that, since
the "ignoring ..." messages didn't look promising and -U is what the
other messages suggest using instead. I'll run it again though (it's
actually running right now) and let it finish, just in case the above
warnings are misleading.

> . i would edit this script and dump
> the values it sees in its opts to see if you are getting '' set in
> there. maybe it is a bug no one has found before or you aren't getting
> the '' passed in for some reason.

Good idea, I'll try that.

sherm--


------------------------------

Date: Wed, 08 Jun 2011 02:07:28 -0400
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: Installing Perl without man pages?
Message-Id: <m28vtckg9r.fsf@sherm.shermpendley.com>

"Uri Guttman" <uri@StemSystems.com> writes:

>>>>>> "SP" == Sherm Pendley <sherm.pendley@gmail.com> writes:
>
>   SP> merlyn@stonehenge.com (Randal L. Schwartz) writes:
>   >>>>>>> "J" == J Gleixner <glex_no-spam@qwest-spam-no.invalid> writes:
>   >> 
>   J> On 06/07/11 02:58, Sherm Pendley wrote:
>   >>>> What's the secret sauce for installing Perl without man pages?
>   >>>> 
>   >>>> I've tried configuring with "-Dman1dir=' ' -Dman3dir=' '" and with
>   >>>> "-Uman1dir -Uman3dir", and both resulted in the man pages all being
>   >>>> dumped into my top-level install directory.
>
> sub pod2man {
>     # @script is scripts names if we are installing manpages embedded 
>     # in scripts, () otherwise
>     my($poddir, $mandir, $manext, @script) = @_;
>     if ($mandir eq ' ' or $mandir eq '') {
 ...
> so setting man1dir to '' should work.

Now that I look at it again, that if() implies that setting it to ' '
*should* have worked too, doesn't it?

Setting it to '' results in just what the warnings I mentioned earlier
suggested would happen - Configure ignored it, and "make install"
created the man/ directory anyway.

sherm--


------------------------------

Date: Wed, 08 Jun 2011 03:35:08 -0400
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: Installing Perl without man pages?
Message-Id: <m27h8wsrmb.fsf@sherm.shermpendley.com>

"Uri Guttman" <uri@StemSystems.com> writes:

> the installman script has this:

Thanks - pointing out that this step is in a separate script led to a
solution that's a crude hack, but does work. From my install script:

    echo '#!./perl
    exit 0;
    ' > ./installman

Nuke the site from orbit - it's the only way to be sure. :-)

sherm--


------------------------------

Date: Wed, 08 Jun 2011 03:53:02 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Installing Perl without man pages?
Message-Id: <87sjrkyd29.fsf@quad.sysarch.com>

>>>>> "SP" == Sherm Pendley <sherm.pendley@gmail.com> writes:

  SP> "Uri Guttman" <uri@StemSystems.com> writes:
  >> the installman script has this:

  SP> Thanks - pointing out that this step is in a separate script led to a
  SP> solution that's a crude hack, but does work. From my install script:

  SP>     echo '#!./perl
  SP>     exit 0;
  SP>     ' > ./installman

all i did was grep man1dir in the perl src dir and found that script.

  SP> Nuke the site from orbit - it's the only way to be sure. :-)

and then you need to watch for the fallout! :)

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


------------------------------

Date: Wed, 08 Jun 2011 08:38:47 +0200
From: Mart van de Wege <mvdwege@mail.com>
Subject: Re: Module for parsing .authinfo?
Message-Id: <86boy8x1xk.fsf@gareth.avalon.lan>

Wolf Behrenhoff <NoSpamPleaseButThisIsValid3@gmx.net> writes:

>  For example, to me it looked like Tim was asking (politely) whether a
> module existed. I didn't read "Looking forward to your rewrite," as a
> command to [Uri] but rather to put more emphasis on his point that one
> has to take care about several things (even if they are very simple).
>
As someone who also reacted a bit stung by that comment: it sounded
needlessly sarcastic. I took it as a complete dismissal of Uri's
suggestions, Uri obviously took it that way as well.

Since subtle nuance does not carry over very well, unless you *mean*
being sarcastic, it is incumbent on the writer to know the implications
of their words. Tim either was being sarcastically dismissive, or he was
being a bad communicator. Either way it is unfair, in my opinion, to
chide Uri (and me) for being pissed off at Tim's tone.

Mart

-- 
"We will need a longer wall when the revolution comes."
    --- AJS, quoting an uncertain source.


------------------------------

Date: Wed, 08 Jun 2011 09:40:11 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Module for parsing .authinfo?
Message-Id: <877h8wfktw.fsf@lifelogs.com>

On Tue, 07 Jun 2011 19:12:34 -0400 "Uri Guttman" <uri@StemSystems.com> wrote: 

UG> well, note that tim hasn't responded since then even when i showed how
UG> to do it quickly. i say "Looking forward to your rewrite" is asking me
UG> to do his work for him which is not something i take lightly. i said it
UG> was easy and he said so do it yourself. i then did it myself and proved
UG> it was easy. that is all there is to it. yes, i was pissed so it
UG> motivated me to spend the 15 minutes coding that up. will tim
UG> acknowledge the code or whatever? i doubt it. it shows who is more
UG> connected to reality. :)

What do you expect Tim to say at this point?  You're obviously so
fixated on being "right" and "winning the argument" that you don't want
to be civil even when given the chance, and you keep rehashing your side
of the argument.

Ted


------------------------------

Date: Wed, 08 Jun 2011 09:45:16 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Module for parsing .authinfo?
Message-Id: <8739jkfklf.fsf@lifelogs.com>

On Wed, 08 Jun 2011 08:38:47 +0200 Mart van de Wege <mvdwege@mail.com> wrote: 

MvdW> Wolf Behrenhoff <NoSpamPleaseButThisIsValid3@gmx.net> writes:
>> For example, to me it looked like Tim was asking (politely) whether a
>> module existed. I didn't read "Looking forward to your rewrite," as a
>> command to [Uri] but rather to put more emphasis on his point that one
>> has to take care about several things (even if they are very simple).
>> 
MvdW> As someone who also reacted a bit stung by that comment: it sounded
MvdW> needlessly sarcastic. I took it as a complete dismissal of Uri's
MvdW> suggestions, Uri obviously took it that way as well.

There are many languages in the world; German (which I guess is Tim's
primary language) has completely different sentence structure from
English.  I usually comment as an aside ("...unless you meant it
sarcastically...")  on such things, and almost always they are simple
misunderstandings.  Japanese speakers are also very hard to gauge,
sometimes they sound really rude--usually it's the language getting in
the way.

MvdW> Since subtle nuance does not carry over very well, unless you *mean*
MvdW> being sarcastic, it is incumbent on the writer to know the implications
MvdW> of their words. Tim either was being sarcastically dismissive, or he was
MvdW> being a bad communicator. Either way it is unfair, in my opinion, to
MvdW> chide Uri (and me) for being pissed off at Tim's tone.

Well, to start, don't assume anything is sarcastic on Usenet, how about
that?  Because sarcasm is very underused there.[1]

Ted

[1] that was not sarcastic at all, at all[2]

[2] and neither was that[3]

[3] heh


------------------------------

Date: Tue, 7 Jun 2011 22:49:14 -0700 (PDT)
From: moonhkt <moonhkt@gmail.com>
Subject: parameter value to perl script
Message-Id: <bfc382ae-8d3e-453f-8dcb-ca06e3af2817@r1g2000yqg.googlegroups.com>


Hi All
Do you know how to pass parameter to perl script with below format ?


XVAL=$1 ; export XVAL
j=$( perl  <<-'EOF'
  use strict;
  use POSIX qw( strftime );
  use Getopt::Std;
  my ($ymd,$i) ;
  $i=$ENV{'XVAL'};
  $ymd=strftime("%Y/%m/%d",localtime(time + $i *86400));
  print $ymd;
EOF
)


------------------------------

Date: Wed, 08 Jun 2011 12:26:27 +0100
From: Henry Law <news@lawshouse.org>
Subject: Warning in one statement, not in apparently identical one
Message-Id: <XNCdnczHFob5wXLQnZ2dnUVZ8kidnZ2d@giganews.com>

I'm trying to write proper Perlish shorthand for some of the tests in a 
subroutine, which when the parameters are wrong have to return FALSE as 
well as setting $@.  Boiled down, it looks like this:

#!/usr/bin/perl

use strict; use warnings;

sub my_sub{
   my $file = shift;
   $@ = "No file supplied" and return 0 unless $file;
   $@ = "File '$file' not found or not a readable file" and return 0 
unless -r $file;
}

The compiler objects to the first one "Found = in conditional, should be 
== at error.pl line 7" but not to the second; but unless my eyes have 
gone funny they are syntactically identical.

It's only a warning but I have a policy of requiring clean compiles. 
What am I doing wrong?

-- 

Henry Law            Manchester, England


------------------------------

Date: Wed, 08 Jun 2011 13:36:31 +0200
From: Wolf Behrenhoff <NoSpamPleaseButThisIsValid3@gmx.net>
Subject: Re: Warning in one statement, not in apparently identical one
Message-Id: <4def5ebf$0$7611$9b4e6d93@newsspool1.arcor-online.net>

On 08.06.2011 13:26, Henry Law wrote:
> I'm trying to write proper Perlish shorthand for some of the tests in a 
> subroutine, which when the parameters are wrong have to return FALSE as 
> well as setting $@.  Boiled down, it looks like this:
> 
> #!/usr/bin/perl
> 
> use strict; use warnings;
> 
> sub my_sub{
>    my $file = shift;
>    $@ = "No file supplied" and return 0 unless $file;
>    $@ = "File '$file' not found or not a readable file" and return 0 
> unless -r $file;
> }
> 
> The compiler objects to the first one "Found = in conditional, should be 
> == at error.pl line 7" but not to the second; but unless my eyes have 
> gone funny they are syntactically identical.
> 
> It's only a warning but I have a policy of requiring clean compiles. 
> What am I doing wrong?

In line 7 you basically have:
assignment and return

So Perl warns that the assignment should probably be a comparison,
because otherwise the "and" does not make sense here as the constant
string you are assigning is always true.

You can use the comma operator instead of "and".

Another thing: you want your sub to return FALSE. But you are returning
0 instead. This is a difference in list context: 1 element (the 0) is
true. So if you want to return false, just write "return;".

- Wolf


------------------------------

Date: Wed, 08 Jun 2011 12:45:30 +0100
From: Henry Law <news@lawshouse.org>
Subject: Re: Warning in one statement, not in apparently identical one
Message-Id: <F4GdnZZFPdlG_XLQnZ2dnUVZ8oqdnZ2d@giganews.com>

On 08/06/11 12:36, Wolf Behrenhoff wrote:
>>     $@ = "No file supplied" and return 0 unless $file;
>>     $@ = "File '$file' not found or not a readable file" and return 0

> In line 7 you basically have:
> assignment and return
>
> So Perl warns that the assignment should probably be a comparison,
> because otherwise the "and" does not make sense here as the constant
> string you are assigning is always true.

Aha!  Thank you.  Since posting I experimented, and found that the 
message went away when I had any variable in the string; you've 
explained why.

> You can use the comma operator instead of "and".

One "speaks" a particular version of the language and the comma operator 
has not been in my particular dialect up to now.  It will be from this 
moment.

> Another thing: you want your sub to return FALSE. But you are returning
> 0 instead. This is a difference in list context: 1 element (the 0) is
> true. So if you want to return false, just write "return;".

Indeed; I've been bitten like that before -- why don't I remember the 
sources of pain?

-- 

Henry Law            Manchester, England


------------------------------

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 3406
***************************************


home help back first fref pref prev next nref lref last post