[23512] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5721 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 28 18:05:55 2003

Date: Tue, 28 Oct 2003 15:05:10 -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           Tue, 28 Oct 2003     Volume: 10 Number: 5721

Today's topics:
        building a e-commerce site <_nospam_stigerikson@yahoo.se>
    Re: building a e-commerce site <nospam@bigpond.com>
    Re: Checkbox -  database checkbox, if checked gives val <usenet@morrow.me.uk>
    Re: Checkbox -  database checkbox, if checked gives val (Tad McClellan)
    Re: Checkbox -  database checkbox, if checked gives val <jwillmore@remove.adelphia.net>
        Finding out if a string has a trailing slash <stanb@panix.com>
    Re: Finding out if a string has a trailing slash <usenet@morrow.me.uk>
    Re: Finding out if a string has a trailing slash <noreply@gunnar.cc>
    Re: Finding out if a string has a trailing slash (Tad McClellan)
    Re: How to generate this list? (David Combs)
    Re: Perl and IIS - script runs but 'The page cannot be  <jgibson@mail.arc.nasa.gov>
    Re: Perl and IIS - script runs but 'The page cannot be  <asu1@c-o-r-n-e-l-l.edu>
    Re: Problem With DBI - fetchrow_array ctcgag@hotmail.com
    Re: regex for stripping HTML <noreply@gunnar.cc>
    Re: regex for stripping HTML <perl@my-header.org>
    Re: regex for stripping HTML <usenet@morrow.me.uk>
    Re: Rookie: Constructing a large SQL INSERT statement ctcgag@hotmail.com
    Re: Singleton process <tassilo.parseval@rwth-aachen.de>
    Re: Singleton process <bart.lateur@pandora.be>
    Re: strange effect with [:lower:] in perl <usenet@morrow.me.uk>
    Re: strange effect with [:lower:] in perl <abigail@abigail.nl>
    Re: strange effect with [:lower:] in perl <flavell@ph.gla.ac.uk>
    Re: strange effect with [:lower:] in perl <usenet@morrow.me.uk>
        system() rc hosed? <ggershSNACK@CAKEctc.net>
    Re: system() rc hosed? (Gary E. Ansok)
    Re: system() rc hosed? <ggershSNACK@CAKEctc.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 28 Oct 2003 22:59:05 +0100
From: stig <_nospam_stigerikson@yahoo.se>
Subject: building a e-commerce site
Message-Id: <bnmos4$3en$1@oden.abc.se>

hi
i am going to be part of building a e-commerce website, for this we 
think that perl might be the choice of language, mainly because we have 
experience from it. we have build smaller e-commerce sites, but this 
will be considerably larger.

where should i begin to look to get answers to the following questions?
1. modeling techniques, code re-use.
2. presentation layer (html), how to build it fast and good, and then 
how to connect it well to the underlaying perl-scripts?
3. is perl a good choice at all, if not, why and what should we look for?


also, are there any open-source web-shops that one can begin from, and 
where can they be found?

any particular book recommended?

thanks in advance
stig



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

Date: Wed, 29 Oct 2003 08:07:58 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: building a e-commerce site
Message-Id: <5674945.P0cDvTL6gg@gregs-web-hosting-and-pickle-farming>

It was a dark and stormy night, and stig managed to scribble:

> hi
> i am going to be part of building a e-commerce website, for this we
> think that perl might be the choice of language, mainly because we have
> experience from it. we have build smaller e-commerce sites, but this
> will be considerably larger.
> 
> where should i begin to look to get answers to the following questions?
> 1. modeling techniques, code re-use.
> 2. presentation layer (html), how to build it fast and good, and then
> how to connect it well to the underlaying perl-scripts?
> 3. is perl a good choice at all, if not, why and what should we look for?
> 

See http://oscommerce.com/ for an open source PHP solution.

gtoomey


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

Date: Tue, 28 Oct 2003 19:14:53 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Checkbox -  database checkbox, if checked gives value of 1 .. how to sum ?
Message-Id: <bnmf7d$isk$1@wisteria.csv.warwick.ac.uk>

searsdvdtech@yahoo.com (randy) wrote:
> Checkbox - field in database is defined as checkbox, name of field
> "comp" , if checked gives value of 1 .. how to get the sum these
> checked checkbox values. see page at
> http://baseportal.com/cgi-bin/baseportal.pl?htx=/searsdvdtech/testforperl.
> 
> here is the code i used
> 
> <do action=all>
> 
> <loop db=testforperl=perl>
> $sum+=$_loop{"comp"};
> </loop>
> 
>  this does not work ... any suggestions...thanks

Try posting a complete minimal example, what you expected it to do,
and what it in fact does. What you have posted appears to be a mixture
of some sort of XML and Perl; in any case, we can tell nothing from
it.

Also try using complete sentences: it make you much easier to
understand.

Ben

-- 
Like all men in Babylon I have been a proconsul; like all, a slave ... During
one lunar year, I have been declared invisible; I shrieked and was not heard,
I stole my bread and was not decapitated.
~ ben@morrow.me.uk ~                   Jorge Luis Borges, 'The Babylon Lottery'


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

Date: Tue, 28 Oct 2003 16:03:35 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Checkbox -  database checkbox, if checked gives value of 1 .. how to sum ?
Message-Id: <slrnbptptn.dv7.tadmc@magna.augustmail.com>

randy <searsdvdtech@yahoo.com> wrote:

> here is the code i used
> 
><do action=all>
> 
><loop db=testforperl=perl>
> $sum+=$_loop{"comp"};
></loop>
> 
>  this does not work ... any suggestions


Yes, post to a newsgroup having to do with whatever language 
you are using.

This newsgroup has to do with the Perl programming language,
and what you posted is not Perl.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Tue, 28 Oct 2003 21:45:23 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Checkbox -  database checkbox, if checked gives value of 1 .. how to sum ?
Message-Id: <20031028164522.38b94457.jwillmore@remove.adelphia.net>

On 28 Oct 2003 10:25:26 -0800
searsdvdtech@yahoo.com (randy) wrote:

> Checkbox - field in database is defined as checkbox, name of field
> "comp" , if checked gives value of 1 .. how to get the sum these
> checked checkbox values. see page at
> http://baseportal.com/cgi-bin/baseportal.pl?htx=/searsdvdtech/testforperl.
> 
> here is the code i used
> 
> <do action=all>
> 
> <loop db=testforperl=perl>
> $sum+=$_loop{"comp"};
> </loop>
> 
>  this does not work ... any suggestions...thanks

Is this an application that _you_ wrote, or downloaded from the 'Net.

If it's one you downloaded - **contact the author**.

If this is a script/application _you_ wrote, please be a little more
specific.  Is what you posted pesudo-code or what?

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
Goldenstern's Rules:  (1) Always hire a rich attorney  (2) Never 
buy from a rich salesman. 


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

Date: Tue, 28 Oct 2003 20:23:28 +0000 (UTC)
From: Stan Brown <stanb@panix.com>
Subject: Finding out if a string has a trailing slash
Message-Id: <bnmj80$2kq$1@reader2.panix.com>

I need to check a user suplied string to see if it has a trailing slash, or
not.

I tried seomthing like:

    if( $dirname =~ m/\/$/ )


But that's not working. What am I doing wrong?

-- 
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
						-- Benjamin Franklin


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

Date: Tue, 28 Oct 2003 20:34:18 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Finding out if a string has a trailing slash
Message-Id: <bnmjsa$kpl$1@wisteria.csv.warwick.ac.uk>

Stan Brown <stanb@panix.com> wrote:
> I need to check a user suplied string to see if it has a trailing slash, or
> not.
> 
> I tried seomthing like:
> 
>     if( $dirname =~ m/\/$/ )

You want to use m|/$| or so, here, to avoid Leaning Toothpick
Syndrome. That's the whole point of Perl's choose-your-own-quotes.

> But that's not working. What am I doing wrong?

Worksforme:

  % perl -le'print ("foo/" =~ m/\/$/)'
  1
  %

What else does your script say, and what is it doing that you consider
it to be 'not working'?

Ben

-- 
I've seen things you people wouldn't believe: attack ships on fire off the
shoulder of Orion; I've watched C-beams glitter in the darkness near the
Tannhauser Gate. All these moments will be lost, in time, like tears in rain.
Time to die.  |-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-|  ben@morrow.me.uk


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

Date: Tue, 28 Oct 2003 21:37:17 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Finding out if a string has a trailing slash
Message-Id: <bnmk8v$13kigd$1@ID-184292.news.uni-berlin.de>

Stan Brown wrote:
> I need to check a user suplied string to see if it has a trailing
> slash, or not.
> 
> I tried seomthing like:
> 
>     if( $dirname =~ m/\/$/ )
> 
> But that's not working.

It works fine for me. What makes you say it's "not working"?

> What am I doing wrong?

How would we know? If you post the code you tried, what you expect it
to do, and what it actually does, somebody here may be able to tell
you what's wrong with it.

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



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

Date: Tue, 28 Oct 2003 16:00:16 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Finding out if a string has a trailing slash
Message-Id: <slrnbptpng.dv7.tadmc@magna.augustmail.com>

Stan Brown <stanb@panix.com> wrote:
> I need to check a user suplied string to see if it has a trailing slash, or
> not.
> 
> I tried seomthing like:
> 
>     if( $dirname =~ m/\/$/ )
> 
> 
> But that's not working. 


Yes it is.

-------------------
#!/usr/bin/perl
use strict;
use warnings;

my $dirname = 'foobar/';
if( $dirname =~ m/\/$/ ) {
   print "matched\n";
}
-------------------


Works for me.


>What am I doing wrong?


Not providing a short and complete program that we can run, as
suggested in the Posting Guidelines that are posted here twice
each week, and as suggested directly to you in previous followups.

Are you trying for your own personal scorefile entry?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Tue, 28 Oct 2003 21:54:39 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: How to generate this list?
Message-Id: <bnmoiv$557$1@reader2.panix.com>

In article <bnk730$etn@dispatch.concentric.net>,
James E Keenan <nospam_for_jkeen@concentric.net> wrote:
>
>"David Combs" <dkcombs@panix.com> wrote in message
>news:bnjig5$4lj$1@reader1.panix.com...
>> [snip]
>> Now this, for John, Abigail, MJD, etc:
>>
>>    "YOUR TASK, MR. PHELPS, IS TO PROGRAM THAT CSH ALGORITHM"
>>
>> How about an efficient algorithm on doing that?
>>
>Hey, David, instead of always asking these guys to write some Perl, why
>don't *you* do that?

If I knew how, I'd have done it a long time ago.

The recursions, the several levels and "directions"
of them, quickly overwhelmed my weak brain.

Heck, I couldn't even write down how I'd do
it *by hand*, that expansion.

Heck, I've never been able to figure out how
to generate simple one-level "combinations", 
except maybe by representing it by a bit-pattern,
and brute-force generate via for-loop all the
integers 1..<num-items>, converting that to
binary, and outputting whatever's got a 1-bit.

DFS trees I can do, likewise BFS, but applying
it to the csh-curly-bracket-generator-problem,
nested and all -- too much to hold in my head.

Sorry.

David



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

Date: Tue, 28 Oct 2003 12:33:12 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Perl and IIS - script runs but 'The page cannot be displayed'
Message-Id: <281020031233124029%jgibson@mail.arc.nasa.gov>

In article <2b68957a.0310271758.375dd4ee@posting.google.com>, stew dean
<stewart@webslave.dircon.co.uk> wrote:

> Jim Gibson <jgibson@mail.arc.nasa.gov> wrote in message
> news:<271020031056574181%jgibson@mail.arc.nasa.gov>...
> > In article <2b68957a.0310241707.3ad7fc65@posting.google.com>, stew dean
> > <stewart@webslave.dircon.co.uk> wrote:
> > [snip]


> 
> I really don't want to be flicking between command line and browser. I
> know others don't understand this but all I want to do is run my
> script without having to pass a lot of arguments using the command
> line. Now maybe there's a way to emulate one script talking to
> another. I personaly don't want to have to remember a string of 10
> arguments (that's where I'm upto).

Here is one more suggestion, one that I use in almost all of my
programming work: put in one simple command-line option, which I
usually call "-t". In my program, if that option is set, I set all of
the variables that I need to execute this program in a test mode. For
CGI, that means setting environment variables such as QUERY_STRING,
PATH, and even HTTP_COOKIE -- whatever it takes to run my CGI script
from the command line. All I have to remember to type is "script -t".
> 
> I want all the errors to show up in my browser or in an error log.
> That's all I want now. I've been trying different solutions and so far
> nothing has worked.
> 
> There's so many bits I'm not sure about - like does the STDERR include
> everything you would see on the command line? Where does the STDERR go
> and when is it written to? Is there a missing error log I can't see.

STDOUT and STDERR are out of your control when your script is executed
by a web server. I have used Apache under linux for most of my CGI
development work. STDOUT goes to the HTTP page served up by the server
and interpreted by the browser. STDERR, on the other hand, is
fortunately captured by the Apache web server and written to an error
log file. For my system, the error log is in /var/log/httpd/error, or
something like that. I just open a shell window and "tail -f
/var/log/httpd/error" in that window and I get to see all of the output
written to the server's error log from STDERR from my program. That is
one of the many things you can do if you have access to a shell and a
command line prompt.

However, the location of a web server error log is really off topic for
clpm. If you are using IIS, you should post your questions to some
other newsgroup. My news server lists about 40 groups dealing with
'iis'.

> 
> Thanks for taking the time to respond, it is appreciated.
> 
> Stew Dean


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

Date: 28 Oct 2003 21:46:09 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Perl and IIS - script runs but 'The page cannot be displayed'
Message-Id: <Xns9422AA960A1C4asu1cornelledu@132.236.56.8>

stewart@webslave.dircon.co.uk (stew dean) wrote in
news:2b68957a.0310241707.3ad7fc65@posting.google.com: 

> Juding from some responces I've got (some have been downright nasty)
> this may be better in the cgi group but cheers anyway.
> 
> Stew Dean

Everyone who has responded to you has been way more polite than your 'I'm 
not going to lift a finger to help you help me solve my problem' attitude 
deserved.


-- 
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov


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

Date: 28 Oct 2003 22:02:09 GMT
From: ctcgag@hotmail.com
Subject: Re: Problem With DBI - fetchrow_array
Message-Id: <20031028170209.263$Kz@newsreader.com>

"Pisinho" <linux@fol.it> wrote:

> I have thi script, but when I invoke this sub query i have the error:
>
> DBD::mysql::st fetchrow_array failed:fetch() without execute() at
> database.pl line 16, <FILE> line 42
>
> sub init_db {
>   my $dsn =
> "DBI:$database_driver:database=$database_name;host=$database_host;port=$d
> ata base_port";
>   $db = DBI->connect($dsn,$database_user,$database_password) or
> return(0); }
>
> sub query {
>   my $query = shift;
>   $handle = $db->prepare($query) or return(0);
>   $handle->execute;
>   @row = $handle->fetchrow_array;      #  LINE 16
>   if ($handle->rows < 1) {
>     @row = ("");
>   }
>   $handle->finish;
>   return @row;
> }
>
> Where is the problem?

Using my PSI::ESP module, I've determined that your problem is that
you used the "query" function to execute a statement which does not
require fetching, such as an insert, delete, or update.

I've never understood the burning desire that some people have to take
an absolutely adequate abstraction, the interface that DBI provides for
you, and wrapping it in some half-assed buggy abstraction of their own
creation.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Tue, 28 Oct 2003 20:09:25 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: regex for stripping HTML
Message-Id: <bnmf40$13898c$1@ID-184292.news.uni-berlin.de>

[not sent to the defunct newsgroup comp.lang.perl]

"Michael Vilain " wrote:
> I found this regex in this group:
> 
>    $value =~ s/\<[^\<]+\>//g;

Then you had some bad luck. ;-)

This makes sense under certain conditions:

     $value =~ s/<[^>]*>//g;

But normally you are recommended to use a module instead for parsing
HTML markup.

> - why escape the "<"?  It's not one of the meta characters that has
>  special meaning in a regex.

You are correct.

> - what's the difference between using ".*" to match any string and
> "+" to match a repeat of the character class "[^\<]".

Please study the Perl documentation for regular expressions, for instance:

     http://www.perldoc.com/perl5.8.0/pod/perlretut.html

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



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

Date: Tue, 28 Oct 2003 20:11:13 +0100
From: Matija Papec <perl@my-header.org>
Subject: Re: regex for stripping HTML
Message-Id: <2hftpv807evno1r7igpk84csomin98s9ln@4ax.com>

X-Ftn-To: Michael Vilain <vilain@spamcop.net> 

"Michael Vilain <vilain@spamcop.net>" wrote:
>Originally, I was using 
>
>   $value =~ s/<.*>//g;
>
>to strip HTML tags from a variable.  It actually stripped everything 
>from the first "<" to the last ">" after the ending tag.  I found this 
>regex in this group:
>
>   $value =~ s/\<[^\<]+\>//g;
>
>and I'm trying to parse it out and figure out why it works.  First off, 
>some questions:
>
>- why escape the "<"?  It's not one of the meta characters that has 
>special meaning in a regex.
>
>- what's the difference between using ".*" to match any string and "+" 
>to match a repeat of the character class "[^\<]".

/<.*>/g matches everything between first "<" and last ">". There should be
"?" after "*" to make regex ungreedy.

/<[^<]+>/g matches everything except "<" between "<" and next ">"



-- 
Matija


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

Date: Tue, 28 Oct 2003 19:36:23 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: regex for stripping HTML
Message-Id: <bnmgfn$jko$2@wisteria.csv.warwick.ac.uk>

Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> But normally you are recommended to use a module instead for parsing
> HTML markup.

Or, say, read perldoc -q HTML :).

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: 28 Oct 2003 22:28:33 GMT
From: ctcgag@hotmail.com
Subject: Re: Rookie: Constructing a large SQL INSERT statement
Message-Id: <20031028172833.227$VL@newsreader.com>

"sdfgsd" <sdfg@sdg.com> wrote:
> Disclaimer: I've googled and searched Perldoc/CPAN.
>
> The format of the INSERT statement is:
>
> INSERT INTO mytable (field_1, field_2, field_3)
> VALUES (value_1, value_2, value_3),
> (value_1, value_2, value_3),
> (value_1, value_2, value_3),
> (value_1, value_2, value_3),
> etc. ;
>
> In Delphi I just keep looping through the constrution process and keep
> adding to a string variable like this:
>
>   sqlstatement := sqlstatement + newrow;
>
> Is this the right approach to take in perl? Just keep adding to a scalar,
> or would some sort of list/hash construct be better?

I know I'm joining the game late here, but what the heck.

First, I'd take a hard look at doing this at all.  I've never seen a
performance problem cured by switching from an insert-in-loop into this
type of bulk insert, but I've seen lots of bugs and brittle code result
from the attempt.  You will be tying yourself to a (I believe)
MySQL-specific feature, and even worse, by-passing bind variables in doing
so--all for little gain.  If I were to resort to such cheesy stunts to try
to squeeze out that last 10% of performance, I'd skip this bulk insert and
go directly to  "Load data local infile into mytable..."

Having said that, the more perlish way to form the bulk insert text is:

$sqlstatement .= join ',', @newvalues


Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: 28 Oct 2003 22:17:17 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Singleton process
Message-Id: <bnmptd$2pk$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Ben Morrow:

> tassilo.parseval@post.rwth-aachen.de wrote:
>> Also sprach Roy Johnson:
>> 
>> > I've got a program that I want to be the only instance of itself
>> > running at any given time.  What *should* I be doing, for maximum
>> > reliability on both Unix and Windows?
>> 
>> Locking, I guess. Let the program create a lockfile at the beginning:
>> 
>>     use Fcntl;
>> 
>>     sysopen LOCK, "/tmp/prog.lock", O_CREAT|O_EXCL or
>>         exit 1;
>> 
>>     ...
>>     
>>     END { unlink "/tmp/prog.lock" }
>> 
>> This should be portable between UNIX and Windows.
> 
> What if the process is killed and leaves a stale lockfile around?
> You want to flock() the file as well; this will be broken when the
> process dies, at least on Unix. Not sure about Windows: I've had nasty
> experiences with programs dieing and leaving locks locked... :(

Define a signal-handler for a couple of signals (this however is not
quite so portable any longer). Anyway, stale lockfiles are nothing
special and show up once in a while.

Another approach would be to let the processes write their PIDs into the
file. That way, a new process could see whether a) any PIDs are to be
found in it and b) whether processes belonging to this PID are still
alive (by sending signal 0).

Other than that I don't expect Perl scripts to continuously crash. At
least mine don't.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Tue, 28 Oct 2003 22:41:07 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Singleton process
Message-Id: <i1stpvco70kv520njavsujaa4uhsvrmtp4@4ax.com>

Ben Morrow wrote:

>What if the process is killed and leaves a stale lockfile around?
>You want to flock() the file as well; this will be broken when the
>process dies, at least on Unix. Not sure about Windows: 

Just flocking a file, that would be my idea. Whether it works on
Windows, depends on the version of Windows. Win98 and friends don't do
flock(). NT can, I think. 

-- 
	Bart.


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

Date: Tue, 28 Oct 2003 19:34:00 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: strange effect with [:lower:] in perl
Message-Id: <bnmgb8$jko$1@wisteria.csv.warwick.ac.uk>


"Alan J. Flavell" <flavell@ph.gla.ac.uk> wrote:
> On Mon, 27 Oct 2003, Abigail wrote:
> 
> > "" >     [a-z0-9]              # Lowercase letters *and* digits.
> > ""
> > ""  Surely that only refers to a subset of what Unicode considers to be
> > ""  "letters"?
> >
> > Yeah, but that's what [:lower:] seems to do too:
> >
> >     $ perl -wle 'for (0x00 .. 0x80) {
> 
> Surely you meant to set the limit at 0xff or so for this
> demonstration?
> 
> >                  printf "%02x %s\n", $_, chr if chr () =~ /[[:lower:]]/}'
> 
> [snip]
> 
> > No lowercase accented letters here.
> 
> Curious.  No surprise when the limit's set at 0x80, as I'm sure you'd
> agree; but I must admit I was surprised at the accented lower-case
> letters up to 0xff not being counted, despite the accented lower case
> letters above 0x100 being counted.  Prima facie I think there's
> something wrong here, no?  (This is perl 5.8.0 per RedHat 9).
> 
> If I set the upper limit at, say, 0xfff, then I get lots of lower-case
> letters reported in the blocks of extended Latin, Greek, Coptic,
> Cyrillic and Armenian.

This confused me as well, at first; try 

% perl -wle'binmode STDOUT, ":utf8" for(0x00 .. 0xFF) { printf "%02x \
  %s\n", $_, chr if substr(chr() . "\x{100}", 0, 1)\ =~              \ 
  /[[:lower:]]/}'

, the sole point of the \x{100} being to upgrade the string to
Unicode...

Some of the characters produced still confuse me rather, though, such
as U+00AA FEMININE ORDINAL INDICATOR, but I guess Perl's just
returning what's in the Unicode standard.

Ben

-- 
And if you wanna make sense / Whatcha looking at me for?          (Fiona Apple)
                            * ben@morrow.me.uk *


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

Date: 28 Oct 2003 19:48:44 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: strange effect with [:lower:] in perl
Message-Id: <slrnbpti0r.5ir.abigail@alexandra.abigail.nl>

Alan J. Flavell (flavell@ph.gla.ac.uk) wrote on MMMDCCX September
MCMXCIII in <URL:news:Pine.LNX.4.53.0310281819040.28979@ppepc56.ph.gla.ac.uk>:
][  On Mon, 27 Oct 2003, Abigail wrote:
][  
][ > "" >     [a-z0-9]              # Lowercase letters *and* digits.
][ > ""
][ > ""  Surely that only refers to a subset of what Unicode considers to be
][ > ""  "letters"?
][ >
][ > Yeah, but that's what [:lower:] seems to do too:
][ >
][ >     $ perl -wle 'for (0x00 .. 0x80) {
][  
][  Surely you meant to set the limit at 0xff or so for this
][  demonstration?

Yes, I did. However, it doesn't change the outcome.

][ >                  printf "%02x %s\n", $_, chr if chr () =~ /[[:lower:]]/}'
][  
][  [snip]
][  
][ > No lowercase accented letters here.
][  
][  Curious.  No surprise when the limit's set at 0x80, as I'm sure you'd
][  agree; but I must admit I was surprised at the accented lower-case
][  letters up to 0xff not being counted, despite the accented lower case
][  letters above 0x100 being counted.  Prima facie I think there's
][  something wrong here, no?  (This is perl 5.8.0 per RedHat 9).

Maybe, maybe not. I'm still confused what Perl is doing with Unicode,
and considering all the discussions on p5p, not everyone wants to do
the same.

And considering that the fonts I use are unable to display Unicode,
I'm not that interested anyway.



Abigail
-- 
$_ = "\x3C\x3C\x45\x4F\x54\n" and s/<<EOT/<<EOT/ee and print;
"Just another Perl Hacker"
EOT


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

Date: Tue, 28 Oct 2003 20:52:21 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: strange effect with [:lower:] in perl
Message-Id: <Pine.LNX.4.53.0310282026310.28979@ppepc56.ph.gla.ac.uk>

On Tue, 28 Oct 2003, Ben Morrow wrote:

> This confused me as well, at first; try
>
> % perl -wle'binmode STDOUT, ":utf8" for(0x00 .. 0xFF) { printf "%02x \
>   %s\n", $_, chr if substr(chr() . "\x{100}", 0, 1)\ =~              \
>   /[[:lower:]]/}'
>
> , the sole point of the \x{100} being to upgrade the string to
> Unicode...

Oh yes: the /[[:lower:]]/ regex fails to work when it's fed
non-upgraded iso-8859-1 characters, but works fine after forcing
the "upgrade".

That would surely have to be categorised as a bug?

> Some of the characters produced still confuse me rather, though, such
> as U+00AA FEMININE ORDINAL INDICATOR,

Yes, the feminine and masculine ordinals are formed from lower case
"a" and "o", so it's plausible at least.

> but I guess Perl's just returning what's in the Unicode standard.

Right, that would be the "Ll" indicator in the third field of the
Unicode character data, e.g for version 3 of Unicode see
http://www.unicode.org/Public/3.0-Update/UnicodeData-3.0.0.txt
(beware: large file!).  See the explanation at
http://www.unicode.org/Public/3.0-Update/UnicodeData-3.0.0.html ,
field number 2 "General Category".  (I'm not sure which version of
Unicode they implement in 5.8.0, sorry)

By the way, just to show myself that it's feasible, I'm sitting at a
Windows/NT station, running the "putty" ssh client to connect to
redhat 9, and with "putty" configured to use a monospaced
Unicode-capable font, and utf-8 encoding.  Seems to work fine for
display  ;-)


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

Date: Tue, 28 Oct 2003 22:19:06 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: strange effect with [:lower:] in perl
Message-Id: <bnmq0q$nms$2@wisteria.csv.warwick.ac.uk>


"Alan J. Flavell" <flavell@ph.gla.ac.uk> wrote:
> On Tue, 28 Oct 2003, Ben Morrow wrote:
> 
> > This confused me as well, at first; try
> >
> > % perl -wle'binmode STDOUT, ":utf8" for(0x00 .. 0xFF) { printf "%02x \
> >   %s\n", $_, chr if substr(chr() . "\x{100}", 0, 1)\ =~              \
> >   /[[:lower:]]/}'
> >
> > , the sole point of the \x{100} being to upgrade the string to
> > Unicode...
> 
> Oh yes: the /[[:lower:]]/ regex fails to work when it's fed
> non-upgraded iso-8859-1 characters, but works fine after forcing
> the "upgrade".
> 
> That would surely have to be categorised as a bug?

No: well, at any rate, it's intentional and documented. The aim is
that non-Unicode-aware programs being fed non-Unicode data carry on
working as before 5.6, and before 5.6 [[:lower:]] meant the same as
[a-z] unless you used locale.

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: Tue, 28 Oct 2003 15:04:38 -0500
From: Greg G <ggershSNACK@CAKEctc.net>
Subject: system() rc hosed?
Message-Id: <Z_SdncAtxfhQUAOiRVn-gA@ctc.net>


I've got some code that looks like this:

     @args = ("/usr/local/bin/myprogram ", " -a ", $param1, " -b ", 
$param2);
     print STDERR @args, "\n";
     $rc = 0xffff & system (@args);

It *should* work, but it is patently ignoring the return code from 
myprogram.  In fact, the return code is 255, which seems to translate to 
  "command failed".  If I capture the output from stderr and run it from 
the command line, it works fine.

In fact, this works fine:

     $capture = `@args`;
     print STDOUT $capture,"\n";

I get the output from the myprogram.

    Any ideas what's happening to me here?

-Greg G



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

Date: Tue, 28 Oct 2003 20:22:55 +0000 (UTC)
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: system() rc hosed?
Message-Id: <bnmj6v$omh$1@naig.caltech.edu>

In article <Z_SdncAtxfhQUAOiRVn-gA@ctc.net>,
Greg G  <ggershSNACK@CAKEctc.net> wrote:
>
>I've got some code that looks like this:
>
>     @args = ("/usr/local/bin/myprogram ", " -a ", $param1, " -b ", 
>$param2);
>     print STDERR @args, "\n";
>     $rc = 0xffff & system (@args);
>
>It *should* work, but it is patently ignoring the return code from 
>myprogram.  In fact, the return code is 255, which seems to translate to 
>  "command failed".  If I capture the output from stderr and run it from 
>the command line, it works fine.

When you pass system() a list of arguments, as you are doing here,
they are taken exactly as the program to run and the arguments to
pass to it.

So your system() command is looking for a program called 
"/usr/local/bin/myprogram " -- without the quotes, but _with_
the trailing space.  Also, the first and third arguments to that 
program are going to have leading and trailing spaces.

If you want to print out the arguments nicely, I would use
    print STDERR join(' ', @args), "\n";
(You could play with the $" variable, which works out to the same thing.)

However, I often prefer something like
    print STDERR map(">$_<", @args), "\n";
especially if trailing spaces or newlines might be involved.

Gary
-- 
Rule #87: If the thought of something makes me giggle for longer than 15 
seconds, I am to assume that I am not allowed to do it.
        -- www.skippyslist.com


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

Date: Tue, 28 Oct 2003 15:35:00 -0500
From: Greg G <ggershSNACK@CAKEctc.net>
Subject: Re: system() rc hosed?
Message-Id: <FaOdnf_Jmsl2SQOiRVn-sg@ctc.net>

Gary E. Ansok wrote:

> In article <Z_SdncAtxfhQUAOiRVn-gA@ctc.net>,
> Greg G  <ggershSNACK@CAKEctc.net> wrote:
> 
>>I've got some code that looks like this:
>>
>>    @args = ("/usr/local/bin/myprogram ", " -a ", $param1, " -b ", 
>>$param2);
>>    print STDERR @args, "\n";
>>    $rc = 0xffff & system (@args);
>>
>>It *should* work, but it is patently ignoring the return code from 
>>myprogram.  In fact, the return code is 255, which seems to translate to 
>> "command failed".  If I capture the output from stderr and run it from 
>>the command line, it works fine.
> 
> 
> When you pass system() a list of arguments, as you are doing here,
> they are taken exactly as the program to run and the arguments to
> pass to it.
> 
> So your system() command is looking for a program called 
> "/usr/local/bin/myprogram " -- without the quotes, but _with_
> the trailing space.  Also, the first and third arguments to that 
> program are going to have leading and trailing spaces.
> 
> If you want to print out the arguments nicely, I would use
>     print STDERR join(' ', @args), "\n";
> (You could play with the $" variable, which works out to the same thing.)
> 
> However, I often prefer something like
>     print STDERR map(">$_<", @args), "\n";
> especially if trailing spaces or newlines might be involved.

    Thanks!  That seems to have cleared things up nicely.

-Greg G



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

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


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