[30069] in Perl-Users-Digest
Perl-Users Digest, Issue: 1312 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 27 03:09:40 2008
Date: Wed, 27 Feb 2008 00:09:05 -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 Wed, 27 Feb 2008 Volume: 11 Number: 1312
Today's topics:
changing the date/time stamp <rsarpi@gmail.com>
Re: changing the date/time stamp <peter@makholm.net>
Re: changing the date/time stamp <rsarpi@gmail.com>
classified script <swasaaron@gmail.com>
Re: CPAN and man page installation <vincent+news@vinc17.org>
Re: How to set file attributes <john@castleamber.com>
Re: How to set file attributes <abigail@abigail.be>
Re: How to set file attributes <John.Smith@invalid.com>
new CPAN modules on Wed Feb 27 2008 (Randal Schwartz)
Re: uc() and utf8 <hjp-usenet2@hjp.at>
Re: uc() and utf8 <ben@morrow.me.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 26 Feb 2008 14:02:08 -0800 (PST)
From: monk <rsarpi@gmail.com>
Subject: changing the date/time stamp
Message-Id: <a35545d5-4a00-439d-a946-451880a046d5@e23g2000prf.googlegroups.com>
Is there a "perl way" of modifying the date/time stamp of a file? Is
there a core function or core module I'm overlooking?
I guess I'd like to emulate or find the equivalent of the 'touch'
command without using system ('touch...')
# from the shell, modify xfile creation date to year 2001 January day
30 time 13:50:26
touch -t 200101301350.26 xfile
thanks in advance.
------------------------------
Date: Tue, 26 Feb 2008 22:06:00 +0000
From: Peter Makholm <peter@makholm.net>
Subject: Re: changing the date/time stamp
Message-Id: <87tzjv74qf.fsf@hacking.dk>
monk <rsarpi@gmail.com> writes:
> Is there a "perl way" of modifying the date/time stamp of a file? Is
> there a core function or core module I'm overlooking?
See the documentation of the utime function in perlfunc.
//Makholm
------------------------------
Date: Tue, 26 Feb 2008 14:15:42 -0800 (PST)
From: monk <rsarpi@gmail.com>
Subject: Re: changing the date/time stamp
Message-Id: <0f20286c-eaa0-4235-a301-edb24020602b@h11g2000prf.googlegroups.com>
just what the doctor recommended.
you da man!! thanks.
------------------------------
Date: Tue, 26 Feb 2008 22:10:28 -0800 (PST)
From: Agnes <swasaaron@gmail.com>
Subject: classified script
Message-Id: <e0479593-1a86-4322-9fa0-8685c8b8e2f4@s8g2000prg.googlegroups.com>
AJ Classifieds empowers your online community with effective tools to
attract and retain more visitors to your web site. With AJ
Classifieds, you can build and brand your own classifieds site
customized to the unique needs of your market, whether it's for
consumers or other businesses.
sources: http://www.ajclassifieds.net
------------------------------
Date: Wed, 27 Feb 2008 02:43:32 +0000 (UTC)
From: Vincent Lefevre <vincent+news@vinc17.org>
Subject: Re: CPAN and man page installation
Message-Id: <20080227022630$50d6@prunille.vinc17.org>
In article <20080224012425$04b6@prunille.vinc17.org>,
Vincent Lefevre <vincent+news@vinc17.org> wrote:
> With the cpan utility, what configuration option need to be modified
> to install the man pages of modules at some place?
> Installation currently fails with the following error:
> mkdir /usr/local/man/man3: Permission denied at /usr/share/perl/5.8/ExtUtils/Install.pm line 112
> So, I need to tell cpan to install the man pages in ~/man/man1
> and ~/man/man3.
I've debugged this a bit. After the failure of Compress::Raw::Bzip2
installation, /home/vlefevre/.cpan/build/Compress-Raw-Bzip2-2.008/Makefile
contains:
INSTALLMAN1DIR = /home/vlefevre/man/man1
INSTALLMAN3DIR = /home/vlefevre/man/man3
as expected, but in fact, these variables are not taken into account,
probably because the Makefile also has:
INSTALLDIRS = site
DESTDIR =
PREFIX = /usr
PERLPREFIX = $(PREFIX)
SITEPREFIX = $(PREFIX)/local
The following is OK:
INSTALLSITELIB = /home/vlefevre/lib/site_perl
but why do I get the following values in the Makefile?
INSTALLSITEMAN1DIR = $(SITEPREFIX)/man/man1
INSTALLSITEMAN3DIR = $(SITEPREFIX)/man/man3
Then, the command
make install NOECHO=''
gives:
------------------------------------------------------------------------
/bin/sh -c true
/bin/sh -c true
/bin/sh -c true
/bin/sh -c true
/bin/sh -c true
/bin/sh -c true
/usr/bin/perl "-MExtUtils::Command::MM" -e pod2man "--" --section=3pm --perm_rw=644 \
lib/Compress/Raw/Bzip2.pm blib/man3/Compress::Raw::Bzip2.3pm
/bin/sh -c true
umask 02; /usr/bin/perl -MExtUtils::Install -e 'install({@ARGV}, '\''0'\'', 0, '\''0'\'');' \
read /usr/local/lib/perl/5.8.8/auto/Compress/Raw/Bzip2/.packlist \
write /home/vlefevre/lib/site_perl/x86_64-linux-gnu-thread-multi/auto/Compress/Raw/Bzip2/.packlist \
blib/lib /home/vlefevre/lib/site_perl \
blib/arch /home/vlefevre/lib/site_perl/x86_64-linux-gnu-thread-multi \
blib/bin /usr/local/bin \
blib/script /usr/local/bin \
blib/man1 /usr/local/man/man1 \
blib/man3 /usr/local/man/man3
mkdir /usr/local/man/man3: Permission denied at /usr/share/perl/5.8/ExtUtils/Install.pm line 112
make: *** [pure_site_install] Error 13
------------------------------------------------------------------------
If I add INSTALLDIRS=perl to makepl_arg in .cpan/CPAN/MyConfig.pm
(I recall I already had "LIB=~/lib/site_perl INSTALLMAN1DIR=~/man/man1
INSTALLMAN3DIR=~/man/man3"), then everything is OK. This is *really*
confusing and seems to be documented nowhere!
--
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)
------------------------------
Date: 26 Feb 2008 21:09:57 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: How to set file attributes
Message-Id: <Xns9A509A4714B0Ccastleamber@130.133.1.4>
Joost Diepenmaat <joost@zeekat.nl> wrote:
> What you want to do is prevent the file from being served to the
> web. One way to do that is to put it outside the publically accessible
> file tree(s). Another is to explicitly block it using whatever
> mechanism your webserver provides.
What might work (depending on your webserver config) is using a . in
front, e.g.
.counter.txt
*However* as others suggested, move it out of the document root (and chmod
your htdocs/www/web/whatever document root dir back to the value it had
before).
--
John
Arachnids near Coyolillo - part 1
http://johnbokma.com/mexit/2006/05/04/arachnids-coyolillo-1.html
------------------------------
Date: 26 Feb 2008 22:11:44 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: How to set file attributes
Message-Id: <slrnfs93kv.96i.abigail@alexandra.abigail.be>
_
John (John.Smith@invalid.com) wrote on VCCXCII September MCMXCIII in
<URL:news:38t8s3550b7tipdjlg66u2ddmv8683k15v@4ax.com>:
:} I have set up my own counter.pl on my web page.
:}
:} The counter saves the visitation count to a text file called "count.txt".
:} How do I create the file (and later open) with file attributes that prevent
:} others reading the file, ie. going to www.johnsmith.com/count.txt (the www here
:} is not real).
Wow, a webcounter. And someone trying to reinvent the wheel. How retro.
Let me guess, you're running perl4, right? On DOS.
Abigail
--
perl -wle 'eval {die ["Just another Perl Hacker"]}; print ${$@}[$#{@${@}}]'
------------------------------
Date: Wed, 27 Feb 2008 08:27:07 +0200
From: John <John.Smith@invalid.com>
Subject: Re: How to set file attributes
Message-Id: <v20as35s7rbbmbdfbt4ki3hcga22ue08uc@4ax.com>
Jim Gibson <jimsgibson@gmail.com> wrote:
>In article <38t8s3550b7tipdjlg66u2ddmv8683k15v@4ax.com>, John
><John.Smith@invalid.com> wrote:
>
>> I have set up my own counter.pl on my web page.
>>
>> The counter saves the visitation count to a text file called "count.txt".
>> How do I create the file (and later open) with file attributes that prevent
>> others reading the file, ie. going to www.johnsmith.com/count.txt (the www
>> here
>> is not real).
>
>It depends upon the operating system. Under Unix, you would create the
>file with an editor, the cat command, or the touch command (see 'man
>cat', etc.). File permissions are set with the chmod command. You want
>to set the file so that it is readable and writable only by the owner:
>
> chmod 0600 count.txt
>
>The problem is that for this to work, the file needs to be owned by the
>web server process, and that may not be your own user id. Some web
>servers use the user 'nobody', for example. As a result, you sometimes
>have to set data files to be world writable:
>
> chmod 0666 count.txt
>
>So it also depends upon your user id, the web server's id, and whether
>or not you have root privilege.
>
>If you do have root privilege, then you can set the owner of the file
>as well as the file permissions (as above):
>
> chown nobody:nobody count.txt
> chmod 0600 count.txt
>
>But this is for Unix, not necessarily other operating systems.
Thanks for input. The web counter files should be seen my me only (I download the
files every day).
Setting the files chmod 0600 count.txt seems to do what I want.
The perl script creates a num conter file for every day. How do I create the new
file so that it has 0600 attributes?
$txtfi=open (MYCOUNT,"<"."count.txt");
------------------------------
Date: Wed, 27 Feb 2008 05:42:17 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Wed Feb 27 2008
Message-Id: <JwvuIH.774@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Acme-Tiroler-0.03
http://search.cpan.org/~marcel/Acme-Tiroler-0.03/
write code like a tyrolean says it
----
Algorithm-EquivalenceSets-0.02
http://search.cpan.org/~marcel/Algorithm-EquivalenceSets-0.02/
Group sets transitively
----
Apache-Reload-0.10
http://search.cpan.org/~phred/Apache-Reload-0.10/
Reload changed modules
----
Apache2-ASP-1.34
http://search.cpan.org/~johnd/Apache2-ASP-1.34/
Perl extension for ASP on mod_perl2.
----
App-Addex-Plugin-Hiveminder-0.001
http://search.cpan.org/~rjbs/App-Addex-Plugin-Hiveminder-0.001/
automatically add "to Hiveminder.com" addrs
----
App-Booklist-v0.1
http://search.cpan.org/~genehack/App-Booklist-v0.1/
Track books you want to read, are reading, and have read
----
App-Context-0.966
http://search.cpan.org/~spadkins/App-Context-0.966/
An application framework for web applications, command-line programs, server programs, and web services
----
App-Options-1.04
http://search.cpan.org/~spadkins/App-Options-1.04/
Combine command line options, environment vars, and option file values (for program configuration)
----
App-Repository-0.966
http://search.cpan.org/~spadkins/App-Repository-0.966/
Logical data access layer for the App::Context Framework, providing a uniform API to access data in databases, file systems, remote web sites, etc.
----
App-Wack-0.04
http://search.cpan.org/~szabgab/App-Wack-0.04/
the actual code of wack the wisual ack
----
App-Widget-0.966
http://search.cpan.org/~spadkins/App-Widget-0.966/
Family of web user interface widgets for the App::Context Framework, enabling development of complex UI's in a CGI, mod_perl, or other web context
----
App-Widget-ChartDirector-0.966
http://search.cpan.org/~spadkins/App-Widget-ChartDirector-0.966/
Graphing widget which displays graphs and charts for web applications using the ChartDirector graphing library within the App-Context Framework
----
App-WorkQueue-0.966
http://search.cpan.org/~spadkins/App-WorkQueue-0.966/
----
BigIP-ParseConfig-1.1.4
http://search.cpan.org/~sschneid/BigIP-ParseConfig-1.1.4/
F5/BigIP configuration parser
----
Bundle-Thread-1.05
http://search.cpan.org/~jdhedden/Bundle-Thread-1.05/
A bundle of modules for supporting threads in Perl
----
Bundle-Thread-1.06
http://search.cpan.org/~jdhedden/Bundle-Thread-1.06/
A bundle of modules for supporting threads in Perl
----
CGI-Ex-2.24
http://search.cpan.org/~rhandom/CGI-Ex-2.24/
CGI utility suite - makes powerful application writing fun and easy
----
CGI-JSONRPC-0.10
http://search.cpan.org/~crakrjack/CGI-JSONRPC-0.10/
CGI handler for JSONRPC
----
Catalyst-Plugin-Assets-0.022
http://search.cpan.org/~rkrimen/Catalyst-Plugin-Assets-0.022/
Manage and minify .css and .js assets in a Catalyst application
----
Catalyst-View-vCard-0.03
http://search.cpan.org/~bricas/Catalyst-View-vCard-0.03/
vCard view for Catalyst
----
CatalystX-ListFramework-0.3
http://search.cpan.org/~snafufans/CatalystX-ListFramework-0.3/
foundations for displaying and editing lists (CRUD) in a Catalyst application
----
Config-LotusNotes-0.31
http://search.cpan.org/~albers/Config-LotusNotes-0.31/
Access Lotus Notes/Domino configuration
----
Convert-Morse-0.06
http://search.cpan.org/~tels/Convert-Morse-0.06/
Convert between ASCII text and MORSE alphabet
----
DBD-Pg-2.1.3_2
http://search.cpan.org/~turnstep/DBD-Pg-2.1.3_2/
PostgreSQL database driver for the DBI module
----
DBIx-Class-ResultSet-Data-Pageset-0.04
http://search.cpan.org/~bricas/DBIx-Class-ResultSet-Data-Pageset-0.04/
Get a Data::Pageset pager from a resultset
----
DBIx-Class-ResultSet-Data-Pageset-0.05
http://search.cpan.org/~bricas/DBIx-Class-ResultSet-Data-Pageset-0.05/
Get a Data::Pageset pager from a resultset
----
DBIx-NamedBinding-0.02
http://search.cpan.org/~ydna/DBIx-NamedBinding-0.02/
use named parameters instead of '?'
----
Data-Path-1.3.1
http://search.cpan.org/~zaphar/Data-Path-1.3.1/
Perl extension for XPath like accessing from complex data structs
----
Data-Path-1.4.1
http://search.cpan.org/~zaphar/Data-Path-1.4.1/
Perl extension for XPath like accessing from complex data structs
----
Data-Queue-Persistent-0.11
http://search.cpan.org/~revmischa/Data-Queue-Persistent-0.11/
Perisistent database-backed queue
----
Data-Queue-Persistent-0.12
http://search.cpan.org/~revmischa/Data-Queue-Persistent-0.12/
Perisistent database-backed queue
----
Data-Storage-0.06
http://search.cpan.org/~marcel/Data-Storage-0.06/
generic abstract storage mechanism
----
Egg-Release-3.02
http://search.cpan.org/~lushe/Egg-Release-3.02/
Version of Egg WEB Application Framework.
----
Egg-Release-3.03
http://search.cpan.org/~lushe/Egg-Release-3.03/
Version of Egg WEB Application Framework.
----
File-Log-1.04
http://search.cpan.org/~gng/File-Log-1.04/
A simple Object Orientated Logger
----
Finance-Bank-Cahoot-0.05
http://search.cpan.org/~masaccio/Finance-Bank-Cahoot-0.05/
Check your Cahoot bank accounts from Perl
----
Games-Ratings-0.0.1
http://search.cpan.org/~bartolin/Games-Ratings-0.0.1/
generic methods for rating calculation (e.g. chess ratings)
----
Hardware-Simulator-MIX-0.2
http://search.cpan.org/~litchie/Hardware-Simulator-MIX-0.2/
----
IO-LCDproc-0.035
http://search.cpan.org/~jcmuller/IO-LCDproc-0.035/
Perl extension to connect to an LCDproc ready display.
----
Lingua-RU-Jcuken-1.04
http://search.cpan.org/~stro/Lingua-RU-Jcuken-1.04/
Conversion between QWERTY and JCUKEN keys in Russian
----
Lingua-UK-Jcuken-1.04
http://search.cpan.org/~stro/Lingua-UK-Jcuken-1.04/
Conversion between QWERTY and JCUKEN keys in Ukrainian
----
Mail-POP3Client-2.18
http://search.cpan.org/~sdowd/Mail-POP3Client-2.18/
Perl 5 module to talk to a POP3 (RFC1939) server
----
Mail-SpamCannibal-0.91
http://search.cpan.org/~miker/Mail-SpamCannibal-0.91/
A tool to stop SPAM
----
Math-Random-MT-Auto-6.12
http://search.cpan.org/~jdhedden/Math-Random-MT-Auto-6.12/
Auto-seeded Mersenne Twister PRNGs
----
Net-OBEX-Packet-Headers-0.001
http://search.cpan.org/~zoffix/Net-OBEX-Packet-Headers-0.001/
construct and parse OBEX packet headers
----
Net-OBEX-Packet-Headers-0.002
http://search.cpan.org/~zoffix/Net-OBEX-Packet-Headers-0.002/
construct and parse OBEX packet headers
----
Net-Whois-Gateway-Client-0.04
http://search.cpan.org/~graykot/Net-Whois-Gateway-Client-0.04/
Interface to Net::Whois::Gateway::Server
----
Net-Whois-Gateway-Server-0.04
http://search.cpan.org/~graykot/Net-Whois-Gateway-Server-0.04/
whois gateway
----
Object-InsideOut-3.38
http://search.cpan.org/~jdhedden/Object-InsideOut-3.38/
Comprehensive inside-out object support module
----
POD2-Base-0.043
http://search.cpan.org/~ferreira/POD2-Base-0.043/
Base module for translations of Perl documentation
----
POE-Component-Client-Whois-Smart-0.08
http://search.cpan.org/~graykot/POE-Component-Client-Whois-Smart-0.08/
Provides very quick WHOIS queries with smart features.
----
POE-Component-IRC-Plugin-Bollocks-0.02
http://search.cpan.org/~bingos/POE-Component-IRC-Plugin-Bollocks-0.02/
A POE::Component::IRC plugin that talks bollocks.
----
POE-Component-Pluggable-1.02
http://search.cpan.org/~bingos/POE-Component-Pluggable-1.02/
A base class for creating plugin enabled POE Components.
----
POE-Component-Win32-EventLog-1.18
http://search.cpan.org/~bingos/POE-Component-Win32-EventLog-1.18/
A POE component that provides non-blocking access to Win32::EventLog.
----
POE-Component-Win32-Service-1.18
http://search.cpan.org/~bingos/POE-Component-Win32-Service-1.18/
A POE component that provides non-blocking access to Win32::Service.
----
Path-Classy-0.002_0
http://search.cpan.org/~ferreira/Path-Classy-0.002_0/
Augmented Path::Class (fancy stuff)
----
R-Writer-0.00001_01
http://search.cpan.org/~dmaki/R-Writer-0.00001_01/
Generate R Scripts From Perl
----
RPSL-Parser-0.28
http://search.cpan.org/~lmc/RPSL-Parser-0.28/
Router Policy Specification Language (RFC2622) Parser
----
Template-Provider-FromDATA-0.08
http://search.cpan.org/~bricas/Template-Provider-FromDATA-0.08/
Load templates from your __DATA__ section
----
Test-CompanionClasses-0.04
http://search.cpan.org/~marcel/Test-CompanionClasses-0.04/
basic invocation of Test::CompanionClasses::Engine
----
Test-Harness-3.10
http://search.cpan.org/~andya/Test-Harness-3.10/
Run Perl standard test scripts with statistics
----
Test-Parser-1.5.2
http://search.cpan.org/~markwkm/Test-Parser-1.5.2/
Base class for parsing log files from test runs, and displays in an XML syntax.
----
Test-Parser-1.5.3
http://search.cpan.org/~markwkm/Test-Parser-1.5.3/
Base class for parsing log files from test runs, and displays in an XML syntax.
----
Test-Parser-1.6
http://search.cpan.org/~markwkm/Test-Parser-1.6/
Base class for parsing log files from test runs, and displays in an XML syntax.
----
Test-Server-0.01
http://search.cpan.org/~jkutej/Test-Server-0.01/
what about test driven administration?
----
Text-SimpleVcard-0.03
http://search.cpan.org/~tomuschat/Text-SimpleVcard-0.03/
a package to manage a single vCard
----
Thread-Suspend-1.14
http://search.cpan.org/~jdhedden/Thread-Suspend-1.14/
Suspend and resume operations for threads
----
UDCode-1.00
http://search.cpan.org/~mjd/UDCode-1.00/
Does a set of code words form a uniquely decodable code?
----
UDCode-1.01
http://search.cpan.org/~mjd/UDCode-1.01/
Does a set of code words form a uniquely decodable code?
----
UDCode-1.02
http://search.cpan.org/~mjd/UDCode-1.02/
Does a set of code words form a uniquely decodable code?
----
UDCode-1.03
http://search.cpan.org/~mjd/UDCode-1.03/
Does a set of code words form a uniquely decodable code?
----
WWW-Google-Calculator-0.05
http://search.cpan.org/~typester/WWW-Google-Calculator-0.05/
Perl interface for Google calculator
----
WWW-Spyder-0.24
http://search.cpan.org/~ashley/WWW-Spyder-0.24/
a simple non-persistent web crawler.
----
WordPress-XMLRPC-1.09
http://search.cpan.org/~leocharre/WordPress-XMLRPC-1.09/
----
XML-Rules-1.01
http://search.cpan.org/~jenda/XML-Rules-1.01/
parse XML & process tags by rules starting from leaves
----
iPod-Squish-0.01
http://search.cpan.org/~nuffin/iPod-Squish-0.01/
Convert songs on an iPod in place using FFmpeg::Command.
----
threads-shared-1.18
http://search.cpan.org/~jdhedden/threads-shared-1.18/
Perl extension for sharing data structures between threads
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Wed, 27 Feb 2008 01:11:01 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: uc() and utf8
Message-Id: <slrnfs9akm.pfr.hjp-usenet2@hrunkner.hjp.at>
On 2008-02-26 13:50, Petr Vileta <stoupa@practisoft.cz> wrote:
> Ben Morrow wrote:
>> Quoth Alex <check.sig@for.email.invalid>:
>>>> # string in cp1250 codepage
>>>> my $wintxt="\xec\x9a\xe8\xf8\x9e\xfd\xe1\xed\xe9";
>>>>
>>>> # convert to utf8
>>>> my $utftxt=convert('CP1250','UTF8',$wintxt);
>>
>> my $txt = decode CP1250 => $wintxt;
>>
>>>> print "<br>Win: $wintxt, ",uc($wintxt),"<br>utf8:$utftxt,
>>>> ",uc($utftxt),"\n";
>>
>> You can't 'uc' $wintxt: it is a binary string, not a character string,
>> so the operation is fairly meaningless (the fact perl will actually do
>> something fairly sensible is not a reason to rely on that). If you
>> *really* want mixed CP1250/UTF8 output, you need to do something like
>>
> Thank you for response.
> My data source is in cp1250 so I *really* need to use this codepage. I want to
> read data (in cp1250),
What "data source" is this? If it's a file, you can can do the
conversion in an I/O layer. If it's a database, the DBD driver may be
able to do the conversion.
> convert it *as is* to utf8 and now use uc() or lc(). Mean you this
> code will work properly?
>
> use strict;
> use utf8;
> use Encode qw/encode decode/;
>
> # string in cp1250 codepage
> my $wintxt="\xec\x9a\xe8\xf8\x9e\xfd\xe1\xed\xe9";
> # convert to utf8
> my $utftxt = Encode::decode( 'CP1250', $wintxt );
Decode converts to a "character string". This happens to be represented
in UTF-8 internally (which is unfortunately visiible in many function
names), but don't think of it that way.
> print "<br>utf8:$utftxt, " uppercase utf8: ", uc($utftxt), "\n";
For the output, you need to encode the strings. (You can only send bytes
over a socket, not characters). You can do this explicitely:
print encode('utf-8', "<br>utf8:$utftxt, " uppercase utf8: " . uc($utftxt) . "\n");
or let the perl I/O system do it implicitely:
binmode STDOUT, ":utf8";
Needless to say I find the latter much simpler and less error-prone.
hp
------------------------------
Date: Wed, 27 Feb 2008 01:52:56 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: uc() and utf8
Message-Id: <ocse95-5rj.ln1@osiris.mauzo.dyndns.org>
Quoth "Petr Vileta" <stoupa@practisoft.cz>:
> Ben Morrow wrote:
> > Quoth Alex <check.sig@for.email.invalid>:
> >
> > my $txt = decode CP1250 => $wintxt;
> >
> >>> print "<br>Win: $wintxt, ",uc($wintxt),"<br>utf8:$utftxt,
> >>> ",uc($utftxt),"\n";
> >
> > You can't 'uc' $wintxt: it is a binary string, not a character string,
> > so the operation is fairly meaningless (the fact perl will actually do
> > something fairly sensible is not a reason to rely on that). If you
> > *really* want mixed CP1250/UTF8 output, you need to do something like
>
> My data source is in cp1250 so I *really* need to use this codepage.
You data source (input) and your output do not need to be in the same
encoding.
> I want to read data (in cp1250), convert it *as is* to utf8 and now
> use uc() or lc().
No, that is meaningless. uc and lc work on characters, not on
UTF8-encoded bytes strings. So you want to
1. ead in binary data (make sure you use binmode on your
filehandles, btw),
2. convert that binary data into characters, using the CP1250
encoding (Encode::decode),
3. uc or lc those characters,
4. convert them back into binary data, using any encoding of your
choice (Encode::encode),
5. write that data out to a filehandle (again, make sure you use
binmode).
> Mean you this code will work properly?
>
> use strict;
> use utf8;
> use Encode qw/encode decode/;
>
> # string in cp1250 codepage
> my $wintxt="\xec\x9a\xe8\xf8\x9e\xfd\xe1\xed\xe9";
> # convert to utf8
> my $utftxt = Encode::decode( 'CP1250', $wintxt );
This far is good.
> print "<br>utf8:$utftxt, " uppercase utf8: ", uc($utftxt), "\n";
No, you've missed a step: read the code I posted again. You can't just
print character data to a filehandle: you'll get 'Wide character in
print' warnings, and you'll get output in perl's internal data format,
which is an incomprehensible mixture of ISO8859-1 and UTF8. You hace to
convert the characters back into bytes, using any encoding of your
choice.
Ben
------------------------------
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 V11 Issue 1312
***************************************