[31483] in Perl-Users-Digest
Perl-Users Digest, Issue: 2742 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 29 18:09:45 2009
Date: Tue, 29 Dec 2009 15:09:10 -0800 (PST)
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, 29 Dec 2009 Volume: 11 Number: 2742
Today's topics:
Confused by utf8/sysread/syswrite/DBD::Pg <alexander.farber@gmail.com>
Re: Confused by utf8/sysread/syswrite/DBD::Pg <glex_no-spam@qwest-spam-no.invalid>
Re: FAQ 5.41 How do I delete a directory tree? <marc.girod@gmail.com>
Re: How to put '#!/usr/bin/env perl -w' at the beginnin <nospam-abuse@ilyaz.org>
Re: How to put '#!/usr/bin/env perl -w' at the beginnin (Randal L. Schwartz)
How to put '#!/usr/bin/env perl -w' at the beginning of <pengyu.ut@gmail.com>
Re: How to put '#!/usr/bin/env perl -w' at the beginnin <pengyu.ut@gmail.com>
Re: How to put '#!/usr/bin/env perl -w' at the beginnin <hjp-usenet2@hjp.at>
Re: How to put '#!/usr/bin/env perl -w' at the beginnin <veatchla@yahoo.com>
Perl to process "mbox" file <simopt@gmail.com>
Re: Perl to process "mbox" file <OJZGSRPBZVCX@spammotel.com>
Re: Perl to process "mbox" file <smallpond@juno.com>
Re: Perl to process "mbox" file <spamtotrash@toomuchfiction.com>
Re: Perl to process "mbox" file <simopt@gmail.com>
tk question repeat <robin1@cnsp.com>
Re: tk question repeat <paduille.4061.mumia.w+nospam@earthlink.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 29 Dec 2009 09:53:32 -0800 (PST)
From: "A. Farber" <alexander.farber@gmail.com>
Subject: Confused by utf8/sysread/syswrite/DBD::Pg
Message-Id: <0a772b88-5869-4ceb-adbe-3ae3d2dbe837@n16g2000yqm.googlegroups.com>
Hello,
I have a multiplayer card game at http://preferans.de
The Flash client sends and reads UTF8 data
(prepended by 16-bit length to make
Flash's readUTF() function happy)
to the non-forking Perl server.
Everything works fine until someone with a russian name joins.
Then the Perl print displays his name as garbage
(but not russian garbage ;-) and when I save
that name into PostgreSQL (UTF8 database) it looks
like this: http://preferans.de/viewforum.php?f=5
So I've added a utf8::decode($name) for all user names.
This has fixed print outputs and Postgres, but I've got
Wide character in syswrite at /usr/libdata/perl5/i386-openbsd/5.10.0/
IO/Handle.pm line 459.
After reading
http://london.pm.org/pipermail/london.pm/Week-of-Mon-20071210/011804.html
I understand that I need to utf8::encode() the
data I'm syswriting back to the Flash client.
Here is my modified function:
sub enqueue {
my $child = shift;
my $data = shift;
my $fh = $child->{FH};
my $response = $child->{RESPONSE};
# flash.net.Socket.readUTF() expects 16-bit prefix in network
order
my $prefix = pack 'n', length $data;
# append to the end of the outgoing queue
push @{$response}, $prefix . utf8::encode($data);
}
Unfortunately I get the warning
Use of uninitialized value $data in length at Child.pm line 234.
Use of uninitialized value $data in concatenation (.) or string at
Child.pm line 237.
and everything stops working.
Does anybody know what is going wrong here?
My data is just an urlencoded data like "user0=Russian_name".
Regards
Alex
PS: I'm using OpenBSD 4.5 with:
p5-pgsql-1.9.0p0
postgresql-client-8.3.6
postgresql-server-8.3.6
vim-7.2.77-no_x11
and
This is perl, v5.10.0 built for i386-openbsd
And I connect from Windows using Putty and Vim
who both are capable to display/edit UTF8.
------------------------------
Date: Tue, 29 Dec 2009 12:04:36 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Confused by utf8/sysread/syswrite/DBD::Pg
Message-Id: <4b3a44b4$0$87068$815e3792@news.qwest.net>
A. Farber wrote:
[...]
> Here is my modified function:
> sub enqueue {
> my $child = shift;
> my $data = shift;
> my $fh = $child->{FH};
> my $response = $child->{RESPONSE};
> # flash.net.Socket.readUTF() expects 16-bit prefix in network
> order
> my $prefix = pack 'n', length $data;
>
> # append to the end of the outgoing queue
> push @{$response}, $prefix . utf8::encode($data);
> }
>
> Unfortunately I get the warning
>
> Use of uninitialized value $data in length at Child.pm line 234.
> Use of uninitialized value $data in concatenation (.) or string at
> Child.pm line 237.
>
> and everything stops working.
>
> Does anybody know what is going wrong here?
> My data is just an urlencoded data like "user0=Russian_name".
You're sure? That warning is saying that $data is undefined.
------------------------------
Date: Tue, 29 Dec 2009 03:53:13 -0800 (PST)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: FAQ 5.41 How do I delete a directory tree?
Message-Id: <e58552bc-8266-4e32-881b-c9c5305f3741@k17g2000yqh.googlegroups.com>
On Dec 29, 11:00=A0am, PerlFAQ Server <br...@theperlreview.com> wrote:
> =A0 =A0 The first argument to "rmtree" is either a string representing a
> =A0 =A0 directory path or an array reference. The second argument control=
s
> =A0 =A0 progress messages, and the third argument controls the handling o=
f files
> =A0 =A0 you don't have permissions to delete. See the "File::Path" module=
for
> =A0 =A0 the details.
This is the 'legacy interface promoted before v2.00'...
I recently found that different versions expect different syntaxes...
I.e. there is a 'legacy interface promoted before v2.06',
and (in 2.08) function names, such as 'remove_tree'.
Marc
------------------------------
Date: Tue, 29 Dec 2009 22:05:21 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: How to put '#!/usr/bin/env perl -w' at the beginning of a perl script?
Message-Id: <slrnhjkv91.q8p.nospam-abuse@powdermilk.math.berkeley.edu>
On 2009-12-29, Peng Yu <pengyu.ut@gmail.com> wrote:
> Since my perl is installed in a nonstandard location, I have to use '/
> usr/bin/env perl'. I also what to use it with '-w'. I'm wondering how
> to do it.
>
> Currently, I have the following error.
>
> $ head -n 1 ./main.pl
> #!/usr/bin/env perl -w
> $ ./main.pl
> /usr/bin/env: perl -w: No such file or directory
Your (Unix) kernel cannot handle more than one argument. A known
limitation. You need to set the effect -w "by hand":
#!/usr/bin/env perl
BEGIN { $^W = 1 } # Can't use -w `with env perl'
Yours,
Ilya
------------------------------
Date: Tue, 29 Dec 2009 14:17:09 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: How to put '#!/usr/bin/env perl -w' at the beginning of a perl script?
Message-Id: <86aax1bf2y.fsf@blue.stonehenge.com>
>>>>> "Peng" == Peng Yu <pengyu.ut@gmail.com> writes:
Peng> Since my perl is installed in a nonstandard location, I have to use '/
Peng> usr/bin/env perl'. I also what to use it with '-w'. I'm wondering how
Peng> to do it.
Don't use "-w". Add "use warnings;" early in your script.
Also, /usr/bin/env perl is a hack. You should replace it with your
specific perl path.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
------------------------------
Date: Tue, 29 Dec 2009 13:44:57 -0800 (PST)
From: Peng Yu <pengyu.ut@gmail.com>
Subject: How to put '#!/usr/bin/env perl -w' at the beginning of a perl script?
Message-Id: <d34c8475-b8a3-4c34-8eeb-34da39d4d105@26g2000yqo.googlegroups.com>
Since my perl is installed in a nonstandard location, I have to use '/
usr/bin/env perl'. I also what to use it with '-w'. I'm wondering how
to do it.
Currently, I have the following error.
$ head -n 1 ./main.pl
#!/usr/bin/env perl -w
$ ./main.pl
/usr/bin/env: perl -w: No such file or directory
------------------------------
Date: Tue, 29 Dec 2009 14:25:28 -0800 (PST)
From: Peng Yu <pengyu.ut@gmail.com>
Subject: Re: How to put '#!/usr/bin/env perl -w' at the beginning of a perl script?
Message-Id: <53794f86-7269-4382-a784-ea101e43ad8c@a32g2000yqm.googlegroups.com>
On Dec 29, 4:17=A0pm, mer...@stonehenge.com (Randal L. Schwartz) wrote:
> >>>>> "Peng" =3D=3D Peng Yu <pengyu...@gmail.com> writes:
>
> Peng> Since my perl is installed in a nonstandard location, I have to use=
'/
> Peng> usr/bin/env perl'. I also what to use it with '-w'. I'm wondering h=
ow
> Peng> to do it.
>
> Don't use "-w". =A0Add "use warnings;" early in your script.
>
> Also, /usr/bin/env perl is a hack. =A0You should replace it with your
> specific perl path.
If I use my specific perl path, it will not be portable, right? After
all, if it moves to a different machine, the path has to be fixed.
------------------------------
Date: Tue, 29 Dec 2009 23:14:21 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: How to put '#!/usr/bin/env perl -w' at the beginning of a perl script?
Message-Id: <slrnhjkvpt.qb1.hjp-usenet2@hrunkner.hjp.at>
On 2009-12-29 21:44, Peng Yu <pengyu.ut@gmail.com> wrote:
> Since my perl is installed in a nonstandard location, I have to use '/
> usr/bin/env perl'.
[...]
> #!/usr/bin/env perl -w
No. You should use
#!/path/to/your/perl -w
instead.
> I also what to use it with '-w'. I'm wondering how
> to do it.
>
> Currently, I have the following error.
>
> $ head -n 1 ./main.pl
> #!/usr/bin/env perl -w
> $ ./main.pl
> /usr/bin/env: perl -w: No such file or directory
This is because the syntax for the shebang line is extremely restrictive
on most unixes. In this case (Linux?) everything after the first space
is passed to /usr/bin/env as a single argument. There may be a
workaround but The Right Thing(TM) is to use the correct path to perl in
the first place.
hp
------------------------------
Date: Tue, 29 Dec 2009 16:44:09 -0600
From: l v <veatchla@yahoo.com>
Subject: Re: How to put '#!/usr/bin/env perl -w' at the beginning of a perl script?
Message-Id: <hhe0nr$nn4$1@news.eternal-september.org>
On 12/29/2009 4:25 PM, Peng Yu wrote:
> On Dec 29, 4:17 pm, mer...@stonehenge.com (Randal L. Schwartz) wrote:
>>>>>>> "Peng" == Peng Yu<pengyu...@gmail.com> writes:
>>
>> Peng> Since my perl is installed in a nonstandard location, I have to use '/
>> Peng> usr/bin/env perl'. I also what to use it with '-w'. I'm wondering how
>> Peng> to do it.
>>
>> Don't use "-w". Add "use warnings;" early in your script.
>>
>> Also, /usr/bin/env perl is a hack. You should replace it with your
>> specific perl path.
>
> If I use my specific perl path, it will not be portable, right? After
> all, if it moves to a different machine, the path has to be fixed.
Create a symbolic link for /usr/bin/perl to your non-standard location
and you should then be able to use the correct shebang in your Perl scripts.
--
Len
------------------------------
Date: Mon, 28 Dec 2009 11:40:06 -0800 (PST)
From: Shankar <simopt@gmail.com>
Subject: Perl to process "mbox" file
Message-Id: <1049e0ef-81ca-408a-b85c-f23105e81ade@j42g2000yqd.googlegroups.com>
Hello,
Can someone please point me to a way to accomplish the following task.
I have made a copy of my "mbox" file in my AIX account, for processing
as follows.
I w'd like to automate:
1. Run through the mbox copy, and for each mail, using some logic on
fields like From, Date/Time, Subject, decide whether or not it is a
mail of interest.
2. If it is a mail of interest, examine whether or not it has
attachments. Then, save the attachments to a directory.
The attachments w'd be of type: *.txt, *.ps, *.pdf, *.doc
I have used PERL in the distant past for scripting on Unix, so thought
of going back to PERL.
I was hoping the PERL gurus w'd point me to a way to accomplish the
above, which I w'd have to do manually otherwise. The number of mails
in the mbox is quite large, so wish to automate.
Thanks a lot for your help,
Shankar
------------------------------
Date: Mon, 28 Dec 2009 21:42:13 +0100
From: "Jochen Lehmeier" <OJZGSRPBZVCX@spammotel.com>
Subject: Re: Perl to process "mbox" file
Message-Id: <op.u5n04odemk9oye@frodo>
On Mon, 28 Dec 2009 20:40:06 +0100, Shankar <simopt@gmail.com> wrote:
> Can someone please point me to a way to accomplish the following task.
http://search.cpan.org/~dcoppit/Mail-Mbox-MessageParser-1.5002/lib/Mail/Mbox/MessageParser/Perl.pm
or
http://search.cpan.org/~vparseval/Mail-MboxParser-0.55/
(I don't know either, they just turned up on google "perl mbox" and their
description seems to fit).
> 2. If it is a mail of interest, examine whether or not it has
> attachments. Then, save the attachments to a directory.
Mail::MboxParser::Mail has methods to get the attachments and headers.
> I was hoping the PERL gurus w'd point me to a way to accomplish the
> above, which I w'd have to do manually otherwise. The number of mails
> in the mbox is quite large, so wish to automate.
The example code given in the above pages should get you started. Feel
free to post more specific questions (together with your code so far, and
a short mbox file for testing).
------------------------------
Date: Mon, 28 Dec 2009 15:48:14 -0500
From: Steve C <smallpond@juno.com>
Subject: Re: Perl to process "mbox" file
Message-Id: <hhb5iu$hai$1@news.eternal-september.org>
Shankar wrote:
> Hello,
>
> Can someone please point me to a way to accomplish the following task.
>
> I have made a copy of my "mbox" file in my AIX account, for processing
> as follows.
> I w'd like to automate:
>
> 1. Run through the mbox copy, and for each mail, using some logic on
> fields like From, Date/Time, Subject, decide whether or not it is a
> mail of interest.
> 2. If it is a mail of interest, examine whether or not it has
> attachments. Then, save the attachments to a directory.
> The attachments w'd be of type: *.txt, *.ps, *.pdf, *.doc
>
> I have used PERL in the distant past for scripting on Unix, so thought
> of going back to PERL.
> I was hoping the PERL gurus w'd point me to a way to accomplish the
> above, which I w'd have to do manually otherwise. The number of mails
> in the mbox is quite large, so wish to automate.
>
There are many CPAN modules dedicated to handling and parsing mail,
so you won't need to start from scratch.
I see Mail::MboxParser which claims to properly handle attachments
of mail in an MBox file, but you should look through some of the
others.
------------------------------
Date: Mon, 28 Dec 2009 21:06:33 +0000 (UTC)
From: Kevin Collins <spamtotrash@toomuchfiction.com>
Subject: Re: Perl to process "mbox" file
Message-Id: <slrnhji7eq.95p.spamtotrash@vai.unix-guy.com>
On 2009-12-28, Shankar <simopt@gmail.com> wrote:
[snip]
> I w'd like to automate:
^^^
Is that supposed to be "would"? There is no contraction for that word, and this
is not a chat room, so please spell it out.
Thanks,
Kevin
------------------------------
Date: Mon, 28 Dec 2009 14:40:29 -0800 (PST)
From: Shankar <simopt@gmail.com>
Subject: Re: Perl to process "mbox" file
Message-Id: <e607ee37-3b37-48a4-89fa-a87dfe90fb99@z41g2000yqz.googlegroups.com>
On Dec 28, 3:48=A0pm, Steve C <smallp...@juno.com> wrote:
> Shankar wrote:
> > Hello,
>
> > Can someone please point me to a way to accomplish the following task.
>
> > I have made a copy of my "mbox" file in my AIX account, for processing
> > as follows.
> > I w'd like to automate:
>
> > 1. Run through the mbox copy, and for each mail, using some logic on
> > fields like From, Date/Time, Subject, decide whether or not it is a
> > mail of interest.
> > 2. If it is a mail of interest, examine whether or not it has
> > attachments. Then, save the attachments to a directory.
> > The attachments w'd be of type: *.txt, *.ps, *.pdf, *.doc
>
> > I have used PERL in the distant past for scripting on Unix, so thought
> > of going back to PERL.
> > I was hoping the PERL gurus w'd point me to a way to accomplish the
> > above, which I w'd have to do manually otherwise. The number of mails
> > in the mbox is quite large, so wish to automate.
>
> There are many CPAN modules dedicated to handling and parsing mail,
> so you won't need to start from scratch.
>
> I see Mail::MboxParser which claims to properly handle attachments
> of mail in an MBox file, but you should look through some of the
> others.
Thanks Steve and Jochem.
I'll take a look at the above.
Upon digging around further, I also came across:
http://perl.overmeer.net/mailbox/html/manuals/index.html
Thanks,
Shankar
------------------------------
Date: Mon, 28 Dec 2009 15:26:54 -0800 (PST)
From: Robin <robin1@cnsp.com>
Subject: tk question repeat
Message-Id: <589f9ee1-98a0-48c8-bddf-902f0597c253@m26g2000yqb.googlegroups.com>
In tk, how can I get a subrountine to be called over and over again
for a certain period of time...
Thanks in advancem
-Robin
------------------------------
Date: Mon, 28 Dec 2009 22:34:12 -0600
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: tk question repeat
Message-Id: <HrSdnWLxv7aGlafWnZ2dnUVZ_sadnZ2d@earthlink.com>
On 12/28/2009 05:26 PM, Robin wrote:
> In tk, how can I get a subrountine to be called over and over again
> for a certain period of time...
>
> Thanks in advancem
> -Robin
See the documentation for Tk::After; you'll be most interested in the
'repeat' method.
------------------------------
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 2742
***************************************