[18685] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 853 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 8 09:05:52 2001

Date: Tue, 8 May 2001 06:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <989327108-v10-i853@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 8 May 2001     Volume: 10 Number: 853

Today's topics:
        Date check on files <jeroen.vander.wijde@cleartrac.nl>
    Re: Date check on files <carvdawg@patriot.net>
    Re: Date check on files <fsonu@usa.net>
    Re: Disguising Perl scripts <jimbo@soundimages.co.uk>
    Re: Email Gurus - Help! <jimbo@soundimages.co.uk>
        file manipulations <giles.pepper@brunel.ac.uk>
    Re: file manipulations (Bernard El-Hagin)
    Re: file manipulations <bart.lateur@skynet.be>
    Re: Help on optimization wanted <iltzu@sci.invalid>
    Re: Help on optimization wanted <iltzu@sci.invalid>
    Re: Help on optimization wanted <bart.lateur@skynet.be>
    Re: how to set binary mode when uploading a file <mk@ticklets.com>
    Re: how to set binary mode when uploading a file (Villy Kruse)
        isapi in perl? <carlos@plant.student.utwente.nl>
    Re: Newbie: how can I shorten a repetitive regular expr <krahnj@acm.org>
    Re: PL/SQL and DBI. <mk@ticklets.com>
    Re: Prices for work? <b_nospam_ill.kemp@wire2.com>
        reading a redirected file via LWP::Simple <cobrasun@yahoo.de>
    Re: Removing attributes <birgit@watermans-welt.de>
    Re: reverse of perlcc (Martien Verbruggen)
    Re: sessions and closures <bart.lateur@skynet.be>
    Re: Sort String <tinamue@zedat.fu-berlin.de>
    Re: Sort String (Gwyn Judd)
    Re: Sort String <thomasvdv@yucom.be>
    Re: unicode support in perl 5.6 -- I'm trying to get it <eike.grote.extern@fmis.de>
    Re: UPPERCASE to "Sentence Case" (Eric Bohlman)
    Re: UPPERCASE to "Sentence Case" (Abigail)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 8 May 2001 11:03:55 +0200
From: "jeroen v.d. Wijden" <jeroen.vander.wijde@cleartrac.nl>
Subject: Date check on files
Message-Id: <9d8d1r$ihr$1@news1.xs4all.nl>

I'm a complete newbie to Perl. I want to create a way to check files for
dates, if one file is more recently edited or changed I want the older file
to be
overwritten by the other. Is there a way to do this in Perl??

Jeroen v.d. Wijden




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

Date: Tue, 08 May 2001 06:45:23 -0400
From: H C <carvdawg@patriot.net>
Subject: Re: Date check on files
Message-Id: <3AF7CE43.42978206@patriot.net>

Yes.  Use stat()

"jeroen v.d. Wijden" wrote:

> I'm a complete newbie to Perl. I want to create a way to check files for
> dates, if one file is more recently edited or changed I want the older file
> to be
> overwritten by the other. Is there a way to do this in Perl??
>
> Jeroen v.d. Wijden



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

Date: Tue, 8 May 2001 16:28:05 +0530
From: "sonu" <fsonu@usa.net>
Subject: Re: Date check on files
Message-Id: <989319196.63480@sj-nntpcache-5>

well..i'm not going to write the complete program..i'll give u an example
--------------------------
    use File::stat;

    use Time::localtime;

    $date_string = ctime(stat($file)->mtime);

    print "file $file updated at $date_string\n";

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

hope it works..


"jeroen v.d. Wijden" <jeroen.vander.wijde@cleartrac.nl> wrote in message
news:9d8d1r$ihr$1@news1.xs4all.nl...
> I'm a complete newbie to Perl. I want to create a way to check files for
> dates, if one file is more recently edited or changed I want the older
file
> to be
> overwritten by the other. Is there a way to do this in Perl??
>
> Jeroen v.d. Wijden
>
>




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

Date: Tue, 8 May 2001 10:47:58 +0100
From: "jimbo" <jimbo@soundimages.co.uk>
Subject: Re: Disguising Perl scripts
Message-Id: <3hPJ6.8673$4A4.37620@NewsReader>

> _fixes_ your program but makes it totally unrecogizable!  Yeesh, any of
you
> born in the south!?

Where's the south?

jimbo
;-)





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

Date: Tue, 8 May 2001 10:57:37 +0100
From: "jimbo" <jimbo@soundimages.co.uk>
Subject: Re: Email Gurus - Help!
Message-Id: <6qPJ6.8675$4A4.37786@NewsReader>

> I am creating a script for a client that needs a small ASCII file attached

ASCII as in 7 bit ASCII?  Or is 'small file' an 8 bit file?  If it is
7 bit just put it in the message.

> to an email message.  I am using Sendmail to generate the mail - no
problem
> there.  The host is AT&T and they dont have Mime::Lite or Mail::Sender

Well, you obviously have access to cgi-bin, just install the modules
you require locally, in your bin.  Add them to @INC and then you won't
need AT&T to do it for you.

############################################################################
#!/usr/bin/perl -w

BEGIN {
  use FindBin;
  push @INC, $Find::Bin;
}

use Mime::Lite;
use Mail::Sender;

< code goes here >
############################################################################

jimbo
;-)





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

Date: Tue, 8 May 2001 08:49:04 +0100
From: "gdp" <giles.pepper@brunel.ac.uk>
Subject: file manipulations
Message-Id: <9d881t$cfu$1@mimas.brunel.ac.uk>

Hi....

I have a directory (linux) with a hundred or so files.  Some of these
filenames contain spaces which I want to remove.  Can anyone give me a clue
as to how I would use a perl script to go through the directory and check
and rename if neccessary the file.  I have used a bit of perl for other
things but have not had experience of this sort of thing.  Any help
appreciated.
Regards

GDP




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

Date: Tue, 8 May 2001 08:26:40 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: file manipulations
Message-Id: <slrn9ffavr.tha.bernard.el-hagin@gdndev25.lido-tech>

On Tue, 8 May 2001 08:49:04 +0100, gdp <giles.pepper@brunel.ac.uk> wrote:
>Hi....
>
>I have a directory (linux) with a hundred or so files.  Some of these
>filenames contain spaces which I want to remove.  Can anyone give me a clue
>as to how I would use a perl script to go through the directory and check
>and rename if neccessary the file.  I have used a bit of perl for other
>things but have not had experience of this sort of thing.  Any help
>appreciated.

You'll need to:

1. open the directory to read it:

perldoc -f opendir

2. read it to get the filenames:

perldoc -f readdir

3. loop through the filenames (I assume you know how to do that)

4. remove any spaces in the filenames:

perldoc perlop (look for the tr/// operator)

5. rename the files which contain spaces:

perldoc -f rename

Try to come up with a script which uses the above and if it doesn't
work post it and someone will help you fix it.

Cheers,
Bernard


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

Date: Tue, 08 May 2001 08:46:25 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: file manipulations
Message-Id: <8hcfftg4bnbuittqu920aiepmfqj7compk@4ax.com>

gdp wrote:

>I have a directory (linux) with a hundred or so files.  Some of these
>filenames contain spaces which I want to remove.  Can anyone give me a clue
>as to how I would use a perl script to go through the directory and check
>and rename if neccessary the file.  I have used a bit of perl for other
>things but have not had experience of this sort of thing.  Any help
>appreciated.

Using File::Find is a good start. Oh, here it comes. Pass the
directories as a command line argument, or it will work in/under the
current directory.

	use File::Find;
	@ARGV or @ARGV = '.';
	find sub {
	    if((my $new = $_) =~ tr/ /_/) {
	        rename $_, $new;
	    }
	}, @ARGV;
	
-- 
	Bart.


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

Date: 8 May 2001 08:18:17 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Help on optimization wanted
Message-Id: <989308145.18592@itz.pp.sci.fi>

In article <3b08bde8.36812763@news.bjoern.hoehrmann.de>, Bjoern Hoehrmann wrote:
>* Michael Ströck wrote in comp.lang.perl.misc:
>>I don't really understand the following however:
>>> my @sieve = (0, 0, (1) x ($max - 1));
>>                                       ^
>>Could you (somebody) explain that syntax ? Especially
>>the "x" and the 1 in parens.
>
>See `perldoc perlop`/"Multiplicative Operators" for the 'x' (repetition
>operator). Parens create lists in Perl

Actually they don't, except in a few special cases:

 * Parens before "=" force list assignment:

       ($one, $two, $three) = 1 .. 3;

       @one_to_ten = 1 .. 10;

       ($seven) = 7 .. 1024;

 * Parens before "x" force list repetition:

       $foofoofoo = "foo" x 3;

       @foo_foo_foo = ("foo") x 3;
       @a_b_a_b_a_b = ("a", "b") x 3;

       @abab_abab = ("ab" x 2) x 2;

However, they do get used a lot in creating lists, since without them
most Perl operators, including "=" and "x", bind tighter than the comma.
Therefore the special behavior shown above only becomes noticeable when
you want to repeat or assign to a list with only one scalar in it.

    $size = @list;                      # no parens: scalar assignment 
    ($first_element) = @list;           # magic parens: list assignment
    ($first, $second, $third) = @list;  # parens required anyway..

Note that if you try to use a list repeat in scalar context, you end up
tickling a bug in current perls:

    print join "_", scalar((1, 2, 3) x 4);   # prints: "1_2_3333"

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla / Kira -- do not feed the troll.


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

Date: 8 May 2001 08:27:18 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Help on optimization wanted
Message-Id: <989310037.21444@itz.pp.sci.fi>

In article <slrn9fckpe.11o.tjla@thislove.dyndns.org>, Gwyn Judd wrote:
>"mein Luftkissenfahrzeug ist voll von den Aalen"
>said Abigail (abigail@foad.org) in 
><slrn9fbi29.ti0.abigail@tsathoggua.rlyeh.net>:
>
>>I would expect a compiler to be smart enough to know both expressions
>>are equivalent, and to do whatever is the fastest on the platform it
>>runs on.
>
>I would expect that would be nice. However, even with "use integer", $_
>* $_ is faster than $_ ** 2.

So it indeed seems to be.  Surprisingly, however, sqrt($_) seems to be
about equally fast as $_ * $_.

Of course, the difference is irrelevant anyway, and only worth looking
into for the sake of idle curiosity.

#!/usr/bin/perl -w
use strict;
use Benchmark;

timethese shift,
  { '*'  => 'my @a = grep $_ == $_*$_, 0 .. 1024;', 
    '**' => 'my @a = grep $_ == $_**2, 0 .. 1024;', 
    sqrt => 'my @a = grep sqrt($_) == $_, 0 .. 1024;',
  };

__END__

Benchmark: running *, **, sqrt, each for at least 10 CPU seconds...
         *: 10 wallclock secs (10.01 usr +  0.00 sys = 10.01 CPU) @ 548.45/s (n=5490)
        **: 11 wallclock secs (10.22 usr +  0.00 sys = 10.22 CPU) @ 397.46/s (n=4062)
      sqrt: 11 wallclock secs (10.04 usr +  0.00 sys = 10.04 CPU) @ 548.21/s (n=5504)

Benchmark: timing 4096 iterations of *, **, sqrt...
         *:  7 wallclock secs ( 7.70 usr +  0.00 sys =  7.70 CPU)
        **: 11 wallclock secs (10.44 usr +  0.00 sys = 10.44 CPU)
      sqrt:  9 wallclock secs ( 7.58 usr +  0.00 sys =  7.58 CPU)

This is perl, version 5.005_03 built for i386-linux

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla / Kira -- do not feed the troll.


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

Date: Tue, 08 May 2001 08:38:52 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Help on optimization wanted
Message-Id: <d2cfft4fskdf65sltra9vqis440qoue09s@4ax.com>

Ilmari Karonen wrote:

>>I would expect that would be nice. However, even with "use integer", $_
>>* $_ is faster than $_ ** 2.
>
>So it indeed seems to be.  Surprisingly, however, sqrt($_) seems to be
>about equally fast as $_ * $_.

Key phrase: "mathematical coprocessor". I think that $_ ** 2 does the
traditional route of taking the log() of $_, multiply by 2, and take the
exp() of that result. Both log() and exp() are slow calculations.

-- 
	Bart.


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

Date: Tue, 8 May 2001 11:00:45 +0200
From: "Paul Kersey" <mk@ticklets.com>
Subject: Re: how to set binary mode when uploading a file
Message-Id: <9d8cpf$i2v$1@news1.xs4all.nl>

open(OUTFILE,">pics\\photo.jpg")
binmode(OUTFILE);
while ($bytesread=read($fileH1,$buffer,1024)) {
  print OUTFILE $buffer:
}

This should do the trick for you.




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

Date: 8 May 2001 11:31:57 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: how to set binary mode when uploading a file
Message-Id: <slrn9ffm9d.o06.vek@pharmnl.ohout.pharmapartners.nl>

On Tue, 8 May 2001 11:00:45 +0200, Paul Kersey <mk@ticklets.com> wrote:
>open(OUTFILE,">pics\\photo.jpg")
>binmode(OUTFILE);
>while ($bytesread=read($fileH1,$buffer,1024)) {
>  print OUTFILE $buffer:
>}
>
>This should do the trick for you.
>
>


Might also need to set binmode on the input file as well.



Villy


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

Date: Tue, 8 May 2001 12:07:09 +0200
From: "carlos" <carlos@plant.student.utwente.nl>
Subject: isapi in perl?
Message-Id: <9d8g9c$crp$1@dinkel.civ.utwente.nl>

does anyone know how to compile al perl script to an isapi .dll ?


carlos




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

Date: Tue, 08 May 2001 07:21:07 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Newbie: how can I shorten a repetitive regular expression?
Message-Id: <3AF79E1F.6569B6E2@acm.org>

David Wake wrote:
> 
> It seems as if there must be some way of shortening code like this.
> Can anyone help?
> 
>     if ( m{CONTACT\sINFORMATION\s+
>                   Name:\s+
>                   (\w[\w\s]+?)\s+     #name
>                   City:\s+
>                   (\w[\w\s]+?)\s+     #city
>                   State:\s+
>                   (\w[\w\s]+?)\s+     #state
>                   Zip\sCode:\s+
>                   (\w[\w\s]+?)\s+     #zip
>                   }sx ){
>     print "Name = $1 \n" ;
>     print "City = $2 \n" ;
>     print "State = $3 \n" ;
>     print "Zip = $4 \n" ;
> }

    if ( /CONTACT\sINFORMATION\s+
                  Name:\s+
                  (\S.*\S)\s+     #name
                  City:\s+
                  (\S.*\S)\s+     #city
                  State:\s+
                  (\S.*\S)\s+     #state
                  Zip\sCode:\s+
                  (\S.*\S)\s+     #zip
                  /x ){


John
-- 
use Perl;
program
fulfillment


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

Date: Tue, 8 May 2001 10:30:18 +0200
From: "Paul Kersey" <mk@ticklets.com>
Subject: Re: PL/SQL and DBI.
Message-Id: <9d8b0c$dk5$1@news1.xs4all.nl>

> > Does anybody have experience on using DBI with
> > oracle Pl/SQL?Please give me an example. What should I do if I want to
> pass
> > in one variable to PL/SQL and get a returned recordset?
> > Thanks!
>
> Isn't the whole point of DBI (Independant) that the database doesn't
matter?
> Or did I miss the point of the question?

Yes you did, pl/sql is a program language inside the Oracle database. You
can write procedures in there, which you can execute with certain input and
output variables, so it's a little bit different (but not much) than regular
sql expressions. I don't think you can return a recordset with pl/sql, just
values.

Here is an example:
# Perl code:
use DBI;
my $dsn = 'dbi:Oracle:DATABASE_NAME';
my $dbh = DBI->connect($dsn,'user','password',{LongReadLen=>65535,
LongTruncOk=>1});
my $csr = $dbh->prepare(q{
  BEGIN
   package_name.procedure_name(:i_param, :o_value, :o_err_str);
  END;
 });
my $i_param = 10;
my $o_param;
$csr->bind_param(":i_param", $i_param);
$csr->bind_param_inout(":o_value", \$o_param, 2000); #2000 is the maximum
length of o_param returned by the procedure
my $err_str;
$csr->bind_param_inout(":o_err_str", \$err_str, 256);
$csr->execute;
$csr->finish;

#pl/sql code:
# package specification
CREATE OR REPLACE PACKAGE package_name
IS
 PROCEDURE procedure_name(i_param IN NUMBER
      ,o_param IN OUT VARCHAR2
      ,o_err_str IN OUT VARCHAR2
 );
END package_name;
/

# package body
CREATE OR REPLACE PACKAGE BODY package_name
IS
 PROCEDURE procedure_name(i_param IN NUMBER
      ,o_param IN OUT VARCHAR2
      ,o_err_str IN OUT VARCHAR2
      )
 IS
  cursor c_table(rec_id number) is select id from table_name where id =
rec_id;
 BEGIN
  for rij in c_table(i_param)
  loop
    o_param := rij.id;
  end loop;
 EXCEPTION
   when others then
  o_err_str := sqlerrm;
 END;
END package_name;
/





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

Date: Tue, 8 May 2001 12:10:57 +0100
From: "W K" <b_nospam_ill.kemp@wire2.com>
Subject: Re: Prices for work?
Message-Id: <989320279.4738.0.nnrp-14.c3ad6974@news.demon.co.uk>

>company, never outside.  I hear crazy rumors of people paying 50k for a


I hear crazy rumours that this newsgroup is international and that people
around the world use it.

My point being - you seem to assume everything is in the USA ( although I am
only assuming this- you didn't say which country you were talking about
$_="USA" ?? )




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

Date: Tue, 8 May 2001 10:51:30 +0200
From: "Chris" <cobrasun@yahoo.de>
Subject: reading a redirected file via LWP::Simple
Message-Id: <9d8c2f$qos$1@news1.wdf.sap-ag.de>

With my perl script I want to read a file (for instance a picture) from the
web using LWP::Simple
But the url (of the file to be read) is dynamically directed somewhere else
(depending on other conditions).

How can I nevertheless read the desired file ?

cheers
Chris




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

Date: Tue, 08 May 2001 13:23:36 +0200
From: Birgit Hans <birgit@watermans-welt.de>
Subject: Re: Removing attributes
Message-Id: <3AF7D738.A448DC3E@watermans-welt.de>

Hi,

LDAP is a kind of database.
Entries can only updated all-or-nothing.
It's quite simple:
The attribute that you want to remove must not be mandatory.
Then get the whole entry and update it without the unwanted attribute.

I think, that's the right way.

Greetings
Birgit

Philippe Hamel wrote:

> Hi,
>
> I'm trying to delete attributes from an LDAP entry using perl and associated
> modules.  I've figured out how to remove whole entries, but if I just want
> to delete attributes from an entry, how do I do that?
>
> Thank you!
>
> --
> Philippe Hamel
> Bureau :
> Courriel : phamel@logisil.com
> Maison :
> Courriel : philippe.hamel@apiiq.qc.ca



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

Date: Tue, 8 May 2001 22:02:11 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: reverse of perlcc
Message-Id: <slrn9ffo23.v5e.mgjv@martien.heliotrope.home>

On Sat, 05 May 2001 01:24:16 GMT,
	flash <bop@mypad.com> wrote:
> is there a ccperl or something.
> 
> i need a way to convert c code to perl, can it be done?

It's called a programmer.

But you could consider using Inline::C to put C code straight in your
Perl program.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd.   | enough features yet.
NSW, Australia                  | 


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

Date: Tue, 08 May 2001 07:27:32 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: sessions and closures
Message-Id: <mp7fftgcr1b9tb927aj2151t2gabh1h6r5@4ax.com>

Dave Bailey wrote:

>That the author of the Yahoo store 
>builder chose to store session state in closures generated by Lisp
>macros is certainly unique, clever and different, but is it better than
>adding and/or updating a row in a table of a relational database, for
>example?  Graham's article was not convincing in this respect, in no
>small part because it had to be so vague.  

I think that the closure approach is more flexible. I can imagine that
with an elaborate site, the "state" becomes something really huge. Your
approach looks like it would need a giant "switch case" approach. I
mean, really really big. Closures could be more lightweight.

One could generate perl source as text, not as a closure, and convert
the data to text with Data::Dumper.

Or perhaps, as F. Xavier Noria wrote, FastCGI can be used to actually
keep the closures in memory. I don't know FastCGI that well enough. But
then you'd be limited to relatively small websites, IMO. Not just one
server, but not too many visitors at once, too.

-- 
	Bart.


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

Date: 8 May 2001 09:50:01 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: Sort String
Message-Id: <9d8fg9$gvquo$1@fu-berlin.de>

John W. Krahn <krahnj@acm.org> wrote:
> Tina Mueller wrote:
>> 
>> yep =)
>> (my code is a little bit longer, but faster ;-)

> Except for the fact that his returns a scalar and yours returns a list.

okay, forgot that. here's the right one:

11:44am tina@lux:tina 670> perl -e'$s="abracadeba";
sub tina {return join "",sort unpack ("A2"x((length $s)/2), $s);}
sub juergen {return join "", sort ($_, split /(..)/, $s)}
use Benchmark;                    
timethese($ARGV[0], {tina=>\&tina, juergen=>\&juergen});
' 50000
Benchmark: timing 50000 iterations of juergen, tina...
juergen: 3 wallclock secs ( 3.21 usr +  0.00 sys =  3.21 CPU) @ 15576.32/s
   tina: 1 wallclock secs ( 1.70 usr +  0.00 sys =  1.70 CPU) @ 29411.76/s

regards,
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: Tue, 08 May 2001 11:13:28 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Sort String
Message-Id: <slrn9ffl6f.ggi.tjla@thislove.dyndns.org>

"mein Luftkissenfahrzeug ist voll von den Aalen"
said Craig Berry (cberry@cinenet.net) in 
<tfebeclkjoaj35@corp.supernews.com>:
>Jürgen Exner (juex@deja.com) wrote:
>:     $sorted = join '', sort grep($_, split /(..)/, $original);
>: 
>: Anyone wants to play golf on this?
>
>  $sorted=join'',sort$original=~/../g;

Well, I can't beat that, but:

   $sorted="@{[sort$original=~/../g]}";

is better, if you nead a space between the pairs :)

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Martin was probably ripping them off.  That's some family, isn't it?
Incest, prostitution, fanaticism, software.
		-- Charles Willeford, "Miami Blues"


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

Date: Tue, 8 May 2001 08:57:09 -0400
From: Thomas Van de Velde <thomasvdv@yucom.be>
Subject: Re: Sort String
Message-Id: <3af7ee01$1@addressworks2.umassd.edu>

Great work Tina!  Thanks.

Tina Mueller wrote:

> John W. Krahn <krahnj@acm.org> wrote:
>> Tina Mueller wrote:
>>> 
>>> yep =)
>>> (my code is a little bit longer, but faster ;-)
> 
>> Except for the fact that his returns a scalar and yours returns a list.
> 
> okay, forgot that. here's the right one:
> 
> 11:44am tina@lux:tina 670> perl -e'$s="abracadeba";
> sub tina {return join "",sort unpack ("A2"x((length $s)/2), $s);}
> sub juergen {return join "", sort ($_, split /(..)/, $s)}
> use Benchmark;
> timethese($ARGV[0], {tina=>\&tina, juergen=>\&juergen});
> ' 50000
> Benchmark: timing 50000 iterations of juergen, tina...
> juergen: 3 wallclock secs ( 3.21 usr +  0.00 sys =  3.21 CPU) @ 15576.32/s
>    tina: 1 wallclock secs ( 1.70 usr +  0.00 sys =  1.70 CPU) @ 29411.76/s
> 
> regards,
> tina
> 



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

Date: Tue, 08 May 2001 09:56:15 +0200
From: Eike Grote <eike.grote.extern@fmis.de>
Subject: Re: unicode support in perl 5.6 -- I'm trying to get it to work l
Message-Id: <3AF7A69E.AE5CA0CB@fmis.de>

Hi,

"Resnick, David" wrote:
> 
> [... my original question about why isalpha wasn't working on unicode ...]
> 
> >You must use the "properties"  \p{IsAlpha}, \p{IsDigit}, and
> >\p{IsPrint} for regexes (unfortunately this method produces
> >error messages for certain characters...):
> 
> >    ### method (1)
> >    $alpha++ if ($letter =~ /\p{IsAlpha}/);
> >    $digit++ if ($letter =~ /\p{IsDigit}/);
> >    $print++ if ($letter =~ /\p{IsPrint}/);
> 
> When I tried the things suggested (which seem like the right idea),
> I get errors as follows:
> Malformed UTF-8 character at /u/dresnick/bin/utf8-test-summary line 22
> 
> These occur if $letter is obtained by chr($i) when $i is between
> 0x80 and OxFF.  Are these being interpreted as Latin-1 or something?
> Did you not see these warnings (was your perl invoked with a -w?)?

That`s what I meant with "error messages for certain characters"
above (it's independent of the `-w` flag).

I'm no expert in Unicode, but it seems that Perl's implementation
of it is _rather_ buggy... the following little test including the
problematic characters gives another very strange result (at least
IMHO):

  use utf8;

  @c = (chr(0x00e0), chr(0x00e1), chr(0xddc0));

  print join("",@c[0,1]),"\n";
  print join("",@c[0,2]),"\n";

Output:

  àá
  Ã  í·

(In case the data is scrambled by the mail program: the first
two characters by themselves are printed fine, but as soon as I
add "0xddc0" the output is completely different to the case
without "0xddc0" at the end.)



Eike
-- 
Eike Grote, ConSol GmbH

E-Mail: eike.grote@epost.de


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

Date: 8 May 2001 07:46:59 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: UPPERCASE to "Sentence Case"
Message-Id: <9d889j$bc6$2@bob.news.rcn.net>

Abigail <abigail@foad.org> wrote:

> Granted, anything a bit more complicated than a regex or two is beyond the
> capabilities of the far majority of the Perl programmers; but that doesn't
> mean one cannot write an algorithm that is almost all the time right.

Based on the definition of "algorithm" that I learned (a process that 
is guaranteed to solve a problem in a finite number of steps), "algorithm 
that is almost all the time right" is like "not very pregnant."  I think 
you mean "write a really good heuristic."



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

Date: Tue, 8 May 2001 09:07:28 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: UPPERCASE to "Sentence Case"
Message-Id: <slrn9ffdqg.ifu.abigail@tsathoggua.rlyeh.net>

Eric Bohlman (ebohlman@omsdev.com) wrote on MMDCCCVII September MCMXCIII
in <URL:news:9d889j$bc6$2@bob.news.rcn.net>:
:)  Abigail <abigail@foad.org> wrote:
:)  
:) > Granted, anything a bit more complicated than a regex or two is beyond the
:) > capabilities of the far majority of the Perl programmers; but that doesn't
:) > mean one cannot write an algorithm that is almost all the time right.
:)  
:)  Based on the definition of "algorithm" that I learned (a process that 
:)  is guaranteed to solve a problem in a finite number of steps), "algorithm 
:)  that is almost all the time right" is like "not very pregnant."  I think 
:)  you mean "write a really good heuristic."


A heuristic is implemented with an algorithm. Sure, if the problem is
"find all ends of sentences, and nothing else", the algorithm doesn't
solve the problem. If the problem is "find ends of sentences often enough,
limiting the number of false positives, such that the user doesn't have
to correct too often", the algorithm works.


Abigail
-- 
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print 
               qq{Just Another Perl Hacker\n}}}}}}}}}'    |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w


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

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


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