[24012] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6210 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 3 18:06:06 2004

Date: Wed, 3 Mar 2004 15:05:12 -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, 3 Mar 2004     Volume: 10 Number: 6210

Today's topics:
    Re: (newbie) How do I group a string for repetition cou <bart.lateur@pandora.be>
    Re: /dev/pts/x, /proc/x/fd, reading stdout, writing std <nospam@nospam9.se>
    Re: Book recommendations for programmer (Randal L. Schwartz)
    Re: Book recommendations for programmer <nospam_007@yahoo.com>
    Re: File::Copy <usenet@morrow.me.uk>
    Re: message from perl script to java applet (Dirk)
    Re: MIME::Lite and pictures <chatiman@free.fr>
    Re: new to perl <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: new to perl <arthur0421@163.com>
    Re: new to perl <arthur0421@163.com>
    Re: new to perl <tore@aursand.no>
    Re: new to perl <gnari@simnet.is>
    Re: Perl & Sessions? <vetro@online.no>
    Re: Perl & Sessions? <sbryce@scottbryce.com>
    Re: Perl & Sessions? <vetro@online.no>
    Re: Perl & Sessions? (another one)
    Re: Perl & Sessions? <g_klinedinst@hotmail.com>
        perl autoconf type utility <peter@nospam.calweb.com>
    Re: perl autoconf type utility <usenet@morrow.me.uk>
        Perl golf: printing data in hex (A. Farber)
    Re: Perl golf: printing data in hex <ThomasKratz@REMOVEwebCAPS.de>
    Re: Perl golf: printing data in hex <ron.parker@povray.org>
    Re: Perl golf: printing data in hex <fifo@despammed.com>
    Re: Perl golf: printing data in hex (Jay Tilton)
    Re: Removing accents from spanish characters <HelgiBriem_1@hotmail.com>
    Re: Removing accents from spanish characters (Duke of Hazard)
    Re: Removing accents from spanish characters <usenet@morrow.me.uk>
    Re: Removing accents from spanish characters <noreply@gunnar.cc>
    Re: Removing accents from spanish characters <gnari@simnet.is>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 03 Mar 2004 16:28:29 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: (newbie) How do I group a string for repetition count?  {m,n}
Message-Id: <hr1c40he5vn6e9p5f7epu8a4k4do1ofj8p@4ax.com>

Ray wrote:

>I'm trying the following to get the 2nd, and only the 2nd occurrence
>of the phrase "turkey shoot", in a string with a lot more than 2
>occurrences of the phrase:
>
>(turkey shoot){2}
>
>It does't match anything.

I hope matching first till second appearance is OK.

	/(turkey shoot).*?\1/

-- 
	Bart.


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

Date: Wed, 03 Mar 2004 18:52:32 GMT
From: Andreas Persson <nospam@nospam9.se>
Subject: Re: /dev/pts/x, /proc/x/fd, reading stdout, writing stdin, not with open3
Message-Id: <pan.2004.03.03.18.52.54.767391@nospam9.se>

On Wed, 03 Mar 2004 00:17:47 -0500, James Willmore wrote:

> 
> Can you, instead, redirect or `tee` the output of the application you're
> trying to monitor to a fifo and then let the script read that instead of
> the virtual console?

never tested to write to the fifo(client)(i really need this), but if i do
something bad like closing the fifo, the server app process gets killed.
thats why i continued to look for another solution.. 

the server application(no source availble) needs to be accesible by admins
and running 24/7.

is it possible to do what im trying to do?
or what can i do?

any help are welcome.

(i really hope this doesnt 'top posts', first time on this news client,
sorry if it does)
/Andreas





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

Date: Wed, 03 Mar 2004 16:21:20 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Book recommendations for programmer
Message-Id: <68e664695507e600bb68cb9ba73f5091@news.teranews.com>

>>>>> "Paul" == Paul Lalli <ittyspam@yahoo.com> writes:

Paul> If you want to learn Perl, you want Learning Perl.  If you want to apply
Paul> Perl for the two purposes you mentioned, you might want to try the Perl
Paul> Cookbook.

And if you're using Perl for larger programs and want to continue in
the style of Learning Perl, check out Learning Perl Objects References
and Modules.

-- 
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, 03 Mar 2004 16:54:48 GMT
From: Don Stefani <nospam_007@yahoo.com>
Subject: Re: Book recommendations for programmer
Message-Id: <s5o1c.5520$sm2.3888@newssvr27.news.prodigy.com>

sw wrote:
> I'm looking for book recommendations for learning Perl. 

I would recommend the latest Perl CD Bookshelf,..

It contains:

Perl in a Nutshell
Mastering Regular Expressions
Learning Perl
Programming Perl
Learning Perl Objects, References, and Modules
Perl Cookbook 2nd ed.
+ A paperback version of Perl in a Nutshell

I purchased mine at bookpool.com
http://www.bookpool.com/.x/z8dxy93yz8/sm/0596006225

As a programming newbie I was also really helped by "Elements of Programming with Perl" by 
Andrew L. Johnson.

With the above materials, PerlDocs and CPAN you'll have your hands full.

Side-note: I found a good use for my windows machine by installing activeperl and using 
the HTML version of the Perldocs it comes with. It has everything categorized and linked. 
It's pretty cool.

Then if you REALLY get stuck, you have this newsgroup and you can check out 
'PerlMonks.org'. A very cool place indeed.

That's my two cents.

dstefani




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

Date: Wed, 3 Mar 2004 16:49:04 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: File::Copy
Message-Id: <c252a0$mik$1@wisteria.csv.warwick.ac.uk>


sunilsreenivas2001@yahoo.com (sunil) wrote:
>  A small question about File::Copy. I want to know if calling copy()
> inside my perl script creates a new process.

No. What made you think it might?

Ben

-- 
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
   From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes,        [ Heracles shoots Vulture with arrow. Vulture bursts into ]
 /Alcestis/)        [ flame, and falls out of sight. ]         ben@morrow.me.uk


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

Date: 3 Mar 2004 11:07:12 -0800
From: buergi1@uni.de (Dirk)
Subject: Re: message from perl script to java applet
Message-Id: <d2e30050.0403031107.7fc46785@posting.google.com>

kodo <inbox@kodo.me.uk> wrote in message news:<c24uh5$1kp91m$2@ID-226330.news.uni-berlin.de>...
> maybe you could be a "bit" more specific on what you want to do?

thank you that you want to help me

 ..but i found out how i can do it

the java applet will listen to a socket and the perlscript sends this
message to this socket. so the message can directly displayed in the
applet. i only hava to modify this two parts.

on java side:
import java.net.*;
import java.io.*;

public class Server {

  public static void main(String[] args) throws IOException {

    String inputLine;

    ServerSocket soc = new ServerSocket(6789);
    Socket inputsoc = soc.accept();
    InputStream is = inputsoc.getInputStream();
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader in = new BufferedReader(isr);

    while ((inputLine = in.readLine())!=null ) {
      System.out.println(inputLine);
    }
  }
}


on perl side:
use IO::Socket::INET;
$MySocket=new IO::Socket::INET->new(PeerPort=>6789,
        Proto=>'tcp',
        PeerAddr=>'localhost');
$msg="This is the message";
$MySocket->send($msg);


 ...but thank you again


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

Date: Wed, 3 Mar 2004 17:38:25 +0100
From: "chatiman" <chatiman@free.fr>
Subject: Re: MIME::Lite and pictures
Message-Id: <404609f4$0$4668$626a14ce@news.free.fr>


"James Willmore" <jwillmore@remove.adelphia.net> a écrit dans le message de
news: pan.2004.03.03.15.20.55.123914@remove.adelphia.net...
>
> Seriously .... the documentation does explain how to attach files to a
> message.  Just try out some of the sample code and it will come to you.
>

I read it a little too fast ... So I have to put "cid:" before in my image
links
Thanks :)






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

Date: Wed, 3 Mar 2004 08:26:00 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: new to perl
Message-Id: <ou052c.i3o.ln@goaway.wombat.san-francisco.ca.us>

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

On 2004-03-03, Tsui Wai-ming <s020274@cuhk.edu.hk> wrote:
> I just started to learn CGI by writing a perl script, but what appeared on
> the browser was exactly what I'd typed in the editor, minus the
><title>xxx</title> line.

Your webserver is not configured properly.  Find out how to
configure it (in a different newsgroup, most likely).

- --keith

- -- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFARgcUhVcNCxZ5ID8RAk7CAJ9F2Ljdu28kVDyHguGTGXcIuDGw3QCfeRX+
Qaxm58GtipvXm2x+6UBgLSk=
=wCQu
-----END PGP SIGNATURE-----


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

Date: Thu, 04 Mar 2004 00:34:58 +0800
From: Regent <arthur0421@163.com>
Subject: Re: new to perl
Message-Id: <c251gs$d4r$1@mail.cn99.com>

Tsui Wai-ming wrote:
> I just started to learn CGI by writing a perl script, but what appeared on
> the browser was exactly what I'd typed in the editor, minus the
> <title>xxx</title> line.
> 
> This is the script I wrote, in fact it is what I directly copied from "Perl
> How to Program":
> 
> #!c:\perl\bin
> #displaying time in brower
> 
> print "Content-type: text/html\n\n";
> print "<html><head><title>Hello!</title>";
> print "</head>\n<body>";
> print scalar( localtime() );
> print "</body></html>"
> 
> Many thanks!!!
> 
Why not tell us WHAT is on the browser.

Regent


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

Date: Thu, 04 Mar 2004 00:37:21 +0800
From: Regent <arthur0421@163.com>
Subject: Re: new to perl
Message-Id: <c251l5$d4r$2@mail.cn99.com>

Tsui Wai-ming wrote:

> I just started to learn CGI by writing a perl script, but what appeared on
> the browser was exactly what I'd typed in the editor, minus the
> <title>xxx</title> line.
> 
> This is the script I wrote, in fact it is what I directly copied from "Perl
> How to Program":
> 
> #!c:\perl\bin
> #displaying time in brower
> 
> print "Content-type: text/html\n\n";
> print "<html><head><title>Hello!</title>";
> print "</head>\n<body>";
> print scalar( localtime() );
> print "</body></html>"
> 
> Many thanks!!!
> 
> 
> 
Well, I believe your shebang line should be

#!c:\perl\bin\perl

Regent


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

Date: Wed, 03 Mar 2004 20:03:48 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: new to perl
Message-Id: <pan.2004.03.03.18.57.38.523251@aursand.no>

On Thu, 04 Mar 2004 00:07:15 +0800, Tsui Wai-ming wrote:
> I just started to learn CGI by writing a perl script, but what appeared
> on the browser was exactly what I'd typed in the editor, minus the
> <title>xxx</title> line.

This has nothing to do with Perl, but how your web-server is configured.
It seems to be that it isn't set up to handle your Perl-scripts the right
way.

Please ask your question in a newsgroup related to which web-server you
are using, or in a CGI-related newsgroup.


-- 
Tore Aursand <tore@aursand.no>
"First, God created idiots. That was just for practice. Then He created
 school boards." -- Mark Twain


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

Date: Wed, 3 Mar 2004 20:25:50 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: new to perl
Message-Id: <c25euc$3oa$1@news.simnet.is>

"Tsui Wai-ming" <s020274@cuhk.edu.hk> wrote in message
news:c24ved$4qq$1@justice.itsc.cuhk.edu.hk...
> I just started to learn CGI by writing a perl script, but what appeared on
> the browser was exactly what I'd typed in the editor, minus the
> <title>xxx</title> line.
>
[snip perl program]

are you using a web server?

gnari






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

Date: Wed, 03 Mar 2004 17:08:21 +0100
From: Vetle Roeim <vetro@online.no>
Subject: Re: Perl & Sessions?
Message-Id: <m3ad2xvrpm.fsf@quimby.dirtyhack.org>

* James Willmore
[...]
>> After a sucessful login I usually send a hard-to-guess string in a
>> hidden field and then use this to identify the user. The value is held
>> in a table with a date/time stamp that I update whenever I hear from the
>> user, or delete after a given period of non-use or a log-off. This
>> allows the user to do what they like while the identifier is valid -
>> including reject cookies and maintain multiple sessions. It seems
>> simpler than cookies and just as secure.  Or am I missing something ?
>
> Hidden fields are not *really* hidden and can be altered by the user. 
> This is why *most* who do CGI applications don't use hidden fields at all.

  But he has basically the same functionality as cookies, only the
  session id is in a form element. Users can alter their cookie values
  too, you know...


[...]
> The bottom line with this whole thing is really rather simple - create an
> identifer unique for the browser that can can be matched in some way on
> the server.  The identifier *must* be something the user *can not* alter
> (at least, not easily).  Hidden fields is *not* the way to do it.

  It's possible to fake cookie values... Session hijacking is still
  possible, whether the session id is in a form element or in a
  cookie.


[...]

-- 
#!/usr/bin/vr


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

Date: Wed, 03 Mar 2004 10:25:36 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: Perl & Sessions?
Message-Id: <104c58d4and0b61@corp.supernews.com>

James Willmore wrote:

> Hidden fields are not *really* hidden and can be altered by the user. 
> This is why *most* who do CGI applications don't use hidden fields at all.

If the user alters the session ID in a hidden field, then the resulting 
session ID can not be found in a list of current valid session IDs in 
the database. (This assumes, of course, that session IDs are created in 
such a way that a user is not likely to stumble upon another valid 
session ID.) If you were using cookies, you would be doing the same 
thing, (checking the session ID against a list of current valid session 
IDs in a database) or am I missing something?

The reason I lean toward URL munging/hidden fields is that users can 
choose not to accept cookies. If a user does not accept your cookie, you 
cannot identify the session later on. The user does not have the option 
of rejecting your hidden fields.

Certainly he can alter the data, but that is why all data is validated 
on the server before it is assumed to be good.




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

Date: Wed, 03 Mar 2004 21:07:58 +0100
From: Vetle Roeim <vetro@online.no>
Subject: Re: Perl & Sessions?
Message-Id: <m3smgpk82p.fsf@quimby.dirtyhack.org>

* Scott Bryce
[...]
> The reason I lean toward URL munging/hidden fields is that users can
> choose not to accept cookies. If a user does not accept your cookie,
> you cannot identify the session later on. The user does not have the
> option of rejecting your hidden fields.

  If you put the session id in the URL, your system may be vulnerable
  to session hijacking.

  If the user goes to a page in your system (with the session id in
  the URL) and clicks a link to an external site, the session id will
  appear in the referer-header that is sent to the external site.

  Sverre H. Husebys "Innocent Code" covers this, and much more.
  <URL:http://innocentcode.thathost.com/>


[...]
-- 
#!/usr/bin/vr


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

Date: Wed, 03 Mar 2004 16:20:59 +0000
From: "Steve (another one)" <y66y@56yu4b6.com>
Subject: Re: Perl & Sessions?
Message-Id: <c250lc$51u$1@news.liv.ac.uk>

James Willmore wrote:
> On Wed, 03 Mar 2004 14:53:52 +0000, Steve (another one) wrote:
> 
>>James Willmore wrote:
>>
>>>On Wed, 03 Mar 2004 14:42:19 +0100, Thomas Deschepper wrote:
> 
> 
>>>>I would like to make a perl script that lets the user log in and checks
>>>>if the username and password are correct. After authentication, I want
>>>>to track that user. I understand that HTTP is "stateless", so I read
>>>>something about sessions and how to implent them (GET, cookies, hidden
>>>>fields).
>>>>
>>>>But I don't really understand the whole process. After the user logs
>>>>in, do I have to produce a unique hash or something like that??
>>>>
>>>>Can someone explain this to me? I've also read the docs about
>>>>CGI::Session.
>>>
>>>
>>>Have a look at ...
>>>http://www.stonehenge.com/merlyn/WebTechniques/col61.html
>>>
>>>There are several ways to deal with sessions.  However, I find the
>>>above URL one of the better ways to do so.  Basically, you want to make
>>>sure that what the user has as credentials is the same thing the server
>>>sees as valid credentials.  One of the better ways to do this is using
>>>cookies. That's what is explained in better detail in the above URL. 
>>>It is, however, not the only way to do it :-)
>>>
>>>HTH
>>
>>After a sucessful login I usually send a hard-to-guess string in a
>>hidden field and then use this to identify the user. The value is held
>>in a table with a date/time stamp that I update whenever I hear from the
>>user, or delete after a given period of non-use or a log-off. This
>>allows the user to do what they like while the identifier is valid -
>>including reject cookies and maintain multiple sessions. It seems
>>simpler than cookies and just as secure.  Or am I missing something ?
> 
> 
> Hidden fields are not *really* hidden and can be altered by the user. 
> This is why *most* who do CGI applications don't use hidden fields at all.

Of course not, but then neither are cookies. As long as a user can't 
create a string which happens to be a current session id (I also use an 
MD5 hash), they work. I am not arguing in favour of the method I 
outlined - I want  to understand *why* most use cookies.
> 
> And, if you *read* the URL, you would see *why* the author does what he
> does.  Basically, one single cookie is used.  This cookie contains an MD5
> hash (which is, in theory, hard to recontruct).  This session id is match
> to a file on the server.  You can place "stuff" in the file, but I don't
> see it as required.
> 
I did read the URL which is what prompted my response. I didn't see 
anything that made the cookie approach simpler than passing a session 
identifier. The down side is that many users reject cookies.

> "Logging off" is a real mis-conception.  The session between the browser
> and the server is closed after information is sent to and fro - meaning,
> there is no state like telnet or ftp.  Because HTTP is stateless, there
> really is no logging in or logging out per se. Which is why some
> identifier between the browser and the server is created.

Again, of course this is true. By logging off I mean making the session 
id no longer valid.

> 
> The bottom line with this whole thing is really rather simple - create an
> identifer unique for the browser that can can be matched in some way on
> the server.  The identifier *must* be something the user *can not* alter
> (at least, not easily).  Hidden fields is *not* the way to do it.

Sorry to be stupid here, but why is an MD5 digest in a hidden field 
insecure ? If the user changes it they create an invalid session id and 
are rejected. To guess a valid session id is likely to be *much* harder 
than guessing a valid username and password. So I would suggest that it 
doesn't matter if the user can easily alter it. Its not as if it could 
be altered accidentally !

Thanks

Steve



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

Date: Wed, 03 Mar 2004 14:17:13 -0800
From: Greg Klinedinst <g_klinedinst@hotmail.com>
Subject: Re: Perl & Sessions?
Message-Id: <cvlc40t3hgb0qq4bbns3s3uide0jtt5og8@4ax.com>

On Wed, 03 Mar 2004 21:07:58 +0100, Vetle Roeim <vetro@online.no>
wrote:

>  If you put the session id in the URL, your system may be vulnerable
>  to session hijacking.
>
>  If the user goes to a page in your system (with the session id in
>  the URL) and clicks a link to an external site, the session id will
>  appear in the referer-header that is sent to the external site.
>
>  Sverre H. Husebys "Innocent Code" covers this, and much more.
>  <URL:http://innocentcode.thathost.com/>

The user can find out their own session ID in all cases, since in all
cases it is data they(the client) are sending to your server. The only
real difference is that with the URL/hidden vars way you don't need to
worry about the client rejecting cookies. Also the URL way(GET)
probably isn't ideal b/c the URL has a maximum length, so hidden
vars(POST) are best IMHO. You just have to make sure that they cannot
guess how you created the session ID, and make sure you expire session
IDs in your DB.


-Greg


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

Date: Wed, 03 Mar 2004 12:36:01 -0800
From: Penguinista <peter@nospam.calweb.com>
Subject: perl autoconf type utility
Message-Id: <40463f09$0$97600$d368eab@news.calweb.com>

Does there happen to be a perl based equivilent of autoconf?  A project 
I have uses embeded perl, and autoconf is giving me hastles.


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

Date: Wed, 3 Mar 2004 20:31:39 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: perl autoconf type utility
Message-Id: <c25fbb$1ro$1@wisteria.csv.warwick.ac.uk>


Penguinista <peter@nospam.calweb.com> wrote:
> Does there happen to be a perl based equivilent of autoconf?  A project 
> I have uses embeded perl, and autoconf is giving me hastles.

All of perl's config information is available through Config.pm.
You may also find ExtUtils::Embed useful.

Ben

-- 
  The cosmos, at best, is like a rubbish heap scattered at random.
                                                         - Heraclitus
  ben@morrow.me.uk


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

Date: 3 Mar 2004 09:06:11 -0800
From: Alexander.Farber@t-online.de (A. Farber)
Subject: Perl golf: printing data in hex
Message-Id: <c9ccaf83.0403030906.54c5ef96@posting.google.com>

Given a binary string in $x, what would be the shortest way
to print it out in hex, like: 3A BC DE FF 00 .. .. .. ?


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

Date: Wed, 03 Mar 2004 18:35:45 +0100
From: Thomas Kratz <ThomasKratz@REMOVEwebCAPS.de>
Subject: Re: Perl golf: printing data in hex
Message-Id: <4046188b.0@juno.wiesbaden.netsurf.de>

A. Farber wrote:

> Given a binary string in $x, what would be the shortest way
> to print it out in hex, like: 3A BC DE FF 00 .. .. .. ?

my $str = "\x3A\x3A\xBC\xDE\xFF\x00";
print join ' ', map uc(unpack("H*", $_)), split(//, $str);

Thomas

-- 
open STDIN,"<&DATA";$=+=14;$%=50;while($_=(seek( #J~.> a>n~>>e~.......>r.
STDIN,$:*$=+$,+$%,0),getc)){/\./&&last;/\w| /&&( #.u.t.^..oP..r.>h>a~.e..
print,$_=$~);/~/&&++$:;/\^/&&--$:;/>/&&++$,;/</  #.>s^~h<t< ..~. ...c.^..
&&--$,;$:%=4;$,%=23;$~=$_;++$i==1?++$,:_;}__END__#....>>e>r^..>l^...>k^..


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

Date: Wed, 3 Mar 2004 13:55:14 -0500
From: Ron Parker <ron.parker@povray.org>
Subject: Re: Perl golf: printing data in hex
Message-Id: <slrnc4cagi.3lg.ron.parker@mail.parkrrrr.com>

On 3 Mar 2004 09:06:11 -0800, A. Farber wrote:
> Given a binary string in $x, what would be the shortest way
> to print it out in hex, like: 3A BC DE FF 00 .. .. .. ?

$_=unpack('H*',$x);s/(..)/\U\1 /g;print

-- 
#macro R(L P)sphere{L F}cylinder{L P F}#end#macro P(V)merge{R(z+a z)R(-z a-z)R(a
-z-z-z a+z)torus{1F clipped_by{plane{a 0}}}translate V}#end#macro Z(a F T)merge{
P(z+a)P(z-a)R(-z-z-x a)pigment{rgbf 1}hollow interior{media{emission 3-T}}}#end 
Z(-x-x.2x)camera{location z*-10rotate x*90normal{bumps.02scale.05}}


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

Date: Wed, 03 Mar 2004 18:59:54 +0000
From: fifo <fifo@despammed.com>
Subject: Re: Perl golf: printing data in hex
Message-Id: <20040303185954.GA3134@fleece>

At 2004-03-03 09:06 -0800, A. Farber wrote:
> Given a binary string in $x, what would be the shortest way
> to print it out in hex, like: 3A BC DE FF 00 .. .. .. ?

print uc join' ',unpack'(H2)*',$x


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

Date: Wed, 03 Mar 2004 19:38:59 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Perl golf: printing data in hex
Message-Id: <40463423.3589160@news.erols.com>

Alexander.Farber@t-online.de (A. Farber) wrote:

: Given a binary string in $x, what would be the shortest way
: to print it out in hex, like: 3A BC DE FF 00 .. .. .. ?

    printf'%*v02X',$",$x

That was broken in 5.8.0, which upset me greatly.
It's fixed again in 5.8.2.



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

Date: Wed, 03 Mar 2004 16:10:34 +0000
From: Helgi Briem <HelgiBriem_1@hotmail.com>
Subject: Re: Removing accents from spanish characters
Message-Id: <rg0c4097e7hq9a3cml28b2rmpjgot0n7r5@4ax.com>

On Wed, 03 Mar 2004 15:59:34 GMT, "Jürgen Exner"
<jurgenex@hotmail.com> wrote:

>Duke of Hazard wrote:
>> If a user types in a spanish word with accents on some characters
>> (e.g. ~ on top of a), how can i remove just the accents and keep the
>> word?
>
>That's a contradiction in terms. If you change a letter then you have a
>different word or more likely no word.
>
>Or do you believe "in" and "ln" are the same word? After all "l" and "i" are
>the same character, just that the "l" does not have the funny dot on top?

It works fine in context, usually.  We often need to write Icelandic
words without all the special Icelandic letters (ÁáÐðÉéÍíÓóÚúÝýÞþÆæÖö,
I have no idea if you can read these or not).  It is quite 
understandable 99.9% of the time. 

I often need to use the following subroutine.  The OP can modify
it for his own purposes.

sub fix_Icelandic_letters
{
for (@_) 
	{ 
	tr/ÁÐÉÍÓÚÝÖáðéíóúýö/ADEIOUYOadeiouyo/; 
	s/Þ/Th/; 
	s/Æ/Ae/; 
	s/þ/th/; 
	s/æ/ae/;
	return $_;	
}
}


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

Date: 3 Mar 2004 12:02:07 -0800
From: faraz_hussain@yahoo.com (Duke of Hazard)
Subject: Re: Removing accents from spanish characters
Message-Id: <d5052c5d.0403031202.7cf1865c@posting.google.com>

Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message the word?
> 
> Why would you like to do that?


I have a searchable database of cities that is used by people from all
over the world. So some people may type Sao Paulo with or without the
accent and I want my search function to treat both queries the same.

Faraz


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

Date: Wed, 3 Mar 2004 20:10:06 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Removing accents from spanish characters
Message-Id: <c25e2u$n6$1@wisteria.csv.warwick.ac.uk>


faraz_hussain@yahoo.com (Duke of Hazard) wrote:
> If a user types in a spanish word with accents on some characters
> (e.g. ~ on top of a), how can i remove just the accents and keep the
> word?

With 5.8, you could try decomposing with Unicode::Normalize::NFD or NFKD
and then ditching all combining accent characters.

Ben

-- 
"The Earth is degenerating these days. Bribery and corruption abound.
Children no longer mind their parents, every man wants to write a book,
and it is evident that the end of the world is fast approaching."
     -Assyrian stone tablet, c.2800 BC                         ben@morrow.me.uk


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

Date: Wed, 03 Mar 2004 21:58:00 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Removing accents from spanish characters
Message-Id: <c25gpg$1pd7gv$1@ID-184292.news.uni-berlin.de>

Duke of Hazard wrote:
> Gunnar Hjalmarsson wrote:
>> Duke of Hazard wrote:
>>> If a user types in a spanish word with accents on some
>>> characters (e.g. ~ on top of a), how can i remove just the
>>> accents and keep the word?
>> 
>> Why would you like to do that?
> 
> I have a searchable database of cities that is used by people from
> all over the world. So some people may type Sao Paulo with or
> without the accent and I want my search function to treat both
> queries the same.

I see. Think I have seen a module that does that, but I'm not able to
find it now. Suppose the approach that Helgi suggested is sufficient.

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



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

Date: Wed, 3 Mar 2004 21:08:26 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Removing accents from spanish characters
Message-Id: <c25he8$436$1@news.simnet.is>

"Helgi Briem" <HelgiBriem_1@hotmail.com> wrote in message
news:rg0c4097e7hq9a3cml28b2rmpjgot0n7r5@4ax.com...
>
> sub fix_Icelandic_letters
> {
> for (@_)
>

> tr/ÁÐÉÍÓÚÝÖáðéíóúýö/ADEIOUYOadeiouyo/;
> s/Þ/Th/;
> s/Æ/Ae/;
> s/þ/th/;
> s/æ/ae/;
> return $_;
> }
> }

what's the deal with the return within the loop?
you realize this will just return the first argument (fixed),
so the loop has no real purpose, other than a fancy way
to do $_=$_[0]

gnari





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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 6210
***************************************


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