[27928] in Perl-Users-Digest
Perl-Users Digest, Issue: 9292 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 13 11:05:55 2006
Date: Tue, 13 Jun 2006 08:05:04 -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 Tue, 13 Jun 2006 Volume: 10 Number: 9292
Today's topics:
Re: Can't find syntax error <nomail@domain.tld>
Re: Daemon perl script <f__r__a__n__s@hotmail.com>
Re: Determining lvalue context <nobull67@gmail.com>
Re: Determining lvalue context <siegel@zrz.tu-berlin.de>
Earthquake and Tornado Forecasting Programs June 13, <edgrsprj@ix.netcom.com>
Re: Merging potentially undefined hashes <nobull67@gmail.com>
Re: Merging potentially undefined hashes <baxter.brad@gmail.com>
Re: Modifying ls <bart.lateur@pandora.be>
Re: Modifying ls <siegel@zrz.tu-berlin.de>
Re: Modifying ls <tadmc@augustmail.com>
Re: Modifying ls <peace.is.our.profession@gmx.de>
Re: OT: Anybody using Xemacs to edit Perl Code? <sfandino@yahoo.com>
Re: Question: Inline::C module packaging? <siegel@zrz.tu-berlin.de>
Symbol Table and References <dh@metrohm.ch>
Re: Symbol Table and References <baxter.brad@gmail.com>
Re: Unable to flush o/p buffer <siegel@zrz.tu-berlin.de>
Re: Using tee with Perl's system command <tzz@lifelogs.com>
UTF-8 subject in an email <ynleder@nspark.org>
Re: UTF-8 subject in an email <bart@nijlen.com>
Re: UTF-8 subject in an email <rvtol+news@isolution.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 13 Jun 2006 09:51:01 -0400
From: Eric <nomail@domain.tld>
Subject: Re: Can't find syntax error
Message-Id: <128tgmc5h4p5u8b@corp.supernews.com>
Now im getting a stranger error. (Also i tried what you said about using
$fh rather then <FILE>, and it put me in an endless loop :). For now
i'll leave it the other way, as it appears to be reading the file with
now problem, and that is the way i've always seen it.
here is my script followed by the output:
#!/usr/bin/perl
#
#
#
#
#
#
use strict;
use warnings;
use LWP::UserAgent;
use Switch;
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->agent("Stress Test/0.1");
$ua->cookie_jar({ file => "./cookies.txt", AutoSave => 1 });
$ua->protocols_forbidden( ['mailto'] );
parse_config("./test1.conf");
my $response;
sub parse_config {
my $conf = shift;
open FILE, "<" . $conf || die("Cannot open $conf. " . $!);
while(<FILE>) {
#print $_;
my @commands = split("=",$_);
#print $commands[0] . " - " . $commands[1];
switch ($commands[0]) {
case "URL" {
$response = $ua->get($commands[1]);
if ($response->is_success) {
print_response();
}else{
die("GET " . $commands[1] . " failed. " .
$response->status_line);
} # end if
} # end case
} # end switch
} # end while
close(FILE);
} # end parse_config
sub print_response {
#print "Response-content....: " . $response->content . "\n";
print "Response-code.......: " . $response->code . "\n";
print "Response-message....: " . $response->message . "\n";
#print "Response-header.....: " . $response->header . "\n";
print "Response-request....: " . $response->request . "\n";
print "Response-previous...: " . $response->previous . "\n";
print "Response-status_line: " . $response->status_line . "\n";
print "Response-base.......: " . $response->base . "\n";
print "Response-is_info....: " . $response->is_info . "\n";
print "Response-is_success.: " . $response->is_success . "\n";
print "Response-is_redirect: " . $response->is_redirect . "\n";
print "Response-is_error...: " . $response->is_error . "\n";
#print "Response-as_string..: " . $response->as_string . "\n";
}
####### And the output
Malformed UTF-8 character (unexpected continuation byte 0xaa, with no
preceding start byte) in bitwise and (&) at
/usr/lib/perl5/5.8.0/Switch.pm line 251, <FILE> line 1.
Malformed UTF-8 character (unexpected continuation byte 0xad, with no
preceding start byte) in bitwise and (&) at
/usr/lib/perl5/5.8.0/Switch.pm line 251, <FILE> line 1.
Malformed UTF-8 character (unexpected continuation byte 0xb3, with no
preceding start byte) in bitwise and (&) at
/usr/lib/perl5/5.8.0/Switch.pm line 251, <FILE> line 1.
Response-code.......: 200
Response-message....: OK
Response-request....: HTTP::Request=HASH(0x85917d8)
Use of uninitialized value in concatenation (.) or string at ./test.pl
line 61, <FILE> line 1.
Response-previous...:
Response-status_line: 200 OK
Response-base.......: https://test.domain.tld/sampleco/
Response-is_info....:
Response-is_success.: 1
Response-is_redirect:
Response-is_error...:
Malformed UTF-8 character (unexpected continuation byte 0xaf, with no
preceding start byte) in bitwise and (&) at
/usr/lib/perl5/5.8.0/Switch.pm line 251, <FILE> line 2.
Malformed UTF-8 character (unexpected continuation byte 0xb0, with no
preceding start byte) in bitwise and (&) at
/usr/lib/perl5/5.8.0/Switch.pm line 251, <FILE> line 2.
Malformed UTF-8 character (unexpected continuation byte 0xac, with no
preceding start byte) in bitwise and (&) at
/usr/lib/perl5/5.8.0/Switch.pm line 251, <FILE> line 2.
Malformed UTF-8 character (unexpected continuation byte 0xab, with no
preceding start byte) in bitwise and (&) at
/usr/lib/perl5/5.8.0/Switch.pm line 251, <FILE> line 2.
------------------------------
Date: Tue, 13 Jun 2006 15:36:13 +0200
From: farans <f__r__a__n__s@hotmail.com>
Subject: Re: Daemon perl script
Message-Id: <pan.2006.06.13.13.36.13.516080@hotmail.com>
On Mon, 12 Jun 2006 18:27:23 -0700, janicehwang1325@yahoo.com wrote:
> hi expert,
>
> I have a client program which is running as daemon and send data to the
> server program on the remote site. I m in the testing phase. however,
> after running the program for 3 days, suddenly the client program is
> killed and no longer active in the client site. wat can be the reason
> for this? Is setting scheduling priority using 'renice' can solve the
> problem?
> Appreciate lots if anyone try to give me some idea.
I don't have an answer for you, only a question:
What were your daemons "last words"?
------------------------------
Date: 13 Jun 2006 04:57:52 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: Determining lvalue context
Message-Id: <1150199871.989279.38100@i40g2000cwc.googlegroups.com>
xhoster@gmail.com wrote:
> "Ferry Bolhar" <bol@adv.magwien.gv.at> wrote:
> > Xho:
> >
> > > You have to return something magical. If the magical thing you return
> > > gets assigned to, you were called in a lvalue context. Otherwise, you
> > > weren't.
> >
> > What do you mean with "something magical"?
>
> I'm not familiar with all the magic in Perl. A tied scalar is the one
> that pops to mind in this case, but there may be others.
Well, in this context, the most revant other magical things are the
return values of builtin lvalue functions like pos(), substr() and so
on.
> Maybe now that I am more familiar with tied objects, I would have a better
> experience.
I have _more_ experience. I assure you it doesn't get much better.
------------------------------
Date: Tue, 13 Jun 2006 14:15:31 +0200
From: Anno Siegel <siegel@zrz.tu-berlin.de>
Subject: Re: Determining lvalue context
Message-Id: <4f7omoF1hsjatU1@news.dfncis.de>
xhoster@gmail.com wrote:
> "Ferry Bolhar" <bol@adv.magwien.gv.at> wrote:
>> Xho:
[lvalue accessors]
> It seemed like one of those things better in theory than in practise,
> with the "How do I know if it is assinged to or not?" problem being
> one of the reasons.
>
> I've just found that resorting to either the separate getter/setter
> methods, or one method which if given N arguments is a getter, or
> if given N+1 arguments is a setter+getter, to be easier.
>
> Maybe now that I am more familiar with tied objects, I would have a better
> experience.
I would use the tie solution only if I dearly wanted an lvalue method
in the user interface of a class. I do find plain lvalue accessors
handy as non-public accessors for internal use, if I need both anyhow.
Anno
------------------------------
Date: Tue, 13 Jun 2006 11:39:00 GMT
From: "edgrsprj" <edgrsprj@ix.netcom.com>
Subject: Earthquake and Tornado Forecasting Programs June 13, 2006
Message-Id: <otxjg.12421$921.5860@newsread4.news.pas.earthlink.net>
"edgrsprj" <edgrsprj@ix.netcom.com> wrote in message
news:D7qAe.21003$eM6.9503@newsread3.news.atl.earthlink.net...
> PROPOSED EARTHQUAKE FORECASTING
> COMPUTER PROGRAM DEVELOPMENT EFFORT
>
> Posted July 11, 2005
> My main earthquake forecasting Web page is:
> http://www.freewebz.com/eq-forecasting/Data.html
>
EARTHQUAKE AND TORNADO FORECASTING PROGRAMS
Posted by E.D.G. June 13, 2006
http://www.freewebz.com/eq-forecasting/Data.html
The information in this report represents expressions of personal opinion.
On July 11, 2005 I posted a report to a number of Internet Newsgroups
including sci.geo.earthquakes stating that I was considering creating a Web
site where researchers around the world could post notes and develop
computer programs associated with the science of earthquake forecasting.
This present report is an update on that project.
The effort is still underway. The present plan is to try to get the
proposed Web site organized for the science of earthquake forecasting and
then expand it to include other sciences such as tornado forecasting and
different areas of medicine. The ultimate goal is to have discussion areas
there for as many of the problems which threaten the health and lives of
people around the world as possible.
Professional and amateur computer programmers would probably be heavily
involved with this work.
Since that first report was posted last July I have been able to establish
what looks like it will be a stable source of funding for the effort. It
should at least enable me to continue working on the project and pay for
things such as Web site rental fees etc. And I am presently working with
two groups of legal people who are attempting to create a formal
organization through which the actual funding and Web site operation etc.
will take place. How fast this effort will progress is at the moment
largely up to those legal groups. One of them is supposed to create the
necessary legal documents. The other will be doing the filing with
government agencies etc. Unfortunately, since I am not a major client of
either group they are doing the work when they are not busy with other
clients.
A formal legal organization intended to be an introductory version of this
new organization has existed since 2002. But it took my legal people about
eight months to get all of the paperwork done and filed. The present effort
has been underway for a month. Hopefully it will not take another seven
months to finish.
PROPOSED WEB SITE
A number of years ago I worked with a Web site development expert to create
a discussion group for earthquake forecasting. I believe that it eventually
evolved into the two following discussion groups. The original Web site
expert is no longer involved.
http://groups.yahoo.com/group/earthwaves
http://www.earthwaves.org/wwwboard/wwwboard.html
For this proposed Web site I would probably try to use a discussion board
which would be a highly modified version of that second board. And it will
take a fair amount of computer programming to create the new version. The
problem with the existing discussion board control computer program is that
it is does not offer the necessary posting options. When researchers post a
note to such a board, rules have to be in place regarding what types of
notes other people can post in response. That is an absolute necessity.
And the structure of that present board does not contain those types of
rules within the control computer program itself.
More details regarding that proposed Web site can be found in the following
report that I submitted for a United Nations disaster mitigation related
discussion back in July of 2004:
http://www.unisdr.org/wcdr-dialogue/t3-dialogue.htm#34
Based on their starting dates etc. I believe that my report might have
already led to the creation of the following Web sites:
http://www.hewsweb.org
http://www.grassroots.org
Keep your fingers crossed. If the effort to create this proposed Web site
is successful then it might assist researchers in quite a few areas of
science and medicine around the world with significantly accelerating their
lifesaving efforts.
------------------------------
Date: 13 Jun 2006 04:47:55 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: Merging potentially undefined hashes
Message-Id: <1150199275.308421.100090@h76g2000cwa.googlegroups.com>
farans wrote:
> %hash1=(defined $hash2 and defined $hash3) ? (%$hash2, %$hash3) : undef;
That is wrong in serveral ways.
If both $hash2 and $hash3 are defined it will work correctly.
If either $hash2 are $hash3 are undefined it will ignore the contents
of the other one and set
%hash1 = ( '' => undef)
whilst emitting two warnings.
------------------------------
Date: 13 Jun 2006 06:40:07 -0700
From: "Brad Baxter" <baxter.brad@gmail.com>
Subject: Re: Merging potentially undefined hashes
Message-Id: <1150206007.017291.113480@u72g2000cwu.googlegroups.com>
farans wrote:
> On Fri, 09 Jun 2006 11:46:17 -0700, Brian McCauley wrote:
>
> > My preferred idiom is:
> >
> > %hash1 = (%{ $hash2 || {} }, %{ $hash3 || {} });
> >
> > Or:
> >
> > %hash1 = (%{\%$hash2}, %{\%$hash3});
>
> I don't uderstand the last one, ...
>From perldoc perlref:
6. References of the appropriate type can spring into
existence if you dereference them in a context that
assumes they exist.
If $hash2 is undefined, you'll get a warning if you attempt
to use it as a hashref, e.g.,
>> perl -Mstrict -lwe 'my $hash2; print %$hash2'
Can't use an undefined value as a HASH reference at -e line 1.
But you do not get a warning if you dereference %$hash2;
rather, a new hash is autovivified and a reference to it is
stored in $hash2.
>> perl -Mstrict -lwe 'my $hash2; print \%$hash2'
HASH(0x229a4)
Brian's
> > %hash1 = (%{\%$hash2}, %{\%$hash3});
takes advantage of this to supply an empty hash, sans
warnings, if the reference begins undefined.
-- Brad
------------------------------
Date: Tue, 13 Jun 2006 11:47:48 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Modifying ls
Message-Id: <b39t82p2pous8hnoo04m32nnfcdf76q4kl@4ax.com>
manian.k@gmail.com wrote:
>How can I push that information into an array.
>$array = 'ls -t'
Use
@array = `ls -t`;
instead. $array is not an array. `` will call the program and capture
the output.
>and usr array[1] to get the latest file.
make that
$array[0]
Which will pick the first array item. Warning: it'll have a newline
appended.
--
Bart.
------------------------------
Date: Tue, 13 Jun 2006 13:52:59 +0200
From: Anno Siegel <siegel@zrz.tu-berlin.de>
Subject: Re: Modifying ls
Message-Id: <4f7ncgF1hi3b7U1@news.dfncis.de>
John W. Krahn wrote:
> manian.k@gmail.com wrote:
[...]
>> How can I push that information into an array.
>> $array = 'ls -t'
>
> $array is a scalar not an array.
>
>> and usr array[1] to get the latest file.
>
> If you did that then the latest file would be in $array[0] not $array[1].
>
>
> Here's how to do it without calling an external program like ls:
>
>
> opendir DIR, '.' or die "Cannot open '.' directory: $!";
>
> my $latest = [ '', 0 ];
>
> while ( my $file = readdir DIR ) {
>
> my $mtime = ( stat $file )[ 9 ];
>
> $latest = [ $file, $mtime ] if $latest->[ 1 ] < $mtime;
> }
>
> closedir DIR;
>
> print "The latest file is $latest->[0].\n";
...or this. It will show all youngest files if there are more
than one:
use List::Util qw( min);
my %by_date;
push @{ $by_date{ -M $_} }, $_ for glob '* .*';
print "Youngest file(s): @$_\n" for $by_date{ min keys %by_date};
Anno
------------------------------
Date: Tue, 13 Jun 2006 07:58:44 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Modifying ls
Message-Id: <slrne8tdk4.tfm.tadmc@magna.augustmail.com>
Tad McClellan <tadmc@augustmail.com> wrote:
> manian.k@gmail.com <manian.k@gmail.com> wrote:
>
>> Example if I do ls -lt
>> drwx------+ 1 mkrishnamoorthy Domain Users 0 Feb 16 17:32
>> Application Data
>
>
>> I just want the time and the file name, that is
>>
>> Feb 16 17:32 Application Data
>>
>> How can I push that information into an array.
>
>
> my @array = map { chomp; substr($_, 43) } qx/ ls -lt /;
It would probably be better to use something with a more consistent
date format than ls uses.
Doing it in native Perl would have a consistent date format, and
be more portable too.
Seems like the Schwartzian transform (perldoc -q sort) would
be the Right Tool here:
my @array = map { localtime($_->[1]) . " $_->[0]" }
sort { $b->[1] <=> $a->[1] }
map { [ $_, (stat)[9] ] } glob '*';
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 13 Jun 2006 16:21:03 +0200
From: Mirco Wahab <peace.is.our.profession@gmx.de>
Subject: Re: Modifying ls
Message-Id: <e6mhr7$m2t$1@mlucom4.urz.uni-halle.de>
Thus spoke Tad McClellan (on 2006-06-13 14:58):
> Seems like the Schwartzian transform (perldoc -q sort) would
> be the Right Tool here:
>
>
> my @array = map { localtime($_->[1]) . " $_->[0]" }
> sort { $b->[1] <=> $a->[1] }
> map { [ $_, (stat)[9] ] } glob '*';
I tried to de-schwartzi-ficate this
and came up with the following:
my (%fn, $t);
$fn{$_} = [$t=(stat)[9], scalar localtime $t] for glob '*';
which can give the same results by:
print "$_ : $fn{$_}->[1]\n"
for
sort{ $fn{$b}->[0] <=> $fn{$a}->[0] }
keys %fn;
but I think, after all, the S.T. is more
appropriate here.
Regards
Mirco
------------------------------
Date: Tue, 13 Jun 2006 11:39:16 GMT
From: Salvador Fandino <sfandino@yahoo.com>
Subject: Re: OT: Anybody using Xemacs to edit Perl Code?
Message-Id: <448EA3D5.5030609@yahoo.com>
Ronny wrote:
> I'm using Xemacs "right out of the box" to edit Perl code. Xemacs
> correctly switches on CPerl mode automatically. However, it seems to
> have
> a very particular idea, how a Perl program should be laid out: Suppose
> I write
> a function definition like this:
>
> sub myfunc($)
> {
>
> As soon as I type the {, Xemacs positions it exactly under the "$"
> sign:
>
> sub myfunc($)
> {
> (i.e. it places the brace under the $ sign, which is silly IMO).
>
If I recall correctly this is a bug already solved in latest versions of
CPerl. It was caused by the prototype not being correctly parsed, and
"$)" got interpreted as a scalar variable.
A work around is to add an space between the "$" and the ")", for instance:
sub my func ($ )
{
...
Cheers,
- Salva
------------------------------
Date: Tue, 13 Jun 2006 14:19:23 +0200
From: Anno Siegel <siegel@zrz.tu-berlin.de>
Subject: Re: Question: Inline::C module packaging?
Message-Id: <4f7ou0F1hsjatU2@news.dfncis.de>
xhoster@gmail.com wrote:
> "Lee" <leegee@gmail.com> wrote:
[...]
>> I don't always find the "RTFM" response helpful, or even worth typing.
>
> Then ask smart questions right up front.
That probably got you a private reply to the effect that it wasn't
helpful but please don't consider him/her rude.
Anno
------------------------------
Date: Tue, 13 Jun 2006 16:34:52 +0200
From: dh <dh@metrohm.ch>
Subject: Symbol Table and References
Message-Id: <f34be$448ecd0c$3e02edc1$18481@news.hispeed.ch>
Hello,
I am trying to understand symbol tables and references. Maybe someone
can give me a hint.
Assume we are loking at symbol table st.
0) What is the internal format of a symbol table?
1) What is actually stored at e.g. @st? The data of @a or a pointer to
this data?
2) What is returned by (1,2,3), the data itself or a pointer to this data?
3) Is it correct, that a reference is simply a pointer?
4) What is *st exactly, a pointer to the start of the symbol table?
5) What is the difference between *st and /*st?
6) What exactly is a file handle?
Thank you, Daniel
------------------------------
Date: 13 Jun 2006 07:58:50 -0700
From: "Brad Baxter" <baxter.brad@gmail.com>
Subject: Re: Symbol Table and References
Message-Id: <1150210730.240593.246000@u72g2000cwu.googlegroups.com>
dh wrote:
> Hello,
> I am trying to understand symbol tables and references. Maybe someone
> can give me a hint.
> Assume we are loking at symbol table st.
> 0) What is the internal format of a symbol table?
> 1) What is actually stored at e.g. @st? The data of @a or a pointer to
> this data?
> 2) What is returned by (1,2,3), the data itself or a pointer to this data?
> 3) Is it correct, that a reference is simply a pointer?
> 4) What is *st exactly, a pointer to the start of the symbol table?
> 5) What is the difference between *st and /*st?
> 6) What exactly is a file handle?
>
> Thank you, Daniel
Have you read
perldoc perlreftut
perldoc perlref
perldoc perldata
--
Brad
------------------------------
Date: Tue, 13 Jun 2006 12:38:14 +0200
From: Anno Siegel <siegel@zrz.tu-berlin.de>
Subject: Re: Unable to flush o/p buffer
Message-Id: <4f7j0bF1hs75hU1@news.dfncis.de>
myflaneur@yahoo.com wrote:
> Hi:
>
> I have been trying to get my PERL script to flush the output buffer
> after each and every print statement. I have tried the following code
> snippets-none of which are working.
How do you know it isn't working? What do you expect and what does
it do instead?
> Any help/pointers will be greatly appreciated.
You're doing much too much in your program(s). It is enough to
set $| = 1 once, there is no need to do that in a loop. Also,
autoflushing is an alternative to calling flush() manually, it doesn't
make sense to do both.
> -------------------------------------------------------
> open(OUTPUT,">>my_output.txt");
> #within some loop
Take it out of the loop. Once is enough.
> {
> $cfh=select OUTPUT;
>
> $|=1;
>
> print OUTPUT "Some array";
> select $cfh;
>
> #$cfh->flush();
>
> #select(( select(OUTPUT), $|=1)[0]);
Why are you doning this *twice* per loop?
> }
>
> --------------------------------
>
> use IO::Handle;
> open(OUTPUT,">>my_output.txt");
> #within some loop
> {
> print OUTPUT "Some array";
> #OUTPUT->autoflush(1);
>
> #select(( select(OUTPUT), $|=1)[0]);
> }
>
> ---------------------------------
Anno
------------------------------
Date: Tue, 13 Jun 2006 09:15:18 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Using tee with Perl's system command
Message-Id: <g69pshdnqmx.fsf@CN1374059D0130.kendall.corp.akamai.com>
On 12 Jun 2006, olson_ord@yahoo.it wrote:
Ted Zlatanov wrote:
>> I would consider opening ls as a pipe:
>>
>> open F, "ls|" or die "Couldn't open ls pipe: $!";
>> open W, ">out.txt" or die "Couldn't write to out.txt: $!";
>>
>> while (<F>)
>> {
>> print;
>> print W $_;
>> }
> Thanks Ted for taking the time to respond. Here ls is just used as an
> example command - but I am actually calling one of my own executables
> here. I just wanted to provide a working example.
Oh, OK.
> I think this code suggested also has the property that it would just
> dump everything out after the execution. I don't want this because I
> want to see where my code gets stuck - in case of a crash in one of
> my test cases. Regards, O.O.
If you mean that you want STDERR as well (where errors are typically
printed in Unix), you need to redirect it. Look at "perldoc -q STDERR"
for specifics.
If you want the script to immediately output what it gets from the
command, set $| to 1 ("perldoc -q flush"). Otherwise the Perl output
is buffered so you won't necessarily get every line as it's printed by
the script. If the command buffers its output, that's a different
problem that Perl won't solve :)
Ted
------------------------------
Date: Tue, 13 Jun 2006 13:58:42 +0200
From: Yohan N. Leder <ynleder@nspark.org>
Subject: UTF-8 subject in an email
Message-Id: <MPG.1ef8c6dc9d98f907989893@news.tiscali.fr>
Hello,
I would like to send UTF-8 material and binary attachment in an email.
So, for this, I've built a multipart/mixed MIME message : no problem
about this.
But, my problem is about UTF-8 encoding.
The two parts which can contains no-ascii characters using UTF-8
encoding are : the subject and the body. So, I've first tried to encode
the subject line as indicated at http://www.ietf.org/rfc/rfc2047.txt. It
gives something like this :
use utf8;
use open ':utf8';
use Encode;
my $subject = encode('MIME-B', "boîte");
Email is well sent and received, but the client email I'm using (Eudora)
display the accentuated "i" as "î".
I've also tried not using Encode::MIME::Header, with several ways like :
my $subject = "=?UTF-8?B?".2b64("boîte")."?=";
my $subject = "=?UTF-8?B?".2b64(encode_utf8("boîte"))."?=";
And, even without "use open ':utf8';" which is used at sendmail pipe
time through "open (SENDMAIL, "|sendmail -t") or die "err open sendmail"
So, what's wrong ?
And I've not seen about body at this time :-(
------------------------------
Date: 13 Jun 2006 07:13:27 -0700
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: Re: UTF-8 subject in an email
Message-Id: <1150208007.607533.317210@u72g2000cwu.googlegroups.com>
Yohan N. Leder wrote:
> I would like to send UTF-8 material and binary attachment in an email.
> So, for this, I've built a multipart/mixed MIME message : no problem
> about this.
>
> But, my problem is about UTF-8 encoding.
>
> The two parts which can contains no-ascii characters using UTF-8
> encoding are : the subject and the body. So, I've first tried to encode
> the subject line as indicated at http://www.ietf.org/rfc/rfc2047.txt. It
> gives something like this :
>
> use utf8;
> use open ':utf8';
> use Encode;
> my $subject =3D encode('MIME-B', "bo=EEte");
>
> Email is well sent and received, but the client email I'm using (Eudora)
> display the accentuated "i" as "=C3=AE".
>
> I've also tried not using Encode::MIME::Header, with several ways like :
>
> my $subject =3D "=3D?UTF-8?B?".2b64("bo=EEte")."?=3D";
> my $subject =3D "=3D?UTF-8?B?".2b64(encode_utf8("bo=EEte"))."?=3D";
>
> And, even without "use open ':utf8';" which is used at sendmail pipe
> time through "open (SENDMAIL, "|sendmail -t") or die "err open sendmail"
>
> So, what's wrong ?
I think this is not a direct UTF-8 issue. If you encode the subject
line correctly to 7-bit ascii, it's then up to the email client how it
will decode the subject. I think there's not much more you can do.
Maybe Eudora doesn't like RFC2047 or UTF-8, or has only limited support
for it.
Does it work in Eudora when you have a line like:
Subject: =3D?utf-8?Q?bo=3DC3=3DAEte?=3D
or
Subject: =3D?utf-8?B?Ym/DrnRl?=3D
in stead of 'bo=EEte' ?
I would suggest to test your subject lines in as much emailclients as
possible.
--=20
Bart
------------------------------
Date: Tue, 13 Jun 2006 16:28:17 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: UTF-8 subject in an email
Message-Id: <e6mp38.17c.1@news.isolution.nl>
Yohan N. Leder schreef:
> use utf8;
This means that (you state that) your source code is in UTF-8 encoding.
> my $subject = encode('MIME-B', "boîte");
That "boîte" is probably not in UTF-8 but in Latin1?
Try "bo\x{EE}te", or just remove the "use utf8;" line.
Have you read the new perlunitut already?
(I have no URL, use Google)
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 9292
***************************************