[31407] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2659 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 30 00:09:42 2009

Date: Thu, 29 Oct 2009 21:09: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           Thu, 29 Oct 2009     Volume: 11 Number: 2659

Today's topics:
    Re: How to reverse date? (David Canzi)
        Perl to read EMBEDDED Outlook email? <yudelin100@gmail.com>
    Re: Perl to read EMBEDDED Outlook email? <ben@morrow.me.uk>
        robin.comuf.com <robin1@cnsp.com>
    Re: software engineering, program construction <cartercc@gmail.com>
    Re: software engineering, program construction <uri@StemSystems.com>
    Re: software engineering, program construction <cartercc@gmail.com>
    Re: software engineering, program construction <uri@StemSystems.com>
    Re: software engineering, program construction <jurgenex@hotmail.com>
    Re: software engineering, program construction <jurgenex@hotmail.com>
    Re: software engineering, program construction <uri@StemSystems.com>
    Re: software engineering, program construction <m@rtij.nl.invlalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 29 Oct 2009 18:34:00 +0000 (UTC)
From: dmcanzi@remulak.uwaterloo.ca (David Canzi)
Subject: Re: How to reverse date?
Message-Id: <hccn6o$b3$1@rumours.uwaterloo.ca>

In article <l_3Gm.94178$Xw3.58949@en-nntp-04.dc1.easynews.com>,
nobody  <nobody@nowhere.com> wrote:
>If I have a date in the format YYYYMMDD like:
>
>20090329
>
>How can I change that to:
>
>03-29-2009
>
>-Thanks!

People looking at your program's output won't be able to tell
whether 11-12-2009 is Nov 12th or Dec 11th.  Use an unambiguous
date format:

$d = '20090329';
$d =~ s/(\d{4})(\d\d)(\d\d)/$1-$2-$3/
print "$d\n";

-- 
David Canzi			| Every time you write clever code in
				| production software, God kills a kitten.


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

Date: Thu, 29 Oct 2009 13:41:49 -0700 (PDT)
From: maylin <yudelin100@gmail.com>
Subject: Perl to read EMBEDDED Outlook email?
Message-Id: <9aa9f9a9-5c95-457b-863b-68f6eb5d8410@y23g2000yqd.googlegroups.com>

Hope some experts can help me on this -

If you have an Outlook email that includes an attached email, how can
you use Perl to read/parse that embedded email? I tried to use
WIN32::OLE, and I know you can get the mail body this way:
$mailbody=$folder->Items->Item($i)->Body;

Now this email also has an attached email and I need to get its mail
body. So I used following line to get the attached email:
my $attach = $folder->Items->Item($i)->Attachments();

After this line runs the $attach is that embedded email (and I can
save the $attach to a text file), but how to open it to get its email
body?

I tried following but none of them worked:

$mailbody=$attach->Body; # not working
$mailbody=$attach->Items->Item(1)->Body; # not working
$mailbody = $folder->Items->Item($i)->Attachments()->Body; # not
working

It'll be highly appreciated if somebody tells me where is wrong or
where to find some sample codes.


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

Date: Fri, 30 Oct 2009 00:01:22 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Perl to read EMBEDDED Outlook email?
Message-Id: <ivmpr6-ph4.ln1@osiris.mauzo.dyndns.org>


Quoth maylin <yudelin100@gmail.com>:
> Hope some experts can help me on this -
> 
> If you have an Outlook email that includes an attached email, how can
> you use Perl to read/parse that embedded email? I tried to use
> WIN32::OLE, and I know you can get the mail body this way:
> $mailbody=$folder->Items->Item($i)->Body;

You do not have a Perl problem. You have an Outlook problem. If you can
find some VBA (or whatever) that will do what you want, translating it
into Perl is trivial.

Ben



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

Date: Thu, 29 Oct 2009 09:57:43 -0600
From: "Robin" <robin1@cnsp.com>
Subject: robin.comuf.com
Message-Id: <hcce0q$2e7i$1@adenine.netfront.net>

don't commit suicide. It is well worth it to stay alive.

Sucide support chat channel/bbs.

http://robin.comuf.com
-- 
Robin

--
robin1@cnsp.com




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

Date: Thu, 29 Oct 2009 08:11:13 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: software engineering, program construction
Message-Id: <8ffb2668-3b4e-4ef9-a446-893730babc39@a21g2000yqc.googlegroups.com>

On Oct 29, 10:10=A0am, J=FCrgen Exner <jurge...@hotmail.com> wrote:
> No, you don't get it. The difference is that I can see what data items
> the function is consuming and producing by simply looking at the
> function call. I do not have to dig in some obscure documentation that
> is not in sync with the actual code, I do not have to maintain comments
> "Reads global variable X and Y, modifies Y and Z" which we all know are
> never correct anyway, I do not have to inspect the code of the function
> to know what data items it is using.

You didn't answer the question, or maybe I didn't make the question
clear enough.

If you have a large data structure that you need to both modify and
read (at different times), why make a copy of the data structure to
pass as an argument to the function only to return the copy to
overwrite the original? In other words, why do this:
my %data;
%data =3D get_data(%data);
%data =3D modify_data(%data);

or this:
my %data;
get_data(\%data);
modify_data(\%data);

when you can just as clearly do this:
my %data;
&get_data;
&modify_data;

You do not have to dig in obscure documentation because you can see
clearly what the function is doing by the descriptive name. Also, I
guess I want to stress that this is a specific script for a specific
purpose, a special purpose tool as it were, and not a general purpose
script that applies to a general problem. FOR THIS LIMITED PURPOSE I
just don't see the point of passing an argument either by reference or
by value.

I agree that for more substantial programs for a more general purpose
that the principles expressed (about variable localization, passing
identifiable arguments, returning specific values, etc.) are best
practices.

CC.


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

Date: Thu, 29 Oct 2009 11:28:42 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: software engineering, program construction
Message-Id: <87bpjq2p91.fsf@quad.sysarch.com>

>>>>> "c" == ccc31807  <cartercc@gmail.com> writes:

  c> You didn't answer the question, or maybe I didn't make the question
  c> clear enough.

the latter.

  c> If you have a large data structure that you need to both modify and
  c> read (at different times), why make a copy of the data structure to
  c> pass as an argument to the function only to return the copy to
  c> overwrite the original? In other words, why do this:
  c> my %data;
  c> %data = get_data(%data);
  c> %data = modify_data(%data);

you don't do that. you pass in a ref to the hash. no copies are made and
you still isolate the code logic so it doesn't directly access any
globals. having globals (really static data in this case) isn't bad but
accessing them in a global way is bad and a very bad habit you need to
unlearn. 

  c> or this:
  c> my %data;
  c> get_data(\%data);
  c> modify_data(\%data);

  c> when you can just as clearly do this:
  c> my %data;
  c> &get_data;
  c> &modify_data;

STOP USING & for sub calls. this is true regardless of the globals!!

and this is a case where isolation wins over your incorrect perception
of clarity. if you wanted to move the subs elsewhere or reuse them you
need the better api of passing in the hash ref. your code is hardwired
to only use those variables and only be in that file with the
globals. do you see the difference? you will now argue that this code
will only live here. that is bogus as in other cases it won't stay there
forever. then you have to rewrite all the code. learn the better api
design now and practice it.

  c> You do not have to dig in obscure documentation because you can see
  c> clearly what the function is doing by the descriptive name. Also, I
  c> guess I want to stress that this is a specific script for a specific
  c> purpose, a special purpose tool as it were, and not a general purpose
  c> script that applies to a general problem. FOR THIS LIMITED PURPOSE I
  c> just don't see the point of passing an argument either by reference or
  c> by value.

no. you don't get it. descriptive names can lie. you can't move the code
as i said above. that is worse than your claim of 'clarity' which is
actually false. 

  c> I agree that for more substantial programs for a more general purpose
  c> that the principles expressed (about variable localization, passing
  c> identifiable arguments, returning specific values, etc.) are best
  c> practices.

that is true for all sizes of programs. you haven't demonstrated the
ability to code in that style and keep defending (poorly at that) why
your global style is good or even better. it isn't good or better in any
circumstances. passing in the refs is much cleaner, more mainatainable,
more extendable, easier to move, easier to reuse, etc. there isn't a
loss in the bunch there.

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: Thu, 29 Oct 2009 08:53:00 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: software engineering, program construction
Message-Id: <82fce0db-9f4a-49cb-85ac-72581bd35851@b18g2000vbl.googlegroups.com>

On Oct 29, 11:28=A0am, "Uri Guttman" <u...@StemSystems.com> wrote:
>  having globals (really static data in this case) isn't bad but
> accessing them in a global way is bad and a very bad habit you need to
> unlearn.

Okay.

> STOP USING & for sub calls. this is true regardless of the globals!!

Why? What is the reason for an ironclad, absolute rule against using &
for user defined function calls?

> your code is hardwired
> to only use those variables and only be in that file with the
> globals. do you see the difference? you will now argue that this code
> will only live here. that is bogus as in other cases it won't stay there
> forever. then you have to rewrite all the code. learn the better api
> design now and practice it.

But what if it WILL only live here? What if it's a one time script
that you KNOW that you will only use once and then delete permanently?


> descriptive names can lie.

That they can do!

> you can't move the code as i said above.

This is also true, but it doesn't account for those occasions when the
code is guaranteed not to move.

> that is true for all sizes of programs. you haven't demonstrated the
> ability to code in that style and keep defending (poorly at that) why

Don't mistake 'defending' a position for the purpose of advocating it
with 'defending' a position for the purpose of testing it. Just
because a scientist attempts to falsify a hypothesis doesn't mean that
he doesn't believe that it's false -- he simply wants to test it. I'm
not advocating a particular style, just asking questions.

> your global style is good or even better. it isn't good or better in any
> circumstances. passing in the refs is much cleaner, more mainatainable,
> more extendable, easier to move, easier to reuse, etc. there isn't a
> loss in the bunch there.

QED

CC


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

Date: Thu, 29 Oct 2009 12:05:07 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: software engineering, program construction
Message-Id: <87tyxi18zw.fsf@quad.sysarch.com>

>>>>> "c" == ccc31807  <cartercc@gmail.com> writes:

  c> On Oct 29, 11:28 am, "Uri Guttman" <u...@StemSystems.com> wrote:
  >> having globals (really static data in this case) isn't bad but
  >> accessing them in a global way is bad and a very bad habit you need to
  >> unlearn.

  c> Okay.

  >> STOP USING & for sub calls. this is true regardless of the globals!!

  c> Why? What is the reason for an ironclad, absolute rule against using &
  c> for user defined function calls?

it is documented in perlsub and covered in this group MANY times. rtfm
or google for it so i don't have to repeat it again. or you can trust
the group's knowledge that is it bad and also very old perl4 style. also
it isn't even needed anymore if you call subs with foo().

  >> your code is hardwired
  >> to only use those variables and only be in that file with the
  >> globals. do you see the difference? you will now argue that this code
  >> will only live here. that is bogus as in other cases it won't stay there
  >> forever. then you have to rewrite all the code. learn the better api
  >> design now and practice it.

  c> But what if it WILL only live here? What if it's a one time script
  c> that you KNOW that you will only use once and then delete permanently?


  >> descriptive names can lie.

  c> That they can do!

  >> you can't move the code as i said above.

  c> This is also true, but it doesn't account for those occasions when the
  c> code is guaranteed not to move.

that is NEVER a guarantee. learn that too. code moves. as i said, if it
doesn't here, it will in some other scripts. the bad habit needs to be
changed so you don't get bitten later.

  >> that is true for all sizes of programs. you haven't demonstrated the
  >> ability to code in that style and keep defending (poorly at that) why

  c> Don't mistake 'defending' a position for the purpose of advocating it
  c> with 'defending' a position for the purpose of testing it. Just
  c> because a scientist attempts to falsify a hypothesis doesn't mean that
  c> he doesn't believe that it's false -- he simply wants to test it. I'm
  c> not advocating a particular style, just asking questions.

you are not testing or anything here. you are defending your poor habit
against a cadre of experts in perl. you come here for help and even
after repeated explanations you keep 'testing' it. that is called
defending with little to stand upon. it gets tiresome. just know that
you lower your ability to be hired by holding on to such poor coding
habits.

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: Thu, 29 Oct 2009 10:28:17 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: software engineering, program construction
Message-Id: <8pjje55h5m4v61cl325ho3u0k3m6fakaqr@4ax.com>

ccc31807 <cartercc@gmail.com> wrote:
>On Oct 29, 10:10 am, Jürgen Exner <jurge...@hotmail.com> wrote:
>You didn't answer the question, or maybe I didn't make the question
>clear enough.
>
>If you have a large data structure that you need to both modify and
>read (at different times), why make a copy of the data structure to
>pass as an argument to the function only to return the copy to
>overwrite the original? In other words, why do this:
>my %data;
>%data = get_data(%data);
>%data = modify_data(%data);
>
>or this:
>my %data;
>get_data(\%data);
>modify_data(\%data);
>
>when you can just as clearly do this:
>my %data;
>&get_data;
>&modify_data;

Exactly because it is not as clear. 

I for one am totally mystified why on earth you are passing @_ to those
functions explicitely without ever using it while at the same time you
are passing the actual data behind the back in global variables.
This is like setting the left turn signal and then turning right.

>You do not have to dig in obscure documentation because you can see
>clearly what the function is doing by the descriptive name. Also, I
>guess I want to stress that this is a specific script for a specific
>purpose, a special purpose tool as it were, and not a general purpose
>script that applies to a general problem. FOR THIS LIMITED PURPOSE I
>just don't see the point of passing an argument either by reference or
>by value.
>
>I agree that for more substantial programs for a more general purpose
>that the principles expressed (about variable localization, passing
>identifiable arguments, returning specific values, etc.) are best
>practices.

Fine, then why not practise those everywhere. Only practise makes good
coders. And if you practise poor style ....

jue


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

Date: Thu, 29 Oct 2009 10:34:00 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: software engineering, program construction
Message-Id: <89kje59vqkpgjf1mdqiffkk8c95ol38pfq@4ax.com>

ccc31807 <cartercc@gmail.com> wrote:
>On Oct 29, 11:28 am, "Uri Guttman" <u...@StemSystems.com> wrote:
>> STOP USING & for sub calls. this is true regardless of the globals!!
>
>Why? What is the reason for an ironclad, absolute rule against using &
>for user defined function calls?

Do you know what '&' does? Do you need that functionality or take
advantage of that functionality? If the answer to either question is
'no', then don't use it, because it does something behind your back
without you knowing what it does. And that will bite you badly one day.

>But what if it WILL only live here? What if it's a one time script
>that you KNOW that you will only use once and then delete permanently?

And the moon is made of green cheese ....

Anyway, good style requires constant practise. Constant practise of good
style, of course.

jue


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

Date: Thu, 29 Oct 2009 16:47:54 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: software engineering, program construction
Message-Id: <87bpjqylj9.fsf@quad.sysarch.com>

>>>>> "JE" == Jürgen Exner <jurgenex@hotmail.com> writes:

  JE> And the moon is made of green cheese ....

really? then we don't need to send food for any future manned missions
to the moon. maybe we can mine it for supplying food to mars
missions. does cpan have a module for dealing with moon cheese?

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: Thu, 29 Oct 2009 22:54:23 +0100
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: software engineering, program construction
Message-Id: <fhfpr6-7um.ln1@news.rtij.nl>

On Thu, 29 Oct 2009 16:47:54 -0400, Uri Guttman wrote:

>>>>>> "JE" == Jürgen Exner <jurgenex@hotmail.com> writes:
> 
>   JE> And the moon is made of green cheese ....
> 
> really? then we don't need to send food for any future manned missions
> to the moon. maybe we can mine it for supplying food to mars missions.
> does cpan have a module for dealing with moon cheese?

Moon::Cheese obviously. :-)

M4


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

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


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