[18001] in Perl-Users-Digest
Perl-Users Digest, Issue: 161 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 28 14:05:39 2001
Date: Sun, 28 Jan 2001 11:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <980708709-v10-i161@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 28 Jan 2001 Volume: 10 Number: 161
Today's topics:
[Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
Re: bundle Perl or use C? <bowman@montana.com>
Re: Comparing multiple values datastar@my-deja.com
Re: Comparing multiple values <jdf@pobox.com>
Creating calendar (reminder) class <marc.beck@bigfoot.com>
Re: Finding a char in string (Mark Jason Dominus)
Re: Finding a char in string <godzilla@stomp.stomp.tokyo>
Re: Finding a char in string <bart.lateur@skynet.be>
How to pass $vars to a script from within another scrip <creafin1998@yahoo.com>
Re: How to pass $vars to a script from within another s <tinamue@zedat.fu-berlin.de>
Re: Limits on array and hash storage <jpl@research.att.com>
maintaining Session with Apache <harilaos@ntlworld.com>
mod_perl Perl: <a565a87@my-deja.com>
Re: Mysterious inconsistent script behavior gnari@my-deja.com
Re: perl editors <nospam.newton@gmx.li>
Re: PROBLEM with SPRITE.PM gnari@my-deja.com
socket handle reading gclemmons@my-deja.com
Re: socket handle reading <jdf@pobox.com>
Re: socket handle reading gclemmons@my-deja.com
Re: String functions? (Mark Jason Dominus)
Re: String functions? <godzilla@stomp.stomp.tokyo>
Re: Text:CSV can't handle german characters <marc.beck@bigfoot.com>
Re: Text:CSV can't handle german characters <marc.beck@bigfoot.com>
Re: Text:CSV can't handle german characters tigra@sky.deep.ru
Re: Text:CSV can't handle german characters <monty@primenet.com>
Re: Text:CSV can't handle german characters <marc.beck@bigfoot.com>
Re: Text:CSV can't handle german characters <marc.beck@bigfoot.com>
The Best News Publishing Perl Script (Energy)
The Best News Publishing Perl Script (Energy)
The Best News Publishing script (Energy)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 28 Jan 2001 11:20:45 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage980681041.3574@news.teleport.com>
Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 29 Apr 2000
[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last _major_ update of the Perl FAQ was in Summer
of 1998; of course, ongoing updates are made as needed. ]
For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).
http://www.cpan.org/doc/FAQs/
Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.
For an alternative way to get answers, check out the Perlfaq website.
http://www.perlfaq.com/
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.
perldoc perlfaq
man perlfaq
If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.
If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.
http://www.cpan.org/
http://www.perl.com/CPAN/
http://www.cpan.org/doc/FAQs/FAQ/html/
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/
You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)
California ftp://ftp.cdrom.com/pub/perl/CPAN/
Texas ftp://ftp.metronet.com/pub/perl/
South Africa ftp://ftp.is.co.za/programming/perl/CPAN/
Japan ftp://ftp.dti.ad.jp/pub/lang/CPAN/
Australia ftp://cpan.topend.com.au/pub/CPAN/
Netherlands ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
Switzerland ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
Chile ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/
If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.
Have fun with Perl!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 28 Jan 2001 09:37:15 -0700
From: "bowman" <bowman@montana.com>
Subject: Re: bundle Perl or use C?
Message-Id: <8jYc6.4373$Uo2.15053@newsfeed.slurp.net>
Thomas Brusca <tebrusca@oakland.edu> wrote in message
news:94vd1s$l1c$1@news2.acs.oakland.edu...
>
> Do you think bundling Perl will be as difficult as maintaining
> the C binary of the POST program?
Short answer: depending on the existence of a third party package on a wide
range of *nix systems will probably prove to be a bigger hassle than just
distributing a clean, POSIX compliant C binary. Even with C, you have your
work cut out for you. There is a reason *nix apps are usually built from
source on the target platform.
Now, if you could depend on a not too obsolete Perl on the clients'
machines, or friendly sysadmins ready and willing to install Perl, working
in Perl would be easier.
Supporting anything on "all flavors of Unix" without distibuting source will
make Windows look really good....
------------------------------
Date: Sun, 28 Jan 2001 15:14:26 GMT
From: datastar@my-deja.com
Subject: Re: Comparing multiple values
Message-Id: <951d0f$q8s$1@nnrp1.deja.com>
This certainly has this been enlightening! Thanks to all of you for
your ideas!
I suppose the answer to my question is no, there isn't a really simple
solution, (with the exception of the "any()" solution, but I wonder
about the overhead involved with Quantum:Superpositions -- any
thoughts?).
I like the hash approach, as it can be applied to string values as well
as numerics. I know RE's are second nature to many of you, but as an
"occasional" Perl user, I find them prone to careless errors (and
those based on my limited understanding of when to use |'s, ('s, ['s,
$'s, ^'s, etc!!!).
Thanks again to all!
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 28 Jan 2001 11:33:23 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Comparing multiple values
Message-Id: <wvbfbprg.fsf@pobox.com>
datastar@my-deja.com writes:
> I know RE's are second nature to many of you, but as an "occasional"
> Perl user, I find them prone to careless errors (and those based on
> my limited understanding of when to use |'s, ('s, ['s, $'s, ^'s,
> etc!!!).
Whatever practice you put into regular expressions will be richly
rewarded. If you haven't already done so, look with some care at
Chapter 7 of "Learning Perl". Also, see the book "Mastering Regular
Expressions".
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Sun, 28 Jan 2001 19:00:50 +0100
From: "Marc Beck" <marc.beck@bigfoot.com>
Subject: Creating calendar (reminder) class
Message-Id: <951mog$evfud$1@ID-23826.news.dfncis.de>
Hello,
I would like to create a class that acts as a reminder. To create a
reminder instance you just pass the time and a reference to a sub that
should be executed.
For example:
my $reminder = MYPM::reminder->new();
$reminder->AddReminder({ 'time' => '12:00:00',
'msg' => 'lunch',
'sub' => \&alarm}
);
$reminder->AddReminder({ 'time' => '17:00:00',
'msg' => 'dinner',
'sub' => \&alarm}
);
$reminder->start;
sub alarm()
{
print shift;
}
I couldn't figure out how to manage it so the AddReminder methods
return immidiately but still call &alarm at the specified time.
Any hints for me?
cu Marc
------------------------------
Date: Sun, 28 Jan 2001 11:37:56 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Finding a char in string
Message-Id: <3a740493.247$fb@news.op.net>
My earlier benchmark was in error. I was benchmarking
substr($s, index($s, ';')-1);
instead of
substr($s, 0, index($s, ';')-1);
The conclusion of my article is the same however. An amended version
follows. My apologies for any confusion.
In article <3A735C21.4F6C6B9B@stomp.stomp.tokyo>,
Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
>A substring method for this case example is significantly
>faster,
That does not appear to be true.
Here is the result of the attached benchmark with the test string:
$S = ' ; ' . ('x' x 20000);
SUBSTR: 4.15 0 = 4.15
REGEX: 4.32 0 = 4.32
LOOP: 3.95 0.01 = 3.96
Here the substr version is about 46% faster.
Here is the result with the test string:
$S = ('x' x 20000) . ' ; ';
SUBSTR: 22.5 0 = 22.5
REGEX: 14.86 0 = 14.86
LOOP: 3.63 0 = 3.63
But here the regex is about 41% faster.
However, the regex was faster for the slower case.
> uses an equally significant lesser amount of memory
I doubt this.
>and, clearly, is not prone to inherent regex errors, most
>often caused by human hand.
The substr version is four times as long.
>and, clearly, is not prone to inherent regex errors, most
>often caused by human hand.
The substr version is four times as long.
----------------------------------------------------------------
Here is the corrected benchmark file.
$S = ('x' x 20000) . ' ; ';
# $S = ' ; ' . ('x' x 20000);
# $S = ' ; ';
$N = 10000;
$i = $N;
($su, $ss) = times();
while () {
$s = $S;
$s = substr($s, 0, index($s, ';')-1);
last unless --$i;
}
($eu, $es) = times();
($tu, $ts) = ($eu-$su, $es-$ss);
print "SUBSTR: $tu $ts = ", $tu+$ts, "\n";
$i = $N;
($su, $ss) = times();
while () {
$s = $S;
$s =~ s/;.*//s;
last unless --$i;
}
($eu, $es) = times();
($tu, $ts) = ($eu-$su, $es-$ss);
print "REGEX: $tu $ts = ", $tu+$ts, "\n";
$i = $N;
($su, $ss) = times();
while () {
$s = $S;
last unless --$i;
}
($eu, $es) = times();
($tu, $ts) = ($eu-$su, $es-$ss);
print "LOOP: $tu $ts = ", $tu+$ts, "\n";
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Sun, 28 Jan 2001 08:07:33 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Finding a char in string
Message-Id: <3A7443C5.43E1EA11@stomp.stomp.tokyo>
Mark Jason Dominus wrote:
(some repairs of his upside down quoting)
(original author wrote:)
> Godzilla! wrote:
(others wrote:)
(majority of article is missing)
> >A substring method for this case example is significantly
> >faster,
> That does not appear to be true.
> My earlier benchmark was in error. I was benchmarking
> substr($s, index($s, ';')-1);
> instead of
> substr($s, 0, index($s, ';')-1);
> The conclusion of my article is the same however. An amended version
> follows. My apologies for any confusion.
(snipped biased unrelated code)
My benchmark results made prior to posting
my initial article directly contradict your
own results. Fortunately, I am careful enough
to attain correct results based on unbiased
data under strict controls, from the get go.
Godzilla!
------------------------------
Date: Sun, 28 Jan 2001 17:52:45 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Finding a char in string
Message-Id: <72n87tg0er7kvj8cnkvnpg86vgtkfa7j9p@4ax.com>
Henrik Thostrup Jensen wrote:
>I've need to find a certain char (";") in a string and remove all that
>is after the char. The only way i've been able to do this so far is by
>making the string into an array, searching through the array for the
>char and thereafter splitting the string at the char location.
>
>There have to be an easier way
Sure there is.
s/;.*/;/s;
Make this
s/;.*//s;
if you want to remove the semicolon as well. Oh, and this will delete
every newline too, but only if a semicolon was found.
--
Bart.
------------------------------
Date: Sun, 28 Jan 2001 15:59:22 GMT
From: "creafin1998" <creafin1998@yahoo.com>
Subject: How to pass $vars to a script from within another script and e-mail results to a group.
Message-Id: <01c08943$ae02b100$48c249d8@rjuliano>
I need to pass variables to a script from within another script, then
e-mail the results to a group. I was hoping something like this would
work:
# $value is taken from a separate flat text file.
$prog = '/path/script.pl?var=$value';
$group = 'user1\@dot.com user2\@dot.com user3\@dot.com';
`$prog | mail $group`;
It doesn't work. It seems to tell me that it cannot find the script.
However, when I remove the ?var=$value it at least finds the script and
performs the e-mail function.
Thanks in advance.
------------------------------
Date: 28 Jan 2001 17:35:40 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: How to pass $vars to a script from within another script and e-mail results to a group.
Message-Id: <951l9c$fbks2$3@fu-berlin.de>
hi,
creafin1998 <creafin1998@yahoo.com> wrote:
> I need to pass variables to a script from within another script, then
> e-mail the results to a group. I was hoping something like this would
> work:
> # $value is taken from a separate flat text file.
> $prog = '/path/script.pl?var=$value';
^^^^^^^^^^^
this is for CGI. so the script is a cgi-skript,
i guess.
> $group = 'user1\@dot.com user2\@dot.com user3\@dot.com';
> `$prog | mail $group`;
you are trying to execute a CGI script at commandline.
the script expects the parameters to be in
$ENV{'QUERY_STRING'} or in STDIN.
if you want to execute a script on commandline, you can type
script.pl param1 param2 ...
the shell will not find the programm called "script.pl?var=value".
it doesn't exist.
read the parameters with @ARGV
perldoc perlvar
or use lwp
perldoc lwpcook
hth,
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
please don't email unless offtopic or followup is set. thanx
------------------------------
Date: Sun, 28 Jan 2001 17:38:11 GMT
From: "John P. Linderman" <jpl@research.att.com>
Subject: Re: Limits on array and hash storage
Message-Id: <3A745903.4F5E3983@research.att.com>
nobull@mail.com wrote:
> William Cardwell <EUSWMCL@am1.ericsson.se> writes:
>
> > I notice that large arrays and hashes are commonly used in Perl. I do
> > the same and have not yet hit limits. Am I really using only ram?
>
> We can only really guess, but it seems unlikely to me that you are
> using an operating system that doesn't have some sort of virtual memory
> mecahnism in use.
>
> This doesn't really have anything to do with Perl.
It may have something to do with the *performance* of Perl.
But it's not something that can be answered without knowing
a lot more about what ``large'' means, and the architecture
of the system being used. Caches, main memory, their sizes
and relative speed can introduce ``limits'' even before you
have to start worrying about swapping. If Perl is ``fast enough''
for the job at hand, chances are excellent that what you want
to optimize is development time, maintainability, and the joy
of programming, for all of which Perl shines. -- jpl
------------------------------
Date: Sun, 28 Jan 2001 11:56:21 +0000
From: harilaos <harilaos@ntlworld.com>
Subject: maintaining Session with Apache
Message-Id: <3A7408E5.CE2D8FFF@ntlworld.com>
Hello,
i was wondering if anyone could help me.
I want to maintain sessions across several perl scripts and
i thought a good way was to modify the .htacess file and input
a user name and password. Then i could pass this information to apache
to authenticate. By doing this i could have the global variable
REMOTE_USER for that users session without having to pass it
though the url, cookies of hidden fields.
My question: Is there a way to pass authentication information
to apache without the login window popping up?
Thanks
------------------------------
Date: Sun, 28 Jan 2001 18:06:20 GMT
From: Rob <a565a87@my-deja.com>
Subject: mod_perl Perl:
Message-Id: <951n2o$2dt$1@nnrp1.deja.com>
I'm a real neophyte at Perl, and I got involved in it because I want to
experiment with Apache against OLE.
Please correct my if I'm wrong (and I'm paraphrasing wildly here):
1. It is my understanding that mod_perl lends a complete, native Perl
API to Apache, making Apache higher performance than if conventional
CGI scripting is used. Is this the case?
2. Does mod_perl really in fact simply encapsulate whatever existing
installation of perl that I have on my machine. E.g., if what I
currently use for perl is CPAN 5.6.0, does my mod_perl .DLL build just
take that CPAN 5.6.0 installation that currently suffices for my perl
environment and make that available, in-process, to Apache? (Or is my
mod_perl build some kind of a completely separate perl from that of my
preexisting 5.6.0? It's a really stupid question, but I just wanted
some kind of confirmation.)
Thanks for any information that you all can provide.
-Rob
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Sun, 28 Jan 2001 11:23:34 GMT
From: gnari@my-deja.com
Subject: Re: Mysterious inconsistent script behavior
Message-Id: <950vfj$h9k$1@nnrp1.deja.com>
In article <20010128015900.08409.00000790@ng-cg1.aol.com>,
jcdixon@aol.com (JCDixon) wrote:
> I have a script that works_almost_all the time. It is a relatively
> minor revision of a pretty large CGI script that has been running
> trouble-free for several months.
your question is not really appropriate in this newsgroup, and
probably would get better answers in one of the cgi groups,
but here goes:
did you do a diff between this revision and the old one?
after 'minor' changes, diff is wonderful to make clear exactly
what was done.
> The web hosting company says the server logs identify the error
> as "premature end of script headers." No additional information
> is available in the log.
>
this sounds like debugging output being issued to STDOUT before
the headers are generated
> Here's what I've already eliminated as possible causes:
>
> 1. Content-type: text/HTML\n\n. Yup, it's in there. And I can find
> no logical
> path that would keep it from being returned to the client.
>
look for something happening before that
> Other than that, I'm out of ideas.
you should arrange to have access to the webserver error logs, and
generate debugging output to STDERR.
good luck
gnari
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Sun, 28 Jan 2001 19:14:26 +0100
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.li>
Subject: Re: perl editors
Message-Id: <pao87tg9a40eupj2mgalsq0br202qaof34@4ax.com>
On Thu, 25 Jan 2001 09:21:05 -0600, "Phil R Lawrence" <prlawrence@lehigh.edu>
wrote:
> "hanja" <hanja@my-deja.com> wrote:
> > Out of curiousity, what editor do you use to write your scripts?
> TextPad
TextPad on Win32. vim on Unix.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Sun, 28 Jan 2001 12:10:11 GMT
From: gnari@my-deja.com
Subject: Re: PROBLEM with SPRITE.PM
Message-Id: <951274$j3o$1@nnrp1.deja.com>
In article <94uthp$1q$1@nnrp1.deja.com>,
aminl@my-deja.com wrote:
> Hello,
>
> I have set up SPRITE.PM (version 3.21) to read data from a flat file
> delimited by "::" .... I run a "for" loop to print out data retrieved
> from the select statement.
>
> foreach $record (@data)
> {
> print $record<BR>";
> }
>
> However I only get [ARRAY(0x81636bc)] outputted
this means that $record is a reference to an array, but not a string.
see perldoc perlref
you could do
print $record->[0]."<BR>";
to print the first element of each.
of course, that might not be a scalar either.
gnari
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Sun, 28 Jan 2001 15:35:07 GMT
From: gclemmons@my-deja.com
Subject: socket handle reading
Message-Id: <951e7b$r6f$1@nnrp1.deja.com>
I've been working on a server application using
IO::Socket and IO::Select for the socket handle
looping.
If I setup a generic IO::Socket::INET on a
localhost/port and use
IO::Select->select($readable_handles, undef, undef, 1)
to build the array ref that I loop through to
test a handle's read availability and then
my $buf = <$my_socket_file_handle>;
inside the loop after they are connected it behaves
the way I would expect. It has been told by the Select
that something is in the buffer to be read and it
grabs the top 'line' from said buffer.
This works fine for one-line-at-a-time sends but
when someone sends multiple lines at a time it
only reads the first and waits until the next send
to read the rest.
Naturally, if I try to run a while loop on the read
it sits happily reading until the user disconnects,
but since I need to interact with multiple users at
once it sort of defeats the point of the entire server.
I have a couple of questions on this:
Why will it only read the first line on the initial
send but then all of the remaining lines on the next?
Is there some kind of 'end of stream' delimiter?
and
Is there a way to read until the end of the actual send
rather than the end of the first line?
I'm leaving out most of the code I'm using because
it is just a standard Perl IO::Socket multi-user
loop. If more info is needed please let me know.
Thank you.
-g
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 28 Jan 2001 11:43:11 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: socket handle reading
Message-Id: <snm3bpb4.fsf@pobox.com>
gclemmons@my-deja.com writes:
> I've been working on a server application using IO::Socket and
> IO::Select for the socket handle looping.
I recently wrote such a thing using the sample code given in "The Perl
Cookbook" as its foundation. I suggest you look there for a more
robust technique than using the <> operator which suffers from the
deficiencies you outline in your original post. The code is available
online at
ftp://ftp.oreilly.com/published/oreilly/perl/cookbook/
The code you want is in chapter 17, and is called "nonforker".
The basic idea is that you read a fixed number of bytes at a time into
a buffer that you maintain for each client. HTH.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Sun, 28 Jan 2001 17:24:11 GMT
From: gclemmons@my-deja.com
Subject: Re: socket handle reading
Message-Id: <951kjj$87$1@nnrp1.deja.com>
Ahh, brilliant!
A buffer for the buffer eh? Thank you very much for the help.
It's much appreciated.
-g
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Sun, 28 Jan 2001 11:03:40 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: String functions?
Message-Id: <3a73fc8a.170$1e1@news.op.net>
In article <950tl9$8rs$1@news.kolumbus.fi>, Dan <kkk@elrancho.com> wrote:
>No... Still wondering how to get the length of the string ;)
You use the 'length' function.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Sun, 28 Jan 2001 09:22:40 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: String functions?
Message-Id: <3A745560.81802AA3@stomp.stomp.tokyo>
Dan wrote:
(snipped)
> How do I store the first three characters of
> a string into another string? And how can I get
> the length of a string?
Finding the length of a string is quite
simple using length () function. Grabbing
the first n (any number) characters of
a string is equally easy with substring.
You will find good documentation on these
functions in your reference material or
in online reference sites.
Look over my simple test script below
my signature.
Godzilla!
--
TEST SCRIPT:
____________
#!perl
print "Content-type: text/plain\n\n";
$string ="123456789";
$length = length ($string);
print "Length Of String:\n\n $length";
$new_string = substr ($string, 0, 3);
print "\n\nNew String:\n\n $new_string";
exit;
PRINTED RESULTS:
________________
Length Of String:
9
New String:
123
------------------------------
Date: Sun, 28 Jan 2001 17:02:10 +0100
From: "Marc Beck" <marc.beck@bigfoot.com>
Subject: Re: Text:CSV can't handle german characters
Message-Id: <951fq0$fcsv8$1@ID-23826.news.dfncis.de>
> > I just integrated the Text::CSV::parse method into my Script to
convert
> > a CSV to a SQL-Table.
> >
> > The Problem with this module is that it won't handle any strings
> > containing ä, ö, ü or any other special german characters.
> > How can the CSV module have to be modified so it will work?
>
> It's been done. Use Text::CSV_XS instead.
>
<--- quote from perldoc Text::CSV_XS
1 Allowable characters within a CSV field include 0x09
(tab) and the inclusive range of 0x20 (space) through
0x7E (tilde). In binary mode all characters are
accepted, at least in quoted fields:
--->
I can't see where ä, ö, or ü are included in this range!
I think I'll have to modify my script so these special characters
won't appear in my csv.
cu Ralf
------------------------------
Date: Sun, 28 Jan 2001 17:22:50 +0100
From: "Marc Beck" <marc.beck@bigfoot.com>
Subject: Re: Text:CSV can't handle german characters
Message-Id: <951h0s$fbapk$1@ID-23826.news.dfncis.de>
> I think I'll have to modify my script so these special characters
> won't appear in my csv.
>
I tried several times to find a suitable regex that converts ä to ae,
ü to ue etc ...
Using seperate regex for each character works fine but I'm not far
enough into regexs to find a single line expression. Any hints?
How can I get the right decimal 8bit code for these characters?
man iso*?
------------------------------
Date: Sun, 28 Jan 2001 17:35:51 GMT
From: tigra@sky.deep.ru
Subject: Re: Text:CSV can't handle german characters
Message-Id: <951l9n$pj$1@nnrp1.deja.com>
In article <951h0s$fbapk$1@ID-23826.news.dfncis.de>,
"Marc Beck" <marc.beck@bigfoot.com> wrote:
> > I think I'll have to modify my script so these special characters
> > won't appear in my csv.
> >
> I tried several times to find a suitable regex that converts ä to ae,
> ü to ue etc ...
> Using seperate regex for each character works fine but I'm not far
> enough into regexs to find a single line expression. Any hints?
Something like this should help:
my %oddies = (
'ü' => 'ue',
'ä' => 'ae',
...
);
s/([üä])/$oddies{$1}/ge;
> How can I get the right decimal 8bit code for these characters?
> man iso*?
Hmm. BTW, what do you really want do do with these strings after putting
them into DB?
Sergey
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 28 Jan 2001 18:24:31 GMT
From: Jim Monty <monty@primenet.com>
Subject: Re: Text:CSV can't handle german characters
Message-Id: <951o4v$42o$2@nnrp1.phx.gblx.net>
Marc Beck <marc.beck@bigfoot.com> wrote:
> > > I just integrated the Text::CSV::parse method into my Script to
> > > convert a CSV to a SQL-Table.
> > >
> > > The Problem with this module is that it won't handle any strings
> > > containing ä, ö, ü or any other special german characters.
> > > How can the CSV module have to be modified so it will work?
> >
> > It's been done. Use Text::CSV_XS instead.
> >
> <--- quote from perldoc Text::CSV_XS
> 1 Allowable characters within a CSV field include 0x09
> (tab) and the inclusive range of 0x20 (space) through
> 0x7E (tilde). In binary mode all characters are
> accepted, at least in quoted fields:
> --->
> I can't see where ä, ö, or ü are included in this range!
They're included in the range specified as "all characters" in the
excerpt above. Use binary mode.
> I think I'll have to modify my script so these special characters
> won't appear in my csv.
Check perlfaq4 before you go to that much trouble to avoid a
non-problem:
How can I split a [character] delimited string except when inside
[character]? (Comma-separated files)
If, for whatever reason, Text::CSV_XS doesn't work for your data,
there are still ways to parse CSV text without having to munge
eight-bit characters. But Text::CSV_XS should work. Did you try it?
--
Jim Monty
monty@primenet.com
Tempe, Arizona USA
------------------------------
Date: Sun, 28 Jan 2001 19:48:45 +0100
From: "Marc Beck" <marc.beck@bigfoot.com>
Subject: Re: Text:CSV can't handle german characters
Message-Id: <951pia$fk82h$1@ID-23826.news.dfncis.de>
> > I tried several times to find a suitable regex that converts ä to
ae,
> > ü to ue etc ...
> > Using seperate regex for each character works fine but I'm not far
> > enough into regexs to find a single line expression. Any hints?
>
> Something like this should help:
>
> my %oddies = (
> 'ü' => 'ue',
> 'ä' => 'ae',
> ...
> );
>
> s/([üä])/$oddies{$1}/ge;
>
Looks good ... thx!
> > How can I get the right decimal 8bit code for these characters?
> > man iso*?
>
> Hmm. BTW, what do you really want do do with these strings after
putting
> them into DB?
>
The CSV file is generated by Outlook 2000 containing the calendar
entries.
I upload it via a perl-script to my sql-database.
I then run a perl script via cron that queries the database for
today's
appointments and then reminds me via SMS on my mobile.
You would say: Why isn't he using DBD::CSV?
Just because I want to use MySQL :)
------------------------------
Date: Sun, 28 Jan 2001 19:52:47 +0100
From: "Marc Beck" <marc.beck@bigfoot.com>
Subject: Re: Text:CSV can't handle german characters
Message-Id: <951ppr$fjkpl$1@ID-23826.news.dfncis.de>
> If, for whatever reason, Text::CSV_XS doesn't work for your data,
> there are still ways to parse CSV text without having to munge
> eight-bit characters. But Text::CSV_XS should work. Did you try it?
>
I tried it but didn't use binary mode.
I'll try it ... please stand-by .... ok, thanks. it now works in
binary mode.
cu Marc
------------------------------
Date: Thu, 25 Jan 2001 02:58:41 GMT
From: ed_energy@hotmail.com (Energy)
Subject: The Best News Publishing Perl Script
Message-Id: <3a709614.49866524@news.telepac.pt>
Hello all,
(please sorry for my bad english)
What's the best script for news publishing? (free or commercial)
We need a powerfull script to do that. We need a script with the
following fectures:
- Put fotos (one or two) on the article
- support for multiple colaborators
- search engine
- archive articles
- multiple categories
- possibility to comment the articles
A script like this exists out there?
thank you for your help on this,
Pipin
------------------------------
Date: Thu, 25 Jan 2001 03:00:30 GMT
From: ed_energy@hotmail.com (Energy)
Subject: The Best News Publishing Perl Script
Message-Id: <3a7196b4.50026564@news.telepac.pt>
Hello all,
(please sorry for my bad english)
What's the best script for news publishing? (free or commercial)
We need a powerfull script to do that. We need a script with the
following fectures:
- Put fotos (one or two) on the article
- support for multiple colaborators
- search engine
- archive articles
- multiple categories
- possibility to comment the articles
A script like this exists out there?
thank you for your help on this,
Pipin
------------------------------
Date: Thu, 25 Jan 2001 02:51:04 GMT
From: ed_energy@hotmail.com (Energy)
Subject: The Best News Publishing script
Message-Id: <3a6f9463.49433291@news.telepac.pt>
Hello all,
(please sorry for my bad english)
What's the best script for news publishing?
We need a powerfull script to do that. We need a script with the
following fectures:
- Put fotos (one or two) on the article
- support for multiple colaborators
- search engine
- archive articles
- multiple categories
- possibility to comment the articles
A script like this exists?
thank you for your help on this,
Pipin
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 161
**************************************