[27930] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9294 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 13 21:05:47 2006

Date: Tue, 13 Jun 2006 18: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: 9294

Today's topics:
    Re: Can't find syntax error <someone@example.com>
    Re: Earthquake and Tornado Forecasting Programs   June  <cbfalconer@yahoo.com>
        IE Mechanize urls -- what about escaping? nsb_tsd@eml.cc
    Re: IE Mechanize urls -- what about escaping? <glex_no-spam@qwest-spam-no.invalid>
    Re: Looking for a VERY EFFICIENT module for XML <ignoramus24559@NOSPAM.24559.invalid>
    Re: Permutations/combinations from multiple arrays charley@pulsenet.com
    Re: Permutations/combinations from multiple arrays <someone@example.com>
    Re: Permutations/combinations from multiple arrays xhoster@gmail.com
    Re: read a webpage with username/password <mritty@gmail.com>
    Re: Unable to flush o/p buffer myflaneur@yahoo.com
        use WWW:Mechanize to read secure webpage <jiehuang001@hotmail.com>
    Re: use WWW:Mechanize to read secure webpage <no@email.com>
    Re: use WWW:Mechanize to read secure webpage <glex_no-spam@qwest-spam-no.invalid>
    Re: UTF-8 subject in an email [Binary/Quoted-Printable] <anfi@onet.eu>
    Re: UTF-8 subject in an email <ynleder@nspark.org>
    Re: UTF-8 subject in an email <rvtol+news@isolution.nl>
    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 21:04:28 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Can't find syntax error
Message-Id: <wLFjg.49316$S61.44757@edtnps90>

Eric wrote:
> 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 :).

Then you probably used:

while ( $fh ) {

Instead of:

while ( <$fh> ) {

The <> (readline) operator is required to read a line from the filehandle $fh
and put the contents of each line in the $_ variable.



John
-- 
use Perl;
program
fulfillment


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

Date: Tue, 13 Jun 2006 14:03:57 -0400
From: CBFalconer <cbfalconer@yahoo.com>
Subject: Re: Earthquake and Tornado Forecasting Programs   June 13, 2006
Message-Id: <448EFE0D.3B2D968B@yahoo.com>

Frank Silvermann wrote:
> 
> [snip]
> I look forward to a day when meteorology has more to do with precise
> models than models, although I'm all for Russian-style delivery of such
> data.  I forecast that a lot of people will be surprised by the weather
> today, as they are categorical idiots, as is the OP.  frank

Oh for a newsreader that can eliminate all such ugly excessively
cross-posted articles lacking follow-ups.  PLONK thread is the only
remaining answer.

-- 
 Some informative links:
   news:news.announce.newusers
   http://www.geocities.com/nnqweb/
   http://www.catb.org/~esr/faqs/smart-questions.html
   http://www.caliburn.nl/topposting.html
   http://www.netmeister.org/news/learn2quote.html




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

Date: 13 Jun 2006 15:49:22 -0700
From: nsb_tsd@eml.cc
Subject: IE Mechanize urls -- what about escaping?
Message-Id: <1150238962.373813.101250@u72g2000cwu.googlegroups.com>

I am munging together a url from the following snippet of html. It
shows the button I want to click, except it's accessed thru Javascript.
The jscript opens a new window which makes the content inaccessible, so
that's why I want to munge the address myself, so I can open it in the
same window.

For munging I extract the key value, append it to the base url, and do
an IE->get().

Does IE->get() do url escaping? The key value below is already escaped,
and I don't know if IE is unescaping the character codes. How would I
ensure that IE escapes the slashes in the key?

Thanks!
nb

(form code follows)

<INPUT type=hidden value=%2FxxxD%2Fxxa%2FS%2FasdfF%2Fbsa%2FNI
L%2FNIL%2FXF%252 name=aname>

<INPUT
onclick="JavaScript: myWindow = window.open('Some.jsp?keyvalue=' +
this.form.aname.value, 'winname', 'width=40, height=10') "
type=button
value="Click Me">

(perl code follows)

   $cnt=$ie->content;
    #print $cnt;
    $reg_str = 'INPUT type=hidden value=(.*) name=aname';
    $cnt =~ qr/$reg_str/;
    $urltogo = $1;
     print "Found! \n==========\n$urltogo\n=========\n";
    $navig_url = 'http://ninjasite:25/abc/';
    #$urltogo =~ s#%2F#/#g;
    $jscript_added = 'Some.jsp?keyvalue=' & $urltogo ;
    $gotou = $navig_url & $jscript_added;
    print "Going to ::$gotou::\n";
    $ie->get($gotou);
# fails here -- goes to wrong address.
    sleep(12);
    die



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

Date: Tue, 13 Jun 2006 18:09:45 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: IE Mechanize urls -- what about escaping?
Message-Id: <yFHjg.38$872.77341@news.uswest.net>

nsb_tsd@eml.cc wrote:
> I am munging together a url from the following snippet of html. It
> shows the button I want to click, except it's accessed thru Javascript.
> The jscript opens a new window which makes the content inaccessible, so
> that's why I want to munge the address myself, so I can open it in the
> same window.
> 
> For munging I extract the key value, append it to the base url, and do
> an IE->get().
> 
> Does IE->get() do url escaping? The key value below is already escaped,
> and I don't know if IE is unescaping the character codes. How would I
> ensure that IE escapes the slashes in the key?

WTF is IE->get???


>     $jscript_added = 'Some.jsp?keyvalue=' & $urltogo ;
>     $gotou = $navig_url & $jscript_added;

Why are you doing a bitwise and of two scalars??

>     print "Going to ::$gotou::\n";
>     $ie->get($gotou);
> # fails here -- goes to wrong address.

Print the value of it and debug from there.


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

Date: Tue, 13 Jun 2006 19:39:15 GMT
From: Ignoramus24559 <ignoramus24559@NOSPAM.24559.invalid>
Subject: Re: Looking for a VERY EFFICIENT module for XML
Message-Id: <DvEjg.4288$2B4.3946@fe84.usenetserver.com>

On 13 Jun 2006 16:50:49 GMT, xhoster@gmail.com <xhoster@gmail.com> wrote:
> Ignoramus24559 <ignoramus24559@NOSPAM.24559.invalid> wrote:
>> On 13 Jun 2006 15:36:28 GMT, xhoster@gmail.com <xhoster@gmail.com> wrote:
>> > Ignoramus17503 <ignoramus17503@NOSPAM.17503.invalid> wrote:
>> >> On 12 Jun 2006 22:07:06 GMT, xhoster@gmail.com <xhoster@gmail.com>
>> >> wrote:
>> >> > Ignoramus17503 <ignoramus17503@NOSPAM.17503.invalid> wrote:
>> >> >> Right now I use XML::Simple. As it turns out, this module is
>> >> >> relatively slow to parse big XML texts.
>> >> >
>> >> > XML::Simple just uses some other module to do the actual parsing.
>> >> > What part is slow, the actual parsing, or the XML::Simple part of
>> >> > the code?  Have you profiled it to see?  You might be using
>> >> > XML::SAX::PurePerl behind the scenes, which is going to be slow.
>> >>
>> >> Well, what I want is to convert XML into perl structures, out of which
>> >> I would then get data.
>> >>
>> >> Yes, I profiled it, XML::Simple takes most of the time.
>> >>
>> >> I am looking for some simple alternatives, it is killing me.
>> >
>> > Could you post the dprofpp output, or something that generates
>> > realistic XML for us to benchmark ourselves?
>>
>> Good question, but I already switched to XML::Twig, and everything is
>> just fine after that.
>
> I'm glad you found a solution, but it is hard to believe that XML::Twig is
> faster than XML::Simple *if* you are using Twig to load the entire document.

I am doing just that.

> I generally find XML::Simple faster than XML::Twig for that, and easier to
> use to boot.

I also find XML::Simple easier to use. It is, simply put, a great
module! And, possibly, I overlooked something that made it seem slow. 

> (Unless, of course, XML::Simple is falling back on XML::SAX::PurePerl).

I have no idea what mine used. I will check at some point. 

>
> time perl -le 'use XML::Simple; $XML::Simple::PREFERRED_PARSER=""; \
>     use Data::Dumper; XMLin("test.xml") foreach 1..300' > /dev/null
> 8.445u 0.084s 0:08.59 99.1%     0+0k 0+0io 0pf+0w
>
> time perl -le 'use XML::Simple;\
>    $XML::Simple::PREFERRED_PARSER="XML::Parser";\
>    use Data::Dumper; XMLin("test.xml") foreach 1..300' > /dev/null
> 6.443u 0.055s 0:06.60 98.3%     0+0k 0+0io 0pf+0w
>
> subspace/perl_misc> time perl -le 'use XML::Simple; \
>     $XML::Simple::PREFERRED_PARSER="XML::SAX::PurePerl"; use Data::Dumper;\
>     XMLin("test.xml") foreach 1..300' > /dev/null
> 61.260u 0.100s 1:01.49 99.7%    0+0k 0+0io 0pf+0w
>
> subspace/perl_misc> time perl -le 'use XML::Twig; use Data::Dumper; \
>   do {my $x = XML::Twig->new(); $x->parsefile("test3.xml")} \
>   foreach 1..300' > /dev/null
> 8.942u 0.046s 0:09.08 98.8%     0+0k 0+0io 0pf+0w

Your stats are very impressive. Maybe it is indeed a PurePerl issue.

I kept the old code, actually, I switch between old and new code with
an if statement. if( 0 ) etc. 

So, when I have some time, I will check what preferred parser I use
for XML::Simple (it seems, from looking at its source code, that it is
set to undef by default), and maybe I can change that, because I like
XML::Simple a lot better.

You seem to actually know what you are talking about, which is
fantastic.

i



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

Date: 13 Jun 2006 11:09:32 -0700
From: charley@pulsenet.com
Subject: Re: Permutations/combinations from multiple arrays
Message-Id: <1150222172.875708.17360@p79g2000cwp.googlegroups.com>


Peter Ensch wrote:
> Not sure if the correct word is permutation or combination (or neither), but
> this is what I want to do. Given an array of arrays, such as:
>
> my @v = (
>   [qw/ a /],
>   [qw/ b c d /],
>   [qw/ e f g /],
> );
>
> I want to output all the permutations/combinations from taking one item
> from each array, like this:
>
> a b e
> a b f
> a b g
> a c e
> a c f
> a c g
> a d e
> a d f
> a d g
>
> The function should be able to handle any number of arrays with any
> number of elements in each array.
>
> This sounds easy but I'm stuck. Help!
> Peter
>
> --
>
> ^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
> Peter Ensch,
> pensch@ti.com           A-1140   (214) 480 2333
> ^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^

You could do it with the Cross Product.

#!/usr/bin/perl
use strict;
use warnings;
use Set::CrossProduct;

my @v = (
  [qw/ a /],
  [qw/ b c d /],
  [qw/ e f g /],
);

my $iterator = Set::CrossProduct->new( \@v );

my @tuples = $iterator->combinations;

print map{"@$_\n"} @tuples;

**prints

a b e
a b f
a b g
a c e
a c f
a c g
a d e
a d f
a d g



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

Date: Tue, 13 Jun 2006 21:19:12 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Permutations/combinations from multiple arrays
Message-Id: <kZFjg.49320$S61.5106@edtnps90>

Peter Ensch wrote:
> Not sure if the correct word is permutation or combination (or neither), but
> this is what I want to do. Given an array of arrays, such as:
> 
> my @v = (
>   [qw/ a /],
>   [qw/ b c d /],
>   [qw/ e f g /],
> );
> 
> I want to output all the permutations/combinations from taking one item
> from each array, like this:
> 
> a b e
> a b f
> a b g
> a c e
> a c f
> a c g
> a d e
> a d f
> a d g
> 
> The function should be able to handle any number of arrays with any 
> number of elements in each array.

$ perl -le'
my @v = (
  [qw/ a /],
  [qw/ b c d /],
  [qw/ e f g /],
);
print "@{[ /./g ]}" for glob join "", map { local $" = ","; "{@$_}" } @v;
'
a b e
a b f
a b g
a c e
a c f
a c g
a d e
a d f
a d g



John
-- 
use Perl;
program
fulfillment


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

Date: 13 Jun 2006 21:45:48 GMT
From: xhoster@gmail.com
Subject: Re: Permutations/combinations from multiple arrays
Message-Id: <20060613174602.833$qh@newsreader.com>

"John W. Krahn" <krahnj@telus.net> wrote:
> Peter Ensch wrote:
> > Not sure if the correct word is permutation or combination (or
> > neither), but this is what I want to do. Given an array of arrays, such
> > as:
> >
> > my @v = (
> >   [qw/ a /],
> >   [qw/ b c d /],
> >   [qw/ e f g /],
> > );
> >
> > I want to output all the permutations/combinations from taking one item
> > from each array, like this:
> >
> > a b e
> > a b f
> > a b g
> > a c e
> > a c f
> > a c g
> > a d e
> > a d f
> > a d g
> >
> > The function should be able to handle any number of arrays with any
> > number of elements in each array.
>
> $ perl -le'
> my @v = (
>   [qw/ a /],
>   [qw/ b c d /],
>   [qw/ e f g /],
> );
> print "@{[ /./g ]}" for glob join "", map { local $" = ","; "{@$_}" } @v;
> '

I wouldn't recommend this as a general method for handling "any number of
arrays with any number elements" for two reasons.  One is that it builds
the entire list in memory upfront, so it consumes massive amounts
of memory for large results.  The other is that it beats up your file
system by trying to lstat every single thing that gets returned.  (I have
no idea why it does this, as it returns it whether it exists or not, but
strace shows that it does indeed do this.)

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: 13 Jun 2006 12:48:51 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: read a webpage with username/password
Message-Id: <1150228131.772513.191020@p79g2000cwp.googlegroups.com>

jiehuang001@hotmail.com wrote:
> Hi, Paul:
>
> Thank you very much.

You're welcome.  For what, may I ask?  Please quote context when
posting a reply.

> But as you will see, the following code does not
> work.

The code works perfectly for what it was designed to do.  The problem
is that you incorrectly stated your problem description.

> Any help would be deeply appreciated.

You incorrectly stated your problem description.  You said that you had
a URL, but that a user/password was required to access that URL.  That
turns out to not be the case.  Instead, you have a URL whose page
contains a form.  That form has user and password  fields.  Submission
of that form will take you to the actual URL you wanted to go to.

Use WWW::Mechanize.

Paul Lalli



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

Date: 13 Jun 2006 13:37:41 -0700
From: myflaneur@yahoo.com
Subject: Re: Unable to flush o/p buffer
Message-Id: <1150231061.178532.279970@g10g2000cwb.googlegroups.com>

Hi:

Thanks for the response.

I am trying to read data from a file, parse the data, and print it out
into another file. The while loop reads the data.  I am expecting to
see the output file grow as time progresses and also for the parsed
data to be saved in case of abnormal termination of the script.

After trying out several flavors of the flush command-I could not see
either the output files growing (on checking every 3 minutes) nor the
buffer being saved on a Ctrl-z.

Thanks.


Anno Siegel wrote:
> 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: 13 Jun 2006 14:19:53 -0700
From: "jiehuang001@hotmail.com" <jiehuang001@hotmail.com>
Subject: use WWW:Mechanize to read secure webpage
Message-Id: <1150233593.951932.191200@g10g2000cwb.googlegroups.com>

I just found the following code supposed to be able to login into a
page and read the content. I run it without any error. But how I can
print out the content of the webpage??

#! /Perl/bin/perl

use WWW::Mechanize;

# What site are we connecting to?
my $url = "http://www.securepage.com";

# Username
my $username = "username";

# Password
my $password = "password";

# Create a new instance of WWW::Mechanize
my $mechanize = WWW::Mechanize->new(autocheck => 1);

# Supply the necessary credentials
$mechanize->credentials($url, $username, $password);

# Retrieve the desired page
$mechanize->get("$url/securepage.html");



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

Date: Tue, 13 Jun 2006 22:22:13 +0100
From: Brian Wakem <no@email.com>
Subject: Re: use WWW:Mechanize to read secure webpage
Message-Id: <4f8ok5F1hnte6U1@individual.net>

jiehuang001@hotmail.com wrote:

> I just found the following code supposed to be able to login into a
> page and read the content. I run it without any error. But how I can
> print out the content of the webpage??
> 
> #! /Perl/bin/perl
> 
> use WWW::Mechanize;
> 
> # What site are we connecting to?
> my $url = "http://www.securepage.com";
> 
> # Username
> my $username = "username";
> 
> # Password
> my $password = "password";
> 
> # Create a new instance of WWW::Mechanize
> my $mechanize = WWW::Mechanize->new(autocheck => 1);
> 
> # Supply the necessary credentials
> $mechanize->credentials($url, $username, $password);
> 
> # Retrieve the desired page
> $mechanize->get("$url/securepage.html");


print $mechanize->content();


-- 
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png


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

Date: Tue, 13 Jun 2006 18:01:00 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: use WWW:Mechanize to read secure webpage
Message-Id: <kxHjg.19$xl6.4806@news.uswest.net>

jiehuang001@hotmail.com wrote:
> I just found the following code supposed to be able to login into a
> page and read the content. I run it without any error. But how I can
> print out the content of the webpage??

By reading the documentation.

perldoc WWW::Mechanize


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

Date: Wed, 14 Jun 2006 01:00:28 +0200
From: Andrzej Adam Filip <anfi@onet.eu>
Subject: Re: UTF-8 subject in an email [Binary/Quoted-Printable]
Message-Id: <877j3k7jar.fsf@anfi.homeunix.net>

Yohan N. Leder <ynleder@nspark.org> writes:
> 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");
> [...]

Why do you use binary encoding instead of quoted-printable? [MIME-Q]
Quoted-printable is the best choice for encoding of "mostly" ascii text.

-- 
[pl2en: Andrew] Andrzej Adam Filip : anfi@priv.onet.pl : anfi@xl.wp.pl
http://anfi.homeunix.net/            http://www.linkedin.com/in/andfil


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

Date: Tue, 13 Jun 2006 20:15:44 +0200
From: Yohan N. Leder <ynleder@nspark.org>
Subject: Re: UTF-8 subject in an email
Message-Id: <MPG.1ef91f38ed947656989897@news.tiscali.fr>

In article <MPG.1ef8c6dc9d98f907989893@news.tiscali.fr>, 
ynleder@nspark.org says...
> 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. 
> 
> Email is well sent and received, but the client email I'm using (Eudora) 
> display the accentuated "i" as "î".

OK, I've searched a little and found that some popular client emails and 
webmail interfaces doesn't take care at all of Unicode (for example, 
take a look at :

http://www.questionpoint.org/crs/html/help/en/home/home_unicode.html

It's a pity, but I can't ignore it, simply because a lot of my users 
will use some of thoses (first being Eudora).

Then, even if all of my scripts now handle Unicode (UTF-8) at every 
level, I have to found a way to send the emails they have to send in a 
way which may be supported by the majority of popular email clients.

So, I've though about an algorithm, knowing subject and body come from 
UTF-8 strings.

About Subject : 
------------
 Since the email scripts have to send are reports and notifications, I 
can decide of the subject (thus, remove actual possibility for use to 
change it) and manage to povide some in ISO-8859-1 only. However, since 
something like Eudora just ignore the word-encoding, I will simply pass 
subject as it is, and without charset specification.

About Body :
----------
Here it's different, because it's amix between stuffs from script itself 
and checked user inputs... So, it may contain any characters and signs, 
including accentuated upper/lower, euro, percent, etc. Then, here is the 
way I've though, awaiting your opinion :

1 - Does body contains at least one character which cannot be 
represented in ISO-8859-1 ?

2a - No => I add "binmode(SENDMAIL,':encoding(iso-8859-1)')" after pipe 
opening, and just indicate "Content-Type: text/plain; charset='iso-8859-
1'" ahead of body part.

    Yes => I encode body in Base64 and send it as an attachment (second 
one since it may already contain one) using "Content-Transfer-Encoding: 
base64" and "Content-Type: text/plain; name=notif.txt", or "Content-
Type: test/html; name=notif.htm" with indication of charset as UTF-8 in 
an html file containing the minimum required tags and notification 
content. 

2b - Or, in replacement of 2a, I build an HTML email indicating UTF-8 
charset, hoping the most used client will be able to read HTML and user 
didn't unckeked this option in their client email.

What do you think about this solution ? Do you have another idea ? Do 
you see something wrong there ?


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

Date: Wed, 14 Jun 2006 00:08:04 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: UTF-8 subject in an email
Message-Id: <e6nk1n.sk.1@news.isolution.nl>

Yohan N. Leder schreef:
> Ruud:
>> Yohan:

>>> use utf8;
>>
>> This means that (you state that) your source code is in UTF-8
>> encoding.
>
> Yes ! Edited under Komodo only.

OK.


>> Have you read the new perlunitut already?
>> (I have no URL, use Google)
>
> Found here <http://users.tkk.fi/~jhi/perlunitut.pod>. Sounds like the
> same as perluniintro (from memory).

That is indeed perluniintro. I meant a new one, by Juerd.



Check the "Content" header fields too, you'll need ones like:
  Content-Type: text/plain; charset="UTF-8"
  Content-Transfer-Encoding: 8bit
for the body to be recognized as encoded in UTF-8.


A compliant Subject-header can only have 7-bit characters, so you need
to do

  use utf8 ;
  ...
  my $subject = encode( 'MIME_Header', 'Subject: boîte' ) ;


Test:

  perl -MEncode -le 'print "Subject: " . encode("MIME-Header",
"bo\x{00EE}te")'

prints: Subject: =?UTF-8?B?Ym/DrnRl?=

-- 
Affijn, Ruud

"Gewoon is een tijger."




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

Date: Wed, 14 Jun 2006 00:34:59 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: UTF-8 subject in an email
Message-Id: <e6nllj.fo.1@news.isolution.nl>

Dr.Ruud schreef:

>   my $subject = encode( 'MIME_Header', 'Subject: boîte' ) ;

Better:

    my $subject = 'Subject: ' . encode( 'MIME_Header', 'boîte' ) ;

because the single space after the colon after the header field name is
expected by some systems.

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


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