[31732] in Perl-Users-Digest
Perl-Users Digest, Issue: 2995 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 19 00:09:31 2010
Date: Fri, 18 Jun 2010 21:09:14 -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, 18 Jun 2010 Volume: 11 Number: 2995
Today's topics:
Re: count the number of element in an array that are gr <tony_curtis32@yahoo.com>
Re: count the number of element in an array that are gr <jurgenex@hotmail.com>
Re: count the number of element in an array that are gr <jurgenex@hotmail.com>
count the number of element in an array that are greate <pengyu.ut@gmail.com>
Newbie: Where to get support for basic Perl problem? <clive_long@yahoo.com>
Re: Newbie: Where to get support for basic Perl problem <ralph@happydays.com>
Re: Newbie: Where to get support for basic Perl problem <news@lawshouse.org>
Re: Newbie: Where to get support for basic Perl problem <tadmc@seesig.invalid>
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <ralph@happydays.com>
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <cartercc@gmail.com>
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <kkeller-usenet@wombat.san-francisco.ca.us>
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <kkeller-usenet@wombat.san-francisco.ca.us>
Re: problem sending email using MIME::Lite from gmail's <r.ted.byers@gmail.com>
Re: problem sending email using MIME::Lite from gmail's <ben@morrow.me.uk>
Re: problem sending email using MIME::Lite from gmail's <r.ted.byers@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 18 Jun 2010 21:19:56 -0500
From: Tony <tony_curtis32@yahoo.com>
Subject: Re: count the number of element in an array that are greater than some values?
Message-Id: <87wrtvdar7.fsf@yahoo.com>
Peng Yu <pengyu.ut@gmail.com> writes:
> I'm wondering what is the shortest code to count the number of element
> in an array that are greater than some values. I'm just not familiar
> with perl enough to know what is the best way.
>
> A for-loop is the easiest way to think of.
>
> I also come up with the following way. But I'm not sure how to simply
> it in one line. I'm sure that there are better ways. Would you please
> let me know so that I can understand the expressive power of perl?
>
> @new_array=grep { $_ > 5 } @array;
> $#new_array+1
you can just ask for
my $n_greater_than = scalar grep ...;
hth
t
------------------------------
Date: Fri, 18 Jun 2010 21:01:18 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: count the number of element in an array that are greater than some values?
Message-Id: <nufo16p4ru16lideld4v8eh394lk2ggfph@4ax.com>
Peng Yu <pengyu.ut@gmail.com> wrote:
>I'm wondering what is the shortest code to count the number of element
>in an array that are greater than some values. I'm just not familiar
>with perl enough to know what is the best way.
>
>A for-loop is the easiest way to think of.
>
>I also come up with the following way. But I'm not sure how to simply
>it in one line. I'm sure that there are better ways. Would you please
>let me know so that I can understand the expressive power of perl?
>
>@new_array=grep { $_ > 5 } @array;
Just use the scalar value of the return value of grep:
$count = scalar (grep ......)
>$#new_array+1
Why last array index + 1 instead of simply using @new_array in scalar
context? Using the scalar context is not only easier and cleaner, it is
also correct if someone was crazy enough to modify $[ in which case your
approach would yield the wrong number.
jue
------------------------------
Date: Fri, 18 Jun 2010 21:07:49 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: count the number of element in an array that are greater than some values?
Message-Id: <cego16t15ajqal0abdilioe73p1ekch6ht@4ax.com>
Jürgen Exner <jurgenex@hotmail.com> wrote:
>Peng Yu <pengyu.ut@gmail.com> wrote:
>>I'm wondering what is the shortest code to count the number of element
>>in an array that are greater than some values. I'm just not familiar
>>with perl enough to know what is the best way.
>>
>>A for-loop is the easiest way to think of.
>>
>>I also come up with the following way. But I'm not sure how to simply
>>it in one line. I'm sure that there are better ways. Would you please
>>let me know so that I can understand the expressive power of perl?
>>
>>@new_array=grep { $_ > 5 } @array;
>
>Just use the scalar value of the return value of grep:
> $count = scalar (grep ......)
Should have mentioned it explicitely: This is of course the manual,
explicit version that you can always use if you can't think anything
smarter.
For grep() itself it is much simpler, just read the documentation of the
function you are using, in particular the last sentence in the second
paragraph.
>>$#new_array+1
>
>Why last array index + 1 instead of simply using @new_array in scalar
>context? Using the scalar context is not only easier and cleaner, it is
>also correct if someone was crazy enough to modify $[ in which case your
>approach would yield the wrong number.
>
>jue
------------------------------
Date: Fri, 18 Jun 2010 18:50:51 -0700 (PDT)
From: Peng Yu <pengyu.ut@gmail.com>
Subject: count the number of element in an array that are greater than some values?
Message-Id: <89409f28-9782-4522-bec4-201371c5aa9c@a30g2000yqn.googlegroups.com>
I'm wondering what is the shortest code to count the number of element
in an array that are greater than some values. I'm just not familiar
with perl enough to know what is the best way.
A for-loop is the easiest way to think of.
I also come up with the following way. But I'm not sure how to simply
it in one line. I'm sure that there are better ways. Would you please
let me know so that I can understand the expressive power of perl?
@new_array=grep { $_ > 5 } @array;
$#new_array+1
------------------------------
Date: Fri, 18 Jun 2010 13:23:26 -0700 (PDT)
From: Clive <clive_long@yahoo.com>
Subject: Newbie: Where to get support for basic Perl problem?
Message-Id: <3d2a4ca8-72c6-48be-9511-fce26732ee2f@i28g2000yqa.googlegroups.com>
Hello,
I am not a perl programmer. I am trying to implement a Perl Script,
Squeezebox Server (v7.5.0), on a FreeNAS server. the purpose of the
script is to provide a SlimNAS / squeezebox server on an existing
FreeNAS server so I can use my Logitech "client" to access the mp3
music files held on the FreeNAS Server. The installation is all
packaged and documented and the install seems to have completed
correctly as documented.
See http://www.herger.net/slim/detail.php?nr=1026
Now , the simple problem is I can't get the squeezebox server to run
on FreeNAS. It is supposed to work i.e. people have written it works.
I have posted lots of diagnostic info on both squeezebox and freenas
forums. http://forums.slimdevices.com/showthread.php?t=79395&highlight=clive
However, no one on the forum has come up with a solution. I am
guessing (and it is a guess) there is some problem running the
supplied Perl script(s) on my FreeNAS server. I don't have the
technical knowledge to diagnose nor fix the problem. Can anyone
suggest where will be a good place (if not here) to go for advice and
support?
The script (??) puts out diagnostic messages - that may be significant
- and maybe to do with the Perl script or have nothign to do with
Perl, I just don't know.
[10-06-16 21:05:33.2317] main::init (323) Starting Squeezebox Server
(v7.5.0, r30464, Thu Apr 1 06:28:42 MDT 2010) perl 5.008009
[10-06-16 21:05:33.2853] main::init (400) Warning: Can't locate UUID/
Tiny.pm in @INC (@INC contains: /mnt/freenasmount/Slimnas/squeezebox/
CPAN/arch/5.8/i386-freebsd-64int /mnt/freenasmount/Slimnas/squeezebox/
CPAN/arch/5.8/i386-freebsd-64int/auto ..... (lots of libraries
including one that holds Tiny.pm)
Any help to get squeezebox working on FreeNAS will be much
appreciated.
Clive
------------------------------
Date: Fri, 18 Jun 2010 16:29:45 -0400
From: Ralph Malph <ralph@happydays.com>
Subject: Re: Newbie: Where to get support for basic Perl problem?
Message-Id: <67d4f$4c1bd73a$40779ac3$22250@news.eurofeeds.com>
> [10-06-16 21:05:33.2317] main::init (323) Starting Squeezebox Server
> (v7.5.0, r30464, Thu Apr 1 06:28:42 MDT 2010) perl 5.008009
> [10-06-16 21:05:33.2853] main::init (400) Warning: Can't locate UUID/
> Tiny.pm in @INC (@INC contains: /mnt/freenasmount/Slimnas/squeezebox/
> CPAN/arch/5.8/i386-freebsd-64int /mnt/freenasmount/Slimnas/squeezebox/
> CPAN/arch/5.8/i386-freebsd-64int/auto ..... (lots of libraries
> including one that holds Tiny.pm)
I have no knowledge of this software you are trying to install but
it looks like you need to install some modules from cpan!
Read this web page to learn how:
http://perl.about.com/od/packagesmodules/qt/perlcpan.htm
------------------------------
Date: Fri, 18 Jun 2010 21:48:37 +0100
From: Henry Law <news@lawshouse.org>
Subject: Re: Newbie: Where to get support for basic Perl problem?
Message-Id: <Sp6dne_s0PI7RobRnZ2dnUVZ7sCdnZ2d@giganews.com>
On 18/06/10 21:23, Clive wrote:
> The script (??) puts out diagnostic messages - that may be significant
> - and maybe to do with the Perl script or have nothign to do with
> Perl, I just don't know.
>
> [10-06-16 21:05:33.2317] main::init (323) Starting Squeezebox Server
> (v7.5.0, r30464, Thu Apr 1 06:28:42 MDT 2010) perl 5.008009
> [10-06-16 21:05:33.2853] main::init (400) Warning: Can't locate UUID/
> Tiny.pm in @INC (@INC contains: /mnt/freenasmount/Slimnas/squeezebox/
> CPAN/arch/5.8/i386-freebsd-64int /mnt/freenasmount/Slimnas/squeezebox/
> CPAN/arch/5.8/i386-freebsd-64int/auto ..... (lots of libraries
> including one that holds Tiny.pm)
Definitely Perl libraries are missing, or are in the wrong place and
can't be found. But what you say about Tiny.pm actually being in one of
the libraries in the @INC path (like a system path but for Perl modules)
suggests some mis-configuration on installation.
Have you seen where it says "If you have any questions or problems,
don't hesitate to contact me in the Squeezebox Server forums. " at the
bottom of the installation page you referred to? Might be better to
post there first to eliminate Squeezebox-specific problems and narrow it
down to Perl.
I googled a bit and I found reference to a "build-perl-modules.pl"
script (I know nothing about Squeezebox either) ... maybe there's an
extra step in some environments.
--
Henry Law Manchester, England
------------------------------
Date: Fri, 18 Jun 2010 16:59:16 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Newbie: Where to get support for basic Perl problem?
Message-Id: <slrni1nqnn.s0g.tadmc@tadbox.sbcglobal.net>
Clive <clive_long@yahoo.com> wrote:
> The script (??) puts out diagnostic messages - that may be significant
> - and maybe to do with the Perl script or have nothign to do with
> Perl, I just don't know.
> [10-06-16 21:05:33.2853] main::init (400) Warning: Can't locate UUID/
> Tiny.pm in @INC
perl cannot find a module (library) that is being called in somewhere.
> (@INC contains: /mnt/freenasmount/Slimnas/squeezebox/
> CPAN/arch/5.8/i386-freebsd-64int /mnt/freenasmount/Slimnas/squeezebox/
> CPAN/arch/5.8/i386-freebsd-64int/auto ..... (lots of libraries
> including one that holds Tiny.pm)
I dunno what that Tiny.pm might be, but it is not the one that is
being looked for.
It first looks for a *directory* named UUID under one of the
listed @INC dirs, then it looks for a file named Tiny.pm
inside of that UUID/ directory.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
Date: Fri, 18 Jun 2010 14:14:05 -0400
From: Ralph Malph <ralph@happydays.com>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.9 $)
Message-Id: <2d6b4$4c1bb76f$40779ac3$5725@news.eurofeeds.com>
On 6/18/2010 11:02 AM, Tad McClellan wrote:
> Ralph Malph<ralph@happydays.com> wrote:
>
>>> Tad McClellan and many others on the comp.lang.perl.misc newsgroup.
>> ^^^^^^^^^^^
>> incorrect
>
>
> What makes you think that?
>
> Maybe you just missed the discussion...
>
> http://groups.google.com/group/comp.lang.perl.misc/browse_thread/thread/79f0fa4d1e149d/9e1f09d6b7a2940f?q&pli=1
ha ha ha ha ha.
I have no idea if I did or not. Who remembers some
random thread on usenet from 10 years ago? I mean, besides
aspberger victims and morbidly obese shutins?
Hardly any of those thread participants post here anymore anyway.
Some helpful advice pal, no-one is reading your screed.
Tighten it way way up and you might be onto something.
I've taken the liberty of posting v2.0 for you.
------------------------------
Date: Fri, 18 Jun 2010 12:29:03 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.9 $)
Message-Id: <19b72f74-34af-4c3e-a6f7-e35ebe19eac6@c33g2000yqm.googlegroups.com>
On Jun 18, 11:02=A0am, Tad McClellan <ta...@seesig.invalid> wrote:
> I'll take that as one vote against.
Which is offset by my one vote for.
Actually, I think that posting the FAQs has a great value. Posting the
FAQs would have an even greater value if we actually valued the
discussion of them but unfortunately some people view a discussion of
a particular FAQ as an attack on all that's good and holy.
I'm not being critical of posting the FAQs, which is a Good Idea. I am
being critical of certain people who feel that they have to defend the
FAQs against every attempted request for clarification or discussion.
For my part, have become leery of replying to these threads because
I've been burned so many times -- and it's never a good idea to
squelch a discussion.
CC
------------------------------
Date: Fri, 18 Jun 2010 14:41:56 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.9 $)
Message-Id: <4q5te7xttk.ln2@goaway.wombat.san-francisco.ca.us>
On 2010-06-18, ccc31807 <cartercc@gmail.com> wrote:
> On Jun 18, 11:02 am, Tad McClellan <ta...@seesig.invalid> wrote:
>> I'll take that as one vote against.
>
> Which is offset by my one vote for.
...and my vote for makes it positive.
> Actually, I think that posting the FAQs has a great value.
The FAQs are posted separately. These are the Posting Guidelines.
--keith
--
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information
------------------------------
Date: Fri, 18 Jun 2010 14:39:38 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 2.0 $)
Message-Id: <rl5te7xqsk.ln2@goaway.wombat.san-francisco.ca.us>
On 2010-06-18, Ralph Malph <ralph@happydays.com> wrote:
> Full Text:
> -No spam.
> -If asking about code post a complete sample that can run on
> its own and demonstrates the problem.
> -Be nice to everyone including newbies. Don't question design
> decisions too hard. That would contradict TMTOWTDI.
If the sole criterion for improvement is length, 2.0 is far superior to
1.9.
If there are any other criteria, 1.9 is far superior to 2.0.
--keith
--
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information
------------------------------
Date: Fri, 18 Jun 2010 15:22:08 -0700 (PDT)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Re: problem sending email using MIME::Lite from gmail's stmp server
Message-Id: <df585a1c-fa74-49e7-b6f6-60e96979a342@w31g2000yqb.googlegroups.com>
On Jun 18, 12:21=A0am, Chris Nehren <apei...@isuckatdomains.net.invalid>
wrote:
> On 2010-06-17, Ted Byers scribbled these curious markings:
>
> > I am using Activestate perl 5.10.0 on WXP, if that matters.
>
> Yes, it does. Everyone using Windows has abandoned ActiveState in favor
> of Strawberry. ActiveState Perl is for ActiveState to sell support
> contracts and should be treated as such (much as RHELL is for RedHat to
> sell support contracts). You should contact your support representative
> for help with this issue.
>
> [snip 1995-era MIME::Lite code that doesn't work]
>
> People living in the 21st century write email code using Email::MIME,
> Email::Sender, and optionally Email::MIME::Kit. For sending through
> Gmail, you'll want Email::Sender::Transport::SMTP::TLS. The example in
> the synopsis should get you started. It's specifically written for
> Gmail.
>
> --
> Thanks and best regards,
> Chris Nehren
> Unless noted, all content I post is CC-BY-SA.
Thanks guys. great. We have progress.
I can now send email in which the body is html, and from a gmail
account to an arbitrary account.
But there is a problem. While the html displays OK, the top haif of
it is repeated at the end. Equally badly, the link between the jpg
file (containing the logo) and the img tag in the html is broken.
The first few lines, showing the package I am using are:
use strict;
use warnings;
use Email::Sender::Transport::SMTP::TLS;
#use Email::Simple::Creator; # or other Email::
use Email::MIME::Creator;
use IO::All;
my $first_name =3D 'Ted';
my $html_template =3D slurp_file();
$html_template =3D~ s/>NAME</>$first_name</;
And, following the examples in the packages' documentation, I made the
following:
my $sender =3D Email::Sender::Transport::SMTP::TLS->new(
host =3D> 'smtp.gmail.com',
port =3D> 587,
username =3D> 'connie@capitalbusinessservices.net',
password =3D> 'cbs2010',
helo =3D> 'capitalbusinessservices.net',
);
my $subject =3D "A test sending MIME content from gmail to an arbitrary
address (mine)";
my $html_part =3D Email::MIME->create(
attributes =3D> {
content_type =3D> "text/html",
},
body =3D> "$html_template",
);
my $image_part =3D Email::MIME->create(
attributes =3D> {
content_type =3D> "image/jpg",
name =3D> "logo.jpg",
},
body =3D> io( "template.files/image002.jpg" )->all,
);
my @parts =3D ($html_part,$image_part);
my $message =3D Email::MIME->create(
header =3D> [
From =3D> 'connie@capitalbusinessservices.net',
To =3D> 'r.ted.byers@gmail.com',
Subject =3D> $subject,
],
parts =3D> \@parts,
);
eval {
$sender->send($message, {
from =3D> 'connie@capitalbusinessservices.net',
to =3D> [ 'r.ted.byers@gmail.com' ],
} );
};
die "Error sending email: $@" if $@;
It could hardly be simpler.
The img tag is:
<img width=3D634 height=3D95 src=3D"logo.jpg" v:shapes=3D"_x0000_i1025">
I have undoubtedly missed something in making each of the parts, but I
have yet to find what. What I see of the image suggests that
"io( "template.files/image002.jpg" )->all" loses half of the jpeg file
(only half of the image is visible in the attachment, even though the
image is intact if I use my image editor to view it).
Any information you can provide as to what I missed would be
appreciated.
Thanks
Ted
------------------------------
Date: Sat, 19 Jun 2010 00:26:51 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: problem sending email using MIME::Lite from gmail's stmp server
Message-Id: <rubte7-4s42.ln1@osiris.mauzo.dyndns.org>
Quoth Ted Byers <r.ted.byers@gmail.com>:
>
> I can now send email in which the body is html, and from a gmail
> account to an arbitrary account.
>
> But there is a problem. While the html displays OK, the top haif of
> it is repeated at the end. Equally badly, the link between the jpg
> file (containing the logo) and the img tag in the html is broken.
>
> The first few lines, showing the package I am using are:
>
> use strict;
> use warnings;
>
> use Email::Sender::Transport::SMTP::TLS;
> #use Email::Simple::Creator; # or other Email::
> use Email::MIME::Creator;
> use IO::All;
>
> my $first_name = 'Ted';
> my $html_template = slurp_file();
Have you printed out $html_template to verify it contains what you think
it does?
> $html_template =~ s/>NAME</>$first_name</;
>
> And, following the examples in the packages' documentation, I made the
> following:
>
> my $sender = Email::Sender::Transport::SMTP::TLS->new(
> host => 'smtp.gmail.com',
> port => 587,
> username => 'connie@capitalbusinessservices.net',
> password => 'cbs2010',
I sincerely hope this isn't your actual password. If it is, change it
*right* *now*.
> helo => 'capitalbusinessservices.net',
Are you sending this from a machine called capitalbusinessservices.net?
If not you should not be claiming you are. In any case, it's probably
better to let HELO/EHLO default to your machine's actual hostname.
> );
> my $subject = "A test sending MIME content from gmail to an arbitrary
> address (mine)";
>
> my $html_part = Email::MIME->create(
> attributes => {
> content_type => "text/html",
> },
> body => "$html_template",
Those quotes don't do anything for you. See perldoc -q quote.
> );
> my $image_part = Email::MIME->create(
> attributes => {
> content_type => "image/jpg",
> name => "logo.jpg",
> },
> body => io( "template.files/image002.jpg" )->all,
Have you tried this without IO::All? Since a JPEG is a binary file, are
you reading the file in binmode, if that matters?
> );
> my @parts = ($html_part,$image_part);
> my $message = Email::MIME->create(
> header => [
> From => 'connie@capitalbusinessservices.net',
> To => 'r.ted.byers@gmail.com',
> Subject => $subject,
> ],
> parts => \@parts,
> );
>
> eval {
> $sender->send($message, {
> from => 'connie@capitalbusinessservices.net',
> to => [ 'r.ted.byers@gmail.com' ],
> } );
> };
> die "Error sending email: $@" if $@;
It's safer to write this like
eval {
$sender->send(...);
1;
} or die "...";
There are circumstances under which $@ can be cleared between the end of
the eval and the start of the next statement (signal handlers, for
instance) and it's important to know there was an error even if you've
lost the message by then. (Yes, this is annoying, and generally regarded
as a flaw in Perl's exception mechanism.) You may also want to look at
Try::Tiny, which handles the unpleasant details for you.
> It could hardly be simpler.
>
> The img tag is:
>
> <img width=634 height=95 src="logo.jpg" v:shapes="_x0000_i1025">
What happens if you take out that v:shapes attribute? It's not HTML.
> I have undoubtedly missed something in making each of the parts, but I
> have yet to find what. What I see of the image suggests that
> "io( "template.files/image002.jpg" )->all" loses half of the jpeg file
> (only half of the image is visible in the attachment, even though the
> image is intact if I use my image editor to view it).
When you say 'in the attachment' do you mean 'embedded in the HTML
section of the message'? What happens if you save just the JPEG
somewhere and compare it to the original file: are they identical?
Are you using IE/Outlook/something else MS to view the email? ISTR that
v:shapes attribute is something Word puts in HTML; possibly it's causing
mshtml to display only part of the image. What happens if you use a
different browser? What happens if you just view the original HTML file,
without incorporating it into an email?
Ben
------------------------------
Date: Fri, 18 Jun 2010 19:00:45 -0700 (PDT)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Re: problem sending email using MIME::Lite from gmail's stmp server
Message-Id: <58ed178a-96f6-4085-b55f-c4a67cba64a6@z10g2000yqb.googlegroups.com>
On Jun 18, 7:26=A0pm, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth Ted Byers <r.ted.by...@gmail.com>:
>
>
>
>
>
> > I can now send email in which the body is html, and from a gmail
> > account to an arbitrary account.
>
> > But there is a problem. =A0While the html displays OK, the top haif of
> > it is repeated at the end. =A0Equally badly, the link between the jpg
> > file (containing the logo) and the img tag in the html is broken.
>
> > The first few lines, showing the package I am using are:
>
Hi Ben,
Thanks.
> > use strict;
> > use warnings;
>
> > use Email::Sender::Transport::SMTP::TLS;
> > #use Email::Simple::Creator; # or other Email::
> > use Email::MIME::Creator;
> > use IO::All;
>
> > my $first_name =3D 'Ted';
> > my $html_template =3D slurp_file();
>
> Have you printed out $html_template to verify it contains what you think
> it does?
>
Yes. That was the first thing I had done.
> > $html_template =3D~ s/>NAME</>$first_name</;
>
> > And, following the examples in the packages' documentation, I made the
> > following:
>
> > my $sender =3D Email::Sender::Transport::SMTP::TLS->new(
> > =A0 =A0 =A0 =A0 host =3D> 'smtp.gmail.com',
> > =A0 =A0 =A0 =A0 port =3D> 587,
> > =A0 =A0 =A0 =A0 username =3D> 'con...@capitalbusinessservices.net',
> > =A0 =A0 =A0 =A0 password =3D> 'cbs2010',
>
> I sincerely hope this isn't your actual password. If it is, change it
> *right* *now*.
>
Damn. That's what happens when you rush. That will be corrected
promptly.
> > =A0 =A0 =A0 =A0 helo =3D> 'capitalbusinessservices.net',
>
> Are you sending this from a machine called capitalbusinessservices.net?
> If not you should not be claiming you are. In any case, it's probably
> better to let HELO/EHLO default to your machine's actual hostname.
>
Actually, we have a rather more complex network, where the same
hardware lives in different domains, and we make use of Gmail's
support for relating a given gmail account to different domains.
> > =A0 =A0 );
> > my $subject =3D "A test sending MIME content from gmail to an arbitrary
> > address (mine)";
>
> > my $html_part =3D Email::MIME->create(
> > =A0 =A0 =A0 =A0 =A0 attributes =3D> {
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0content_type =3D> "text/html",
> > =A0 =A0 =A0 =A0 =A0 },
> > =A0 =A0 =A0 =A0 =A0 body =3D> "$html_template",
>
> Those quotes don't do anything for you. See perldoc -q quote.
>
> > );
> > my $image_part =3D Email::MIME->create(
> > =A0 =A0 =A0 =A0 =A0 attributes =3D> {
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0content_type =3D> "image/jpg",
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0name =A0 =A0 =A0 =A0 =3D> "logo.jpg",
> > =A0 =A0 =A0 =A0 =A0 },
> > =A0 =A0 =A0 =A0 =A0 body =3D> io( "template.files/image002.jpg" )->all,
>
> Have you tried this without IO::All? Since a JPEG is a binary file, are
> you reading the file in binmode, if that matters?
>
yes, I'll test that next.
I wonder if I need to uuencode it, and if so, how that would change
the headers I tell it to use. Isn't there an encoding attribute that
can be attached to a MIME object?
>
>
> > );
> > my @parts =3D ($html_part,$image_part);
> > my $message =3D Email::MIME->create(
> > =A0 =A0 =A0 header =3D> [
> > =A0 =A0 =A0 =A0 =A0 From =3D> 'con...@capitalbusinessservices.net',
> > =A0 =A0 =A0 =A0 =A0 To =A0 =3D> 'r.ted.by...@gmail.com',
> > =A0 =A0 =A0Subject =3D> $subject,
> > =A0 =A0 =A0 ],
> > =A0 =A0 =A0 parts =3D> \@parts,
> > );
>
> > eval {
> > =A0 =A0 =A0 =A0 $sender->send($message, {
> > =A0 =A0 =A0 =A0 =A0 =A0 from =3D> 'con...@capitalbusinessservices.net',
> > =A0 =A0 =A0 =A0 =A0 =A0 to =A0 =3D> [ 'r.ted.by...@gmail.com' ],
> > =A0 =A0 =A0 =A0 } );
> > =A0 =A0 };
> > =A0 =A0 die "Error sending email: $@" if $@;
>
> It's safer to write this like
>
> =A0 =A0 eval {
> =A0 =A0 =A0 =A0 $sender->send(...);
> =A0 =A0 =A0 =A0 1;
> =A0 =A0 } or die "...";
>
> There are circumstances under which $@ can be cleared between the end of
> the eval and the start of the next statement (signal handlers, for
> instance) and it's important to know there was an error even if you've
> lost the message by then. (Yes, this is annoying, and generally regarded
> as a flaw in Perl's exception mechanism.) You may also want to look at
> Try::Tiny, which handles the unpleasant details for you.
>
> > It could hardly be simpler.
>
> > The img tag is:
>
> > <img width=3D634 height=3D95 src=3D"logo.jpg" v:shapes=3D"_x0000_i1025"=
>
>
> What happens if you take out that v:shapes attribute? It's not HTML.
The original of the html document was an MS Word document. I guess I
better clean out the crap that M$ apps add to html files.
>
> > I have undoubtedly missed something in making each of the parts, but I
> > have yet to find what. =A0What I see of the image suggests that
> > "io( "template.files/image002.jpg" )->all" loses half of the jpeg file
> > (only half of the image is visible in the attachment, even though the
> > image is intact if I use my image editor to view it).
>
> When you say 'in the attachment' do you mean 'embedded in the HTML
> section of the message'? What happens if you save just the JPEG
> somewhere and compare it to the original file: are they identical?
Instead of showing up embedded in the html body, it appeared at the
end of the message where, using the web client to gmail, places
attachments.
>
> Are you using IE/Outlook/something else MS to view the email? ISTR that
> v:shapes attribute is something Word puts in HTML; possibly it's causing
> mshtml to display only part of the image. What happens if you use a
> different browser? What happens if you just view the original HTML file,
> without incorporating it into an email?
>
When I save the html as a local file, it appears as it is supposed to
appear regardless of whether I use Firefox or MS IE.
But to be sure, I'll strip out anything that isn't routine HTML, and
see hwo that affects things.
Thanks again
Ted
------------------------------
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 2995
***************************************