[23318] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5538 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 21 18:10:44 2003

Date: Sun, 21 Sep 2003 15:10:14 -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           Sun, 21 Sep 2003     Volume: 10 Number: 5538

Today's topics:
        some stupid questions about string search & replace in  <mizhael@yahoo.com>
    Re: some stupid questions about string search & replace <pinyaj@rpi.edu>
    Re: some stupid questions about string search & replace <spam@thecouch.homeip.net>
    Re: some stupid questions about string search & replace <tom@nosleep.net>
    Re: some stupid questions about string search & replace <mizhael@yahoo.com>
    Re: some stupid questions about string search & replace <mizhael@yahoo.com>
    Re: some stupid questions about string search & replace <krahnj@acm.org>
        SOS! how to do conditional search & replacement of stri <mizhael@yahoo.com>
    Re: SOS! how to do conditional search & replacement of  <krahnj@acm.org>
    Re: SOS! how to do conditional search & replacement of  <noreply@gunnar.cc>
    Re: SOS! how to search & replace some string to numbers <bwaNOlton@rochSPester.rAMr.com>
    Re: SOS! how to search & replace some string to numbers <bwaNOlSPtAMon@rochester.rr.com>
    Re: SOS! how to search & replace some string to numbers <krahnj@acm.org>
    Re: This probably aint the right place  . . . but there <max@alcyone.com>
        This probably aint the right place  . . . but there's n <nemail@hotmail.com>
    Re: This probably aint the right place  . . . but there <mbudash@sonic.net>
    Re: This probably aint the right place  . . . but there <mbudash@sonic.net>
    Re: This probably aint the right place  . . . but there <wpmccormick@hotmail.com>
    Re: troubles with unicode (incorrect sorting and basic  <pilsl_usenet@goldfisch.at>
    Re: troubles with unicode (incorrect sorting and basic  <flavell@ph.gla.ac.uk>
    Re: wtf is the deal? <tom@nosleep.net>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 21 Sep 2003 13:12:52 -0500
From: "walala" <mizhael@yahoo.com>
Subject: some stupid questions about string search & replace in perl
Message-Id: <bkkpmq$5nc$1@mozo.cc.purdue.edu>

Dear all,

I have been learning Perl for several days by reading online tutorials...
now when I really need it to some serious work, I found I still have a bunch
of questions:

1. How to make a string all to "UPPER CASE"?

2. Suppose there is a "(" (bracket character) in the string $str, and I want
to remove it, how can I do that?

3. Suppose there are two lines in my text file:

M1834 S_4 47 52 VDD!  PCH  L=239.99999143598E-9 W=3.99999998990097E-6 \
AD=2.04320002757108E-12 AS=1.58200004745507E-12 PD=5.36000015927129E-6 \
PS=829.999976303952E-9 NRD=+2.50000001E-01 NRS=+2.50000001E-01 M=1.0

I want to change the "\ ^n" ( The "\" plus an "LF" at the end of each line)
to "^n +" (first do an "LF", then add a "+" to the front of each line)

The result is:

M1834 S_4 47 52 VDD!  PCH  L=239.99999143598E-9 W=3.99999998990097E-6
+AD=2.04320002757108E-12 AS=1.58200004745507E-12 PD=5.36000015927129E-6
+PS=829.999976303952E-9 NRD=+2.50000001E-01 NRS=+2.50000001E-01 M=1.0

How can I do that?

Thanks a lot,

-Walala




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

Date: Sun, 21 Sep 2003 14:48:14 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: walala <mizhael@yahoo.com>
Subject: Re: some stupid questions about string search & replace in perl
Message-Id: <Pine.SGI.3.96.1030921144638.322311B-100000@vcmr-64.server.rpi.edu>

[posted & mailed]

On Sun, 21 Sep 2003, walala wrote:

>I have been learning Perl for several days by reading online tutorials...
>now when I really need it to some serious work, I found I still have a bunch
>of questions:

A more local source of answers is the standard perl documentation.  Use
the 'perldoc' program that comes with perl.

>1. How to make a string all to "UPPER CASE"?

The uc() function.  See 'perldoc -f uc'.

>2. Suppose there is a "(" (bracket character) in the string $str, and I want
>to remove it, how can I do that?

With a regular expression (substitution) like s/\(//.

>3. Suppose there are two lines in my text file:
>
>M1834 S_4 47 52 VDD!  PCH  L=239.99999143598E-9 W=3.99999998990097E-6 \
>AD=2.04320002757108E-12 AS=1.58200004745507E-12 PD=5.36000015927129E-6 \
>PS=829.999976303952E-9 NRD=+2.50000001E-01 NRS=+2.50000001E-01 M=1.0
>
>I want to change the "\ ^n" ( The "\" plus an "LF" at the end of each line)
>to "^n +" (first do an "LF", then add a "+" to the front of each line)

Are those really line-feeds?  Or are they newlines?  You might want the
substitution s/\\\n/\n+/g, but I can't be sure.

-- 
Jeff Pinyan            RPI Acacia Brother #734            2003 Rush Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: Sun, 21 Sep 2003 14:48:14 -0400
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: some stupid questions about string search & replace in perl
Message-Id: <Qnmbb.5446$112.280602@wagner.videotron.net>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

walala wrote:
> Dear all,
> 
> I have been learning Perl for several days by reading online tutorials...
> now when I really need it to some serious work, I found I still have a bunch
> of questions:
> 
> 1. How to make a string all to "UPPER CASE"?

$str = uc($str);

See perldoc -f uc

> 
> 2. Suppose there is a "(" (bracket character) in the string $str, and I want
> to remove it, how can I do that?

$data =~ s/\(//;

See perldoc perlop

> 
> 3. Suppose there are two lines in my text file:
> 
> M1834 S_4 47 52 VDD!  PCH  L=239.99999143598E-9 W=3.99999998990097E-6 \
> AD=2.04320002757108E-12 AS=1.58200004745507E-12 PD=5.36000015927129E-6 \
> PS=829.999976303952E-9 NRD=+2.50000001E-01 NRS=+2.50000001E-01 M=1.0
> 
> I want to change the "\ ^n" ( The "\" plus an "LF" at the end of each line)
> to "^n +" (first do an "LF", then add a "+" to the front of each line)

$data =~ s/\\\n/\n+/g;

See perldoc perlop

Also it might benefit you to buy and learn from a good Perl book by O'Reilly.

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE/bfJweS99pGMif6wRAkgIAJ0SsXYBSTINKK11ipNeAfdo/sOkzgCeILKs
39ke2/fXlp5j4hwzvydQFeA=
=48d3
-----END PGP SIGNATURE-----



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

Date: Sun, 21 Sep 2003 12:27:59 -0700
From: "Tom" <tom@nosleep.net>
Subject: Re: some stupid questions about string search & replace in perl
Message-Id: <3f6dfb13$1@nntp0.pdx.net>

Learning Perl, O'Reilly is a must have. After that, Programmimg Perl,
O'Reilly




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

Date: Sun, 21 Sep 2003 14:27:21 -0500
From: "walala" <mizhael@yahoo.com>
Subject: Re: some stupid questions about string search & replace in perl
Message-Id: <bkku2f$7j0$1@mozo.cc.purdue.edu>

Dear Jeff,

sorry, for that problem 3, I guess what I want is to remove the "\" at the
end of each line and add a "+" to the beginning of the next line(not the
front of that line, but next line)...

Can you statement still do the work?

Thanks a lot,

-Walala


> >3. Suppose there are two lines in my text file:
> >
> >M1834 S_4 47 52 VDD!  PCH  L=239.99999143598E-9 W=3.99999998990097E-6 \
> >AD=2.04320002757108E-12 AS=1.58200004745507E-12 PD=5.36000015927129E-6 \
> >PS=829.999976303952E-9 NRD=+2.50000001E-01 NRS=+2.50000001E-01 M=1.0
> >
> >I want to change the "\ ^n" ( The "\" plus an "LF" at the end of each
line)
> >to "^n +" (first do an "LF", then add a "+" to the front of each line)
>
> Are those really line-feeds?  Or are they newlines?  You might want the
> substitution s/\\\n/\n+/g, but I can't be sure.
>
> -- 
> Jeff Pinyan            RPI Acacia Brother #734            2003 Rush
Chairman
> "And I vos head of Gestapo for ten     | Michael Palin (as Heinrich
Bimmler)
>  years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead
Bye-Election
>  Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
>




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

Date: Sun, 21 Sep 2003 14:26:54 -0500
From: "walala" <mizhael@yahoo.com>
Subject: Re: some stupid questions about string search & replace in perl
Message-Id: <bkku1k$7in$1@mozo.cc.purdue.edu>

Dear Mina,

sorry, for that problem 3, I guess what I want is to remove the "\" at the
end of each line and add a "+" to the beginning of the next line(not the
front of that line, but next line)...

Can you statement still do the work?

Thanks a lot,

-Walala

> > 3. Suppose there are two lines in my text file:
> >
> > M1834 S_4 47 52 VDD!  PCH  L=239.99999143598E-9 W=3.99999998990097E-6 \
> > AD=2.04320002757108E-12 AS=1.58200004745507E-12 PD=5.36000015927129E-6 \
> > PS=829.999976303952E-9 NRD=+2.50000001E-01 NRS=+2.50000001E-01 M=1.0
> >
> > I want to change the "\ ^n" ( The "\" plus an "LF" at the end of each
line)
> > to "^n +" (first do an "LF", then add a "+" to the front of each line)
>
> $data =~ s/\\\n/\n+/g;
>
> See perldoc perlop
>
> Also it might benefit you to buy and learn from a good Perl book by
O'Reilly.
>




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

Date: Sun, 21 Sep 2003 19:46:26 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: some stupid questions about string search & replace in perl
Message-Id: <3F6E0002.212FB250@acm.org>

walala wrote:
> 
> I have been learning Perl for several days by reading online tutorials...
> now when I really need it to some serious work, I found I still have a bunch
> of questions:
> 
> 1. How to make a string all to "UPPER CASE"?

$string = uc $string;

perldoc -f uc


> 2. Suppose there is a "(" (bracket character) in the string $str, and I want
> to remove it, how can I do that?

$string =~ s/\(//;  # remove first '(' character

$string =~ tr/(//d; # remove all '(' characters

perldoc perlre
perldoc perlop


> 3. Suppose there are two lines in my text file:
> 
> M1834 S_4 47 52 VDD!  PCH  L=239.99999143598E-9 W=3.99999998990097E-6 \
> AD=2.04320002757108E-12 AS=1.58200004745507E-12 PD=5.36000015927129E-6 \
> PS=829.999976303952E-9 NRD=+2.50000001E-01 NRS=+2.50000001E-01 M=1.0
> 
> I want to change the "\ ^n" ( The "\" plus an "LF" at the end of each line)
> to "^n +" (first do an "LF", then add a "+" to the front of each line)
> 
> The result is:
> 
> M1834 S_4 47 52 VDD!  PCH  L=239.99999143598E-9 W=3.99999998990097E-6
> +AD=2.04320002757108E-12 AS=1.58200004745507E-12 PD=5.36000015927129E-6
> +PS=829.999976303952E-9 NRD=+2.50000001E-01 NRS=+2.50000001E-01 M=1.0
> 
> How can I do that?

while ( <> ) {
    s/\s*\\\s+\z/\n +/;
    }



John
-- 
use Perl;
program
fulfillment


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

Date: Sun, 21 Sep 2003 13:15:54 -0500
From: "walala" <mizhael@yahoo.com>
Subject: SOS! how to do conditional search & replacement of strings in perl?
Message-Id: <bkkpsf$5oa$1@mozo.cc.purdue.edu>

Suppose I want to do conditional search & replacement:

I have the following input text file:

-------------------------------------------------------------------
_INST1832 B_1 59  135.301588688164E-18 M=1.0

_INST1833 S_4 47 52 VDD!  PCH  L=239.99999143598E-9 W=3.99999998990097E-6
+AD=2.04320002757108E-12 AS=1.58200004745507E-12 PD=5.36000015927129E-6
+PS=829.999976303952E-9 NRD=+2.50000001E-01 NRS=+2.50000001E-01 M=1.0
-------------------------------------------------------------------

I want to change the "_INST" in the lines where there is no "PCH" or "NCH"
patterns to "C", and change the "_INST" in the lines where there is "PCH" or
"NCH" to "M".

The result should be:

-------------------------------------------------------------------
C1832 B_1 59  135.301588688164E-18 M=1.0

M1833 S_4 47 52 VDD!  PCH  L=239.99999143598E-9 W=3.99999998990097E-6
+AD=2.04320002757108E-12 AS=1.58200004745507E-12 PD=5.36000015927129E-6
+PS=829.999976303952E-9 NRD=+2.50000001E-01 NRS=+2.50000001E-01 M=1.0
-------------------------------------------------------------------

What do I do? Can you give me the right "regular expression" which can do
such thing?

Thank you very much!

-Walala





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

Date: Sun, 21 Sep 2003 19:56:30 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: SOS! how to do conditional search & replacement of strings in perl?
Message-Id: <3F6E025E.63AB78C2@acm.org>

walala wrote:
> 
> Suppose I want to do conditional search & replacement:
> 
> I have the following input text file:
> -------------------------------------------------------------------
> _INST1832 B_1 59  135.301588688164E-18 M=1.0
> 
> _INST1833 S_4 47 52 VDD!  PCH  L=239.99999143598E-9 W=3.99999998990097E-6
> +AD=2.04320002757108E-12 AS=1.58200004745507E-12 PD=5.36000015927129E-6
> +PS=829.999976303952E-9 NRD=+2.50000001E-01 NRS=+2.50000001E-01 M=1.0
> -------------------------------------------------------------------
> 
> I want to change the "_INST" in the lines where there is no "PCH" or "NCH"
> patterns to "C", and change the "_INST" in the lines where there is "PCH" or
> "NCH" to "M".
> 
> The result should be:
> -------------------------------------------------------------------
> C1832 B_1 59  135.301588688164E-18 M=1.0
> 
> M1833 S_4 47 52 VDD!  PCH  L=239.99999143598E-9 W=3.99999998990097E-6
> +AD=2.04320002757108E-12 AS=1.58200004745507E-12 PD=5.36000015927129E-6
> +PS=829.999976303952E-9 NRD=+2.50000001E-01 NRS=+2.50000001E-01 M=1.0
> -------------------------------------------------------------------
> 
> What do I do? Can you give me the right "regular expression" which can do
> such thing?


perl -pe'/PCH|NCH/ ? s/^_INST/M/ : s/^_INST/C/' yourfile



John
-- 
use Perl;
program
fulfillment


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

Date: Sun, 21 Sep 2003 21:37:40 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: SOS! how to do conditional search & replacement of strings in perl?
Message-Id: <bkkuru$2uj43$1@ID-184292.news.uni-berlin.de>

walala wrote:
> I want to change the "_INST" in the lines where there is no "PCH"
> or "NCH" patterns to "C", and change the "_INST" in the lines where
> there is "PCH" or "NCH" to "M".

<snip>

> What do I do?

You study Perl documentation:

     perldoc perlre
     perldoc perlop

Also available on the web: http://www.perldoc.com/

Then you write the code yourself. :)

> Can you give me the right "regular expression" which can do such
> thing?

Yes, there are quite a few people who can do that.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Sun, 21 Sep 2003 16:36:44 GMT
From: Bob Walton <bwaNOlton@rochSPester.rAMr.com>
Subject: Re: SOS! how to search & replace some string to numbers in a text file?
Message-Id: <3F6DD38C.5030903@rochSPester.rAMr.com>

walala wrote:

 ...


> I want to search and replace some string in input file A.txt and then output
> B.txt.
> 
> 
> The target string in A.txt is:¡°NRD=1U/X.XXE-0X¡±,(where X.XX stands for a
> number, -E0X is its exponentials, for example, NRD=1U/1.84E-06)
> 
> I want to change this to ¡°NRD=Y.YYYY¡±, where Y.YYYY=1e-6/X.XXe-0X.
> 
> For example, "NRD=1U/1.84E-06"  ->  "NRD=0.5435
> 
> I want to search the whole file and for all such occurence, replace then
> output to B.txt.
> 
> Can anybody give me the example code on how to do this? Thanks a lot!
> 
> -Walala


One one line [untested]:


perl -pe 
's|NRD=1U/(\d\.\d\dE[+-]?0\d)|"NRD=".sprintf("%6.4f",1e-6/$1)|eg' A.txt 
 >B.txt

Change quotes around if on Windoze.
-- 
Bob Walton



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

Date: Sun, 21 Sep 2003 16:43:44 GMT
From: Bob Walton <bwaNOlSPtAMon@rochester.rr.com>
Subject: Re: SOS! how to search & replace some string to numbers in a text file?
Message-Id: <3F6DD52F.9060105@rochester.rr.com>

walala wrote:

 ...


> I want to search and replace some string in input file A.txt and then output
> B.txt.
> 
> 
> The target string in A.txt is:¡°NRD=1U/X.XXE-0X¡±,(where X.XX stands for a
> number, -E0X is its exponentials, for example, NRD=1U/1.84E-06)
> 
> I want to change this to ¡°NRD=Y.YYYY¡±, where Y.YYYY=1e-6/X.XXe-0X.
> 
> For example, "NRD=1U/1.84E-06"  ->  "NRD=0.5435"
> 
> I want to search the whole file and for all such occurence, replace then
> output to B.txt.
> 
> Can anybody give me the example code on how to do this? Thanks a lot!
> 
> -Walala
> 


All on one line [untested]:


perl -pe 
's|NRD=1U/(\d\.\d\dE[+-]?0\d)|"NRD=".sprintf("%6.4f",1e-6/$1)|eg' A.txt 
 >B.txt

-- 
Bob Walton



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

Date: Sun, 21 Sep 2003 19:21:32 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: SOS! how to search & replace some string to numbers in a text file?
Message-Id: <3F6DFA2C.FE699B28@acm.org>

walala wrote:
> 
> I want to search and replace some string in input file A.txt and then output
> B.txt.
> 
> The target string in A.txt is:¡°NRD=1U/X.XXE-0X¡±,(where X.XX stands for a
> number, -E0X is its exponentials, for example, NRD=1U/1.84E-06)
> 
> I want to change this to ¡°NRD=Y.YYYY¡±, where Y.YYYY=1e-6/X.XXe-0X.
> 
> For example, "NRD=1U/1.84E-06"  ->  "NRD=0.5435"
> 
> I want to search the whole file and for all such occurence, replace then
> output to B.txt.
> 
> Can anybody give me the example code on how to do this? Thanks a lot!


perl -pe's!(?<=NRD=)1U/(\d\.\d+[Ee]-\d+)!sprintf"%.4f",1e-6/$1!eg' A.txt > B.txt



John
-- 
use Perl;
program
fulfillment


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

Date: Sun, 21 Sep 2003 14:42:39 -0700
From: Erik Max Francis <max@alcyone.com>
Subject: Re: This probably aint the right place  . . . but there's no real  newsgroup for MySQL
Message-Id: <3F6E1B4F.7AB68296@alcyone.com>

Michael Budash wrote:

> > Hope you don't mind me crossposting this but I'd really like to get
> > a few
> > responses as my lame ISp never so much as answers my questions.
> 
> change isps, life's too short...

Why should it be his ISP's responsibility to teach him programming?

-- 
   Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ Sometimes there's no point in giving up.
\__/  Louis Wu


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

Date: Sun, 21 Sep 2003 18:49:48 +1000
From: "Bob" <nemail@hotmail.com>
Subject: This probably aint the right place  . . . but there's no real newsgroup for MySQL
Message-Id: <T9obb.3950$d6.158629@nasal.pacific.net.au>

Hope you don't mind me crossposting this but I'd really like to get a few
responses as my lame ISp never so much as answers my questions.

My ISP has given me a shell and 5meg to play with, I want to run a football
tipping website for me a nd a few friends next season -  Trivial stuff. HTML
and Perl basically, maybe a few cron jobs to update the round table.

I haven't used MySql and need to set up a few tables for rounds, punters and
tips scoring etc . . . simple database . . . easy relations, not rocket
science to design and implement using Perl. I imagine once I have set this
up the Perl side of it puts any sort of interface with MySQl to bed.

Can someone point me in the right direction as to how to define a database,
from the UNIX prompt and interact with MySQL to do this - where typically do
they place the binaries for MySQl in the UNIX scheme of things, (could be
Linux but I have a Bourne Shell so I'm assuming UNIX).

Thanks very much in advance,
Bob.




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

Date: Sun, 21 Sep 2003 21:12:59 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: This probably aint the right place  . . . but there's no real newsgroup for MySQL
Message-Id: <mbudash-989319.14125821092003@typhoon.sonic.net>

In article <T9obb.3950$d6.158629@nasal.pacific.net.au>,
 "Bob" <nemail@hotmail.com> wrote:

> Hope you don't mind me crossposting this but I'd really like to get a few
> responses as my lame ISp never so much as answers my questions.

change isps, life's too short...

> My ISP has given me a shell and 5meg to play with, I want to run a football
> tipping website for me and a few friends next season -  Trivial stuff. HTML
> and Perl basically, maybe a few cron jobs to update the round table.
> 
> I haven't used MySql and need to set up a few tables for rounds, punters and
> tips scoring etc . . . simple database . . . easy relations, not rocket
> science to design and implement using Perl. I imagine once I have set this
> up the Perl side of it puts any sort of interface with MySQl to bed.
> 
> Can someone point me in the right direction as to how to define a database,
> from the UNIX prompt and interact with MySQL to do this - where typically do
> they place the binaries for MySQl in the UNIX scheme of things, (could be
> Linux but I have a Bourne Shell so I'm assuming UNIX).

your isp should have given you the mysql host (which may be 
'localhost'), dbname, username and password for your db. since the mysql 
binaries may well be in your shells' default path, try this from the 
command line:

mysql -h hostname -u username -ppassword dbname

if it can't find the mysql binary, you'll need to call your isp (sorry).

alternatively, many isps give you a controlled interface to your db. 
some use something called phpMyAdmin, a nice tool (even if it isn't 
written in perl!).

from there, rtfm:

http://www.mysql.com/documentation/

i'm sure you'll be back to ask about using perl to interact with your 
db, so this'll get you started:

perldoc DBI
perldoc DBD::mysql

if they (the DBI and DBD::mysql perl modules) are not installed, your 
isp is less than lame... but you can install them yourself. let's only 
go there if we have to...

that should get you started. good luck!
-- 
Michael Budash


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

Date: Sun, 21 Sep 2003 21:47:55 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: This probably aint the right place  . . . but there's no real newsgroup for MySQL
Message-Id: <mbudash-900B89.14475421092003@typhoon.sonic.net>

In article <3F6E1B4F.7AB68296@alcyone.com>,
 Erik Max Francis <max@alcyone.com> wrote:

> Michael Budash wrote:
> 
> > > Hope you don't mind me crossposting this but I'd really like to 
> > > get a few responses as my lame ISp never so much as answers my 
> > > questions.
> > 
> > change isps, life's too short...
> 
> Why should it be his ISP's responsibility to teach him programming?

he said: "my lame ISp never so much as answers my questions", not: "my 
lame ISp won't teach me programming and it's their responsibility".

-- 
Michael Budash


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

Date: Sun, 21 Sep 2003 16:51:24 -0500
From: "Bill McCormick" <wpmccormick@hotmail.com>
Subject: Re: This probably aint the right place  . . . but there's no real newsgroup for MySQL
Message-Id: <bkl65n$cjf$1@sun-news.laserlink.net>

if you have a full time connection (cable | dsl) , just set up you're own
web server.

no linux box? cygwin (GPL=free)!!! or get a junk box and put redhat on it.

both cygwin and redhat come with apache. you could run mysql on cygwin or
get the win32 binary. redhat comes with mysql.

got pppoe? use a (free) dynamic dns like www.dyndns.org

then you're web site can be something like http://fbtipping.ath.cx





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

Date: Sun, 21 Sep 2003 22:29:01 +0200
From: peter pilsl <pilsl_usenet@goldfisch.at>
Subject: Re: troubles with unicode (incorrect sorting and basic understandingproblems)
Message-Id: <3f6e0ace$1@e-post.inode.at>

Alan J. Flavell wrote:

<skip very useful information>
> 
> Does that get you any further?  I hope so.  Must get back to worm
> fighting now, there's a bunch of bogus virus alerts hitting our users
> from misguided virus scanners out there, as a byproduct of the current
> worm crop (Gibe-F a.k.a Swen).  It's always less work to catch those
> bogus alerts in the mailer, than to calm the distressed users down
> afterwards.  The worms themselves are by comparison easy to block!
> 

:) ack.  thnx you found time to give me a hand anyway. Got a lot of useful 
information from you. thnx a lot.

I now even more reduced my problem to pure perl - without any CGI or SQL.
(Lets say : I isolated one of my problems :)

I wrote a small script (source at the end), that produces some text and 
tries to sort it.  I was suprised that the sorting-order depends on the 
stuff to be sorted :)


In my first attempt the order was like I expected. Then I added one more 
text (a smiley) to the array and the sorting-order was wrong again. This is 
very interesing.  (see HERE1 in the source)

A second interesting thing is, that the result of the ordering depends on 
the used locale. It makes a reseaonable difference if I use "de_AT" as 
LC_CTYPE or using "de_AT.UTF-8".  In the first case, ordering and 
lowercasing works fine. In the second case, ordering and lowercasing 
produces shit.  (see HERE2 in the source)

Other experiences from my script: the "use local"-pragma is important, but 
it does not matter which locale one uses (In fact even "korean" was ok) as 
long as it does not contain "UTF-8" ;) 

So all this unicode-stuff seems very chaotic to me. Minimum changes in the 
input produces unpredictable changes in the output. :) At the end I should 
set up a big database containing 100.000 entries that should be fully 
searchable ;)  And I struggle with sorting in a 10-liner ;)

-----------------------------------------
#!/usr/bin/perl -w
use strict;
use locale;
use POSIX qw(locale_h);

print setlocale(LC_CTYPE),"\n";
setlocale(LC_CTYPE,"de_AT");
#setlocale(LC_CTYPE,"de_AT.UTF-8");   # <=== UNCOMMENT HERE2 !!!
print setlocale(LC_CTYPE),"\n";
#binmode(STDOUT,":utf8");          # I uncommented this, cause it looks
                                # better on my terminal

my @s;
p("\x{00e4} this is lower german umlaut-a");
p("\x{00c4} this is upper german umlaut-A");
p("\x{00d6} this is lower german umlaut-o");
p("\x{00f6} this is upper german umlaut-O");
p("a this is a lower a");
p("A this is a upper a");
p("z this is a lower z");
p("b this is a lower b");
p("B this is a upper B");
p("p this is a lower p");
p("P this is a upper P");
p("o this is a lower o");
p("O this is a upper O");
#p("\x{263a} this is a smiley");              # <=====  UNCOMMENT HERE1 !!!

@s=sort map {lc($_)." (l=".length($_).")"} @s;
print join("\n",@s),"\n";

sub p{
  push(@s,shift);
}
----------------------------------



So I'm left confused. Another thing is, that I dont know how to get the 
unicode-code from a given string: lets say:
$a="\x{263a}" and I want to get  the 263a back from $a. This could help me 
to understand the stuff delivered from CGI.  Using the locale-pragma and 
the above script on data delivered by my webscript didnt not work. It seems 
as if CGI.pm does not deliver real unicode (although I use recent version 
2.98)

I would be very pleased to hear from other people if they managed to run 
bigger projects that include demanding tasks like sorting and so on relying 
completely on unicode.

peter (who should have become a gardener or whatever ;)

ps: I cant say enough thnx to Alan and wonder if other people around here 
are working with unicode in perl too. I googled alot on my questions and it 
seems that there still is many confusion about unicode :) 


-- 
peter pilsl
pilsl_usenet@goldfisch.at
http://www.goldfisch.at



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

Date: Sun, 21 Sep 2003 22:05:27 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: troubles with unicode (incorrect sorting and basic understandingproblems)
Message-Id: <Pine.LNX.4.53.0309212137250.15155@ppepc56.ph.gla.ac.uk>

On Sun, 21 Sep 2003, peter pilsl wrote:

> In my first attempt the order was like I expected. Then I added one more
> text (a smiley) to the array and the sorting-order was wrong again.

This sounds like a consequence of Perl staying with 8-bit
representation as long as possible, and only upgrading to Unicode when
it has no alternative.  See
http://www.perldoc.com/perl5.8.0/pod/perluniintro.html#Perl's-Unicode-Model

So my hunch is that until you added the smiley, the sorting is working
just like it always did; but when you added the smiley, the whole
Unicode thing got switched on.

You'd get the same effect by adding a Greek or Cyrillic character -
anything that can't be expressed in the base 8-bit coding (iso-8859-1
in your case).  Conversely, I guess if you taught Perl to work in
Greek (iso-8859-7) then it would switch into Unicode mode when you
added your German umlaut (but don't quote me on that).

> A second interesting thing is, that the result of the ordering depends on
> the used locale. It makes a reseaonable difference if I use "de_AT" as
> LC_CTYPE or using "de_AT.UTF-8".  In the first case, ordering and
> lowercasing works fine. In the second case, ordering and lowercasing

The perllocale page gives a list of pre-requisites before a locale can
work.  Maybe you haven't got this locale available on your platform?
This area is something I really haven't explored yet, to be honest.

> So all this unicode-stuff seems very chaotic to me.

It's organised somehow under the covers!  It only _seems_ to be
chaotic, I reckon.

It's a pity we don't have a regular contributor here who really
understands this stuff, so you're stuck with me who, more as a hobby
than a profession, learns it piece by piece as each new angle comes
up.

> So I'm left confused. Another thing is, that I dont know how to get the
> unicode-code from a given string:

ord() works for unicode, it takes a Perl character (i.e not just a
byte!) as argument, and delivers an integer result.  How you then
print that out (decimal, hex, whatever) is up to you.  Unicode
themselves conventionally work in hex, as you know.

And if you feed that integer number to chr() then you get Perl's
unicode character out (unless, as I say, it decides it can get away
with just using 8-bit characters).

Those are just the customary Perl functions, transparently upgraded to
support unicode.  And you can use substr() and so on, applied to
Perl's Unicode strings, it doesn't need any new syntax there.

hope that helps


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

Date: Sun, 21 Sep 2003 11:53:05 -0700
From: "Tom" <tom@nosleep.net>
Subject: Re: wtf is the deal?
Message-Id: <3f6df2e6$1@nntp0.pdx.net>

> If you travelled to Britain, would you insist on driving on the
> right-hand side of the road?  After all, it's just a convention, and
> those silly Brits will surely see the light after you show them how
> to drive properly.  What would actually happen, though, is that
> everyone would honk at you and you would cause a wreck.

Lol, are you kidding, those Brits are all nuts when it comes to driving,
regardless of what side of the road it is :)

I take a taxi when I'm there...




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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

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.  

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


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