[13526] in Perl-Users-Digest
Perl-Users Digest, Issue: 936 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 28 21:33:01 1999
Date: Tue, 28 Sep 1999 18:05:12 -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: <938567111-v9-i936@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 28 Sep 1999 Volume: 9 Number: 936
Today's topics:
Re: 2 Perl Questions (Larry Rosler)
Re: a question of buttons <davids@desertigloo.com>
Re: Assign variable from cgi-lib.pl field? (Abigail)
Re: Basic Question <cassell@mail.cor.epa.gov>
Re: can I pass control to a different program <cassell@mail.cor.epa.gov>
Re: Database Help needed <dove@synopsys.com>
Re: DB_File (Jakob Schmidt)
Re: Deleting spaces in a string (Abigail)
Re: Do you now an affordable Perl editor for Windows NT (jasong)
Re: Error <cassell@mail.cor.epa.gov>
Re: Error (Abigail)
Re: Exclusive open()? <cassell@mail.cor.epa.gov>
Re: Exclusive open()? <dove@synopsys.com>
Re: How to convert perl file into binaries? <cassell@mail.cor.epa.gov>
Re: How to save a file as binary? <cassell@mail.cor.epa.gov>
Re: How to save a file as binary? <cassell@mail.cor.epa.gov>
Re: HTML to ASCII (David H. Adler)
Re: kill extra white space in a variable (Abigail)
Re: kill extra white space in a variable (Mathew A. Hennessy)
Re: kill extra white space in a variable <dove@synopsys.com>
Re: LOST NEWBIE (Mathew A. Hennessy)
Re: New book: Automating Windows With Perl <kbandes@home.com>
Re: Perl Question <cassell@mail.cor.epa.gov>
qx// and here doc puzzle (Gyepi SAM)
Re: reconnecting a closed pipe <uri@sysarch.com>
Re: Regex == Turing? (was remove the html tag in the fi <kbandes@home.com>
Re: Simple Mail Transfer Protocol ... Not So Simple! (Gyepi SAM)
Re: Sorting weird numeric data (Abigail)
Re: Sorting weird numeric data <cassell@mail.cor.epa.gov>
Re: Sorting weird numeric data (Larry Rosler)
Win32::API -- how to call functions using NULL pointers eric_poulsen@my-deja.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 28 Sep 1999 16:18:25 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: 2 Perl Questions
Message-Id: <MPG.125aec9bb3087cc6989ff5@nntp.hpl.hp.com>
In article <7srdlb$s4e$1@nnrp1.deja.com> on Tue, 28 Sep 1999 21:58:08
GMT, Alligator <alligator333@my-deja.com> says...
> 1. I need to get the "last-modified" date of a file. By reading the
> FAQs at Perl.com, I was able to learn how to do this for a local file,
> but the file I am trying to access is on another server. How can I get
> its timestamp?
You can use LWP::UserAgent and send a HEAD request. One of the values
that *may* be returned in the header is 'last-modified'. If you get it
back, it will be in an Internet UTC standard text format, which you will
have to analyze to get the components into a form convertible by
timegm() to a Unix-epoch time (see below).
> 2. This question is much more basic than the first. What is the best
> way to store dates (numerically) in Perl? I'm planning to parse the
> output of localtime() and store the day, month, and year in 3 different
> variables. However, before I base the structure of a program (and its
> data files) on this plan, I wanted to see if there was a better way, or
> if date functions in general expected some other format, such as a
> single integer containing a date in yyyy/mm/dd format.
If you don't mind potential Y2038 problems, by far the best (most
compact and manipulable) form is as an integer, specifying the number of
seconds since the Unix Epoch. This is the form returned by the time()
function. I often use "pack 'N'" to convert the number to four bytes to
store in a text file.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 28 Sep 1999 16:06:01 -0700
From: "David P. Schwartz" <davids@desertigloo.com>
Subject: Re: a question of buttons
Message-Id: <37F149D9.73435111@desertigloo.com>
"I.J. Garlick" wrote:
> In article <37EF34E2.9448A457@desertigloo.com>,
> "David P. Schwartz" <davids@desertigloo.com> writes:
> > Gee, I'm truly sorry to distract so many of you experts from your efforts to come up
> > with ever more complex and subtle "Just another Perl Hacker" scripts with such petty
> > issues...
>
> Bummer, in correct line wrapping length AND insluting one of the more
> clued in around here.
>
> Ah well I recon you will have been plonked.
>
> >
>
> (Sorry I just gave to reformat these.)
> > The HTML part is simple. I don't have a question about that. Ok? Is
> > that clear? If I put three buttons on an HTML form, with different names
> > and values, what shows up in my Perl script when it runs is ... three
> > buttons with different names and values. Duh. So, which one was
> > pressed? I don't know where to find this. I don't know if this is a
> > Perl question or not.
>
> It's still not a perl question because the answer is the same in any
> language you care to use for this.
>
> However I am in a fairly good mood and you obviously haven't gotten the
> various clues that have been dropped so:-
>
> It's very easy you name all the buttons in a form element the same. Then
> you check the value of that name that was passed back. Since it's only
> possible to press one button at a time on a form you can't get a
> conflict. See it's HTML not Perl, not C, not Lisp..... you get the
> picture?
>
> --
> Ian J. Garlick
> ijg@csc.liv.ac.uk
>
> The Consultant's Curse:
> When the customer has beaten upon you long enough, give him
> what he asks for, instead of what he needs. This is very strong
> medicine, and is normally only required once.
Ian,
I guess the rule here is, "Those who know, don't tell, and those who tell don't know", eh?
That must be the meaning of "clued-in" you refer to?
I'm glad you're in a "good mood". Thanks for the info. I'm quite clear now.
-David
------------------------------
Date: 28 Sep 1999 19:07:14 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Assign variable from cgi-lib.pl field?
Message-Id: <slrn7v2mg1.9kl.abigail@alexandra.delanet.com>
Campos (nospam@thankyou.com) wrote on MMCCXIX September MCMXCIII in
<URL:news:37f11ac8_3@news1.prserv.net>:
||
|| $var = '$data{'firstname'}';
That doesn't compile, does it?
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Tue, 28 Sep 1999 16:46:35 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Basic Question
Message-Id: <37F1535B.A2B33255@mail.cor.epa.gov>
iltiaz@hotmail.com wrote:
>
> Hi
> I have install IIS 4.0 and Active perl 519 on my NT Box. I have a form
> on my website which takes input and email me back. Right now this is
> not working properly. Do i need to install any sendmail program for
> that. If yes from where? could anybody help me out? Thanks in advance.
There's no way to tell from here. Some formmail scripts assume
that you're running sendmail on a unix box. A few don't. The
sendmail variants for NT that I have seen are not free.. or even
cheap.
You may want to learn enough Perl to be able to use the
Mail::Sender or Mail::Mailer modules, which are free and
available for NT as well as unix.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 28 Sep 1999 16:44:14 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: can I pass control to a different program
Message-Id: <37F152CE.436FB8A9@mail.cor.epa.gov>
Bradley Peters wrote:
>
> Can somebody please tell me whether I can pass control to another
> program within a PERL script.
>
> Using a UNIX csh shell script I was able to pass control to a
> different program as follows (using sqlplus as an example)
> #!/bin/csh
> sqlplus user/password <<EOFone
> show user;
> exit;
> EOFone
>
> Can I do the same thing in Perl.
Yes. Perl even has the here-doc syntax you're using above.
Depending on your needs, you'll want to use either open(),
system(), exec(), or qx// . You can find out about each of
these by using the -f syntax of 'perldoc', or else reading
the perlfunc manpage [although qx will refer you to the
perlop manpage].
perldoc -f open
perldoc -f system
perldoc -f exec
perldoc perlop
Just one note: you can often do better than the pipe-orama
style of shell scripts by re-writing in a more Perlish form.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 28 Sep 1999 17:17:45 -0700
From: David Amann <dove@synopsys.com>
Subject: Re: Database Help needed
Message-Id: <37F15AA9.FF61FE31@synopsys.com>
Hi David,
David Scally wrote:
> I help run a website, which has news which has to be updated nearly daily.
> We currently use a method of plain HTML editing and FTPing to update the
> site, but I was hoping to add make the news section database-driven.
> How hard would it be to do something like this? Would anyone be able to give
> me the coding or something to do this?
Hmm. This thing is not tremendously difficult, but you have to know a few
things before hand. If you want to do it in Perl, you'll need to know Perl (of
course), the CGI module, and someone to store your data persistently (either
some relational database, or DBM files, or flat files).
You'll probably want the following:
* A web form to input the news data into your database.
* A storage routine to store data into your database
* A retrieval routine to retrive data from your database.
* A CGI script to output the data to your end user.
My guess is that a competent web application developer could get a barebones
system like this running in a week or two. More depending on how robust you'd
like this to be and how many features you'd like to add.
Someone might be able to whip up an example on how to do this in a few hours.
Unfortunately, I don't have the time.
Hope this helps,
-=dav
------------------------------
Date: Wed, 29 Sep 1999 01:31:54 +0200
From: jakob@pocketlife.dk (Jakob Schmidt)
Subject: Re: DB_File
Message-Id: <1dyvdb7.adspk6agceioN@[192.168.88.117]>
Joe Buhr <joe.buhr@motorola.com> wrote:
> #!/usr/misc/bin/perl
>
> use DB_File;
>
> tie %h, "DB_File", "test", O_RDWR|O_CREAT, 0644;
Dunno, but in MacPerl you'd have to
use Fcntl;
as well. But I don't think the file would even be created if that was
it...
--
Jakob
------------------------------
Date: 28 Sep 1999 19:25:08 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Deleting spaces in a string
Message-Id: <slrn7v2nhh.9kl.abigail@alexandra.delanet.com>
Rich (guest@unknown.com) wrote on MMCCXIX September MCMXCIII in
<URL:news:rv1i071u3i584@corp.supernews.com>:
`` Why don't you provide a link to the stupid faq then.
*plonk*
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Tue, 28 Sep 1999 23:33:49 GMT
From: jason@commiesoft.to (jasong)
Subject: Re: Do you now an affordable Perl editor for Windows NT
Message-Id: <37f14f88.103833896@news.bctel.ca>
On Tue, 28 Sep 1999 01:29:39 GMT, "Eric Dubreuil"
<ericdub@sympatico.ca> wrote:
>I just installed Perl on my PC (Windows NT) and would like to get a nice
>editor to edit my Perl code. I looked at a few commercials ones but they
>are too expensive (and have way too many features for myt needs anyway).
>
>I just need cheap, freeware or chareware editor that could do code identing
>and/or keywords coloring and stuff like that. I'm looking for an editor that
>would be just a little more programmer friendly that Wordpad...
Get UltraEdit-32. It kicks ass! It's got perl syntax highlighting,
save to/load from ftp so you can edit your scripts right on the
server. All in all a beautiful text editor.
------------------------------
Date: Tue, 28 Sep 1999 16:56:48 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Error
Message-Id: <37F155C0.D6EC0EEF@mail.cor.epa.gov>
Chicheng Zhang wrote:
>
> If you are using cgi.pm, remember always write header(), start_html() first to
> generate pages.
That's CGI.pm .. and there's something wrong with the way your
newsreader is handling your lines. But otherwise, good advice.
And please do not post 'Jeopardy-style' in this newsgroup.
Place your answer after the text to which you respond.. as I
did here. It permits a useful discourse to take place.
> Missing or improperly placing the header() is a major problem causing "premature
> end of script headers".
Yes. But it is only one of many reasons why one can get this error.
The FAQ [perlfaq9] has pointers to URLs which have more advice,
if this doesn't fix the problem.
> It will help a lot more if you can post the entire program here.
Umm.. no. Please do *not* post the entire program here. Cut
your program down to the smallest chunk of code which still
works, but still exhibits the error. For this case, I would
venture that you'd need less than 10 lines. And one might even
find the error(s) oneself as one debugs in this manner.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 28 Sep 1999 19:26:48 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Error
Message-Id: <slrn7v2nkm.9kl.abigail@alexandra.delanet.com>
Ajay Khanna (aakhanna@aludra.usc.edu) wrote on MMCCXIX September MCMXCIII
in <URL:news:Pine.GSO.4.10.9909281128570.4104-100000@aludra.usc.edu>:
"" Hi..
"" I have written a perl program which when tried to run on a browser gives
"" an "Internal Server Error". The error written in the error_log is :
"" [Mon Sep 27 16:44:09 1999] [error] (8)Exec format error: exec of
"" /home/imsc2/www/cgi-bin/calendar-show.pl failed
"" [Mon Sep 27 16:44:09 1999] [error] [client 128.125.163.100] Premature end
"" of script headers " /home/imsc2/www/cgi-bin/calendar-show.pl
"" Could someone help me with it
That means you have a bug.
Abigail
--
$" = "/"; split $, => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_) {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Tue, 28 Sep 1999 17:26:35 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Exclusive open()?
Message-Id: <37F15CBB.3DC11E39@mail.cor.epa.gov>
paulco44213@my-deja.com wrote:
>
> Is it possible to exclusively open a file with perl, such that any
> other open()s by other perl scripts running at the same time will fail?
I'll assume you need to open for write or read-write, since
if you only need to open for read, you don't really have a
concurrency problem.
The basic limitation here will be the OS, rather than Perl.
But Perl's flock() does a decent job of emulating everyone's
locking capabilities. Well, maybe not VMS. I'm sure Dan
Sugalski will complain if I get too confused about Perl and
VMS.
In VMS and NT it is possible to open a file so that no one
else can open it.
In unix-ish OSes, the concept is cooperation rather than
law enforcement, so all the programs have to be willing and
able to check the flock before doing the read-write on the
file. But if you try this over NFS, all bets on atomicity
are off.
In OSes like win95 and win98 there is no built-in
functionality for flock()ing a file. There are ugly
kludges that people have used to dodge this, but they all
suffer from concurrency problems of their own due to a
lack of atomicity.
You can get some of the FAQ on this by typing:
perldoc -q "(?<!b)lock"
or
perldoc -q "\block"
to avoid all the FAQ which have the word 'block'.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 28 Sep 1999 17:37:21 -0700
From: David Amann <dove@synopsys.com>
Subject: Re: Exclusive open()?
Message-Id: <37F15F41.27A6BB0@synopsys.com>
Hi Paul,
paulco44213@my-deja.com wrote:
> Is it possible to exclusively open a file with perl, such that any
> other open()s by other perl scripts running at the same time will fail?
Try the following:
sub LOCK_SH() {1};
sub LOCK_EX() {2};
sub LOCK_NB() {4};
sub LOCK_UN() {8};
open (FILE, "+< $path") or die "Can't open $path: $!\n";
flock(FILE, LOCK_EX()) or die "Can't lock $path: $!\n";
# Update the file you want to update
close(FILE) or die "Can't close $path: $!\n";
Hope this helps,
-=dav
------------------------------
Date: Tue, 28 Sep 1999 17:03:19 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: How to convert perl file into binaries?
Message-Id: <37F15747.5A466F8B@mail.cor.epa.gov>
Chicheng Zhang wrote:
>
> When running a perl file with shebang #!, I need +rx it(chmod 555). So
> it is still reable. if I want
> it to be unreadable but still executable, all I know is +s it. Is
> there any simply way just convert
> this file into binaries??
Based on what you say, it doesn't sound to me like you really
want or need to convert any files into binaries. If you don't
want others to be able to read your CGI scripts, then that is
usually a webserver config issue. If the web server is set up
properly, visitors shouldn't be able to read your scripts.
And I would recommend chmod 0755 instead, as per the CGI
Programming FAQ at
http://www.webthing.com/tutorials/cgifaq.html
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 28 Sep 1999 16:48:32 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: How to save a file as binary?
Message-Id: <37F153D0.5368FF1E@mail.cor.epa.gov>
Larry Rosler wrote:
> What is the antonym of 'educational'? :-)
Let's see:
educational materials
educational television
educational computer programs
I guess the antonym you're looking for is 'interesting'.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 28 Sep 1999 16:50:10 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: How to save a file as binary?
Message-Id: <37F15432.C5244F62@mail.cor.epa.gov>
Abigail wrote:
[snip]
> I never use binmode, and I doubt I ever will.
Don't be so negative. I'm sure you'll find some arcane misfeature
of binmode() that will let you write a new and even more stunning
JAPH sometime soon now. I have confidence in you. :-)
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 28 Sep 1999 23:39:44 GMT
From: dha@panix7.panix.com (David H. Adler)
Subject: Re: HTML to ASCII
Message-Id: <slrn7v2ke0.9c5.dha@panix7.panix.com>
In article <7sl4cr$cuq$1@gellyfish.btinternet.com>, Jonathan Stowe wrote:
>In comp.lang.perl.misc Abigail <abigail@delanet.com> wrote:
>>
>> Let's shoot people who don't RTFDTD.
>>
>
>Thats a *little* harsh wouldnt you say ? I would suggest flogging
>it least it gives them an opportunity to recant.
No one said anything about shooting them *fatally*...
:_)
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
I drink to my coming cirrhosis... - Charles Aznavour
------------------------------
Date: 28 Sep 1999 18:06:51 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: kill extra white space in a variable
Message-Id: <slrn7v2iuq.9kl.abigail@alexandra.delanet.com>
mikej (mikej@1185design.com) wrote on MMCCXIX September MCMXCIII in
<URL:news:37F12473.99DEB73@1185design.com>:
{}
{} I dont know why its giving me the space. The flat file doesnt seem to
{} have any white space after the name. Any ideas on what is causing this
{} phantom space? Thanks.
I guess you either have a bug in your program, or your data doesn't
contain what you think it contains.
Abigail
--
perl -wlpe '}{$_=$.' file # Count the number of lines.
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Wed, 29 Sep 1999 00:08:33 GMT
From: hennessy@cloud9.net (Mathew A. Hennessy)
Subject: Re: kill extra white space in a variable
Message-Id: <rv2m41qg3i519@corp.supernews.com>
In article <slrn7v2iuq.9kl.abigail@alexandra.delanet.com>,
Abigail <abigail@delanet.com> wrote:
>mikej (mikej@1185design.com) wrote on MMCCXIX September MCMXCIII in
><URL:news:37F12473.99DEB73@1185design.com>:
>{}
>{} I dont know why its giving me the space. The flat file doesnt seem to
>{} have any white space after the name. Any ideas on what is causing this
>{} phantom space? Thanks.
(The original post expired off my server)
start your scripts with:
#!/path/to/perl -w
and put (early in your script)
require 5;
use strict;
that may provide additional warning output since the script is
executed in a more stringent warning mode.
btw: write every script using -w and use strict, unless you'll be
deleting it or forgetting it after the task is completed. Certainly, any
script used more than 5 times or included in another script must have
them. It hurts more, but you'll have better code for it.
And if you aren't running perl5, install it. If you don't have
install privs, bludgeon your resident admin until it's there. Any decent
admin (on a unix system) would have already installed it in a publically
available location. Note, 'decent' describes the person's nature, not
their technical savvy.. ;)
--
If it sounds too good to be true, it's probably Linux.
"Fool! There is nothing Perl cannot do! NOTHING!" -Bastich
"You can never entirely stop being what you once were. That's why it's important
to be the right person today, and not put it off till tomorrow." - Larry Wall
------------------------------
Date: Tue, 28 Sep 1999 17:20:57 -0700
From: David Amann <dove@synopsys.com>
Subject: Re: kill extra white space in a variable
Message-Id: <37F15B68.A7A33301@synopsys.com>
Hi Mike,
mikej wrote:
> I dont know why its giving me the space. The flat file doesnt seem to
> have any white space after the name. Any ideas on what is causing this
> phantom space? Thanks.
I don't know what's causing the phantom space, but here's a quick code
snippet to get leading or trailing whitespace from your string.
$string =~ s/^\s+//;
$string =~ s/\s$//;
Hope this helps,
-=dav
------------------------------
Date: Tue, 28 Sep 1999 23:55:06 GMT
From: hennessy@cloud9.net (Mathew A. Hennessy)
Subject: Re: LOST NEWBIE
Message-Id: <rv2laq7h3i592@corp.supernews.com>
In article <MPG.125adc24c7647a60989ff4@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>In article <37F131F0.1F6AC79D@cisco.com> on Tue, 28 Sep 1999 14:24:00 -
>0700, Makarand Kulkarni <makkulka@cisco.com> says...
>> To find files in a dir and then sort them as per inode change times .
>> --
>> opendir(DIR, ".") || die "can't opendir" ;
>> @files = sort { -C $a <=> -C $b } grep { -f $_} readdir(DIR);
>
>Don't try this on a large directory, say 1000 files or more, without
>being prepared to go out for a cup of coffee while it churns away stat-
>ting each of those files far too many times.
does find2perl / File::Find optimize this? (probably..)
--
If it sounds too good to be true, it's probably Linux.
"Fool! There is nothing Perl cannot do! NOTHING!" -Bastich
"You can never entirely stop being what you once were. That's why it's important
to be the right person today, and not put it off till tomorrow." - Larry Wall
------------------------------
Date: Wed, 29 Sep 1999 01:02:13 GMT
From: Kenneth Bandes <kbandes@home.com>
Subject: Re: New book: Automating Windows With Perl
Message-Id: <37F16533.D13586F7@home.com>
Kragen Sitaker wrote:
>
> In article <UM6I3.247$hs.15796@monger.newsread.com>,
[...]
> >I have a new book called Automating Windows With Perl.
>
> OK; here are my impressions from the web site:
> - the author is probably mostly familiar with Microsoft Windows -- not
> in itself an indictment of his competence -- because he refers to "the
> Microsoft concept of Automation" on the web page;
Meaning not that Microsoft invented automation, but that in the
Windows context the term "Automation" has a specific and, believe
it or not, well-defined meaning in terms of COM (unlike other
Microsoft terms such as "ActiveX" or "OLE", whose meanings have
varied radically over time or vanished altogether). Most of what
Win32::OLE deals with is actually "Automation" in this sense
(formerly known as "OLE Automation").
Ken Bandes
------------------------------
Date: Tue, 28 Sep 1999 17:12:55 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Perl Question
Message-Id: <37F15987.55AF676@mail.cor.epa.gov>
Dheera wrote:
> $test_proj_n_page="gridSearch/pgHomeDefault?";
>
> if($test_proj_n_page=~/([^\/]*)\/([^\/]*)\?/){
> $test_proj_n_page=~s/([^\/]*)\/([^\/]*)\?/
> $test_projectname=$1;$test_pagename=$2/e;
> }
> print "$test_projectname\n$test_pagename;"
Yes, it is a very good idea to test that the match has been
successful before assigning using $1, $2, etc. But this is
a fairly icky way to do it. You're running the entire
regex twice, when the most time-consuming part of the code
is likely to be the regex. And you don't need to backwhack
a slash *inside* a character class, you know. You probably
want to change those '*' to '+' too.
I think you may want to re-read the perlre pages.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 28 Sep 1999 13:01:35 -0400
From: gyepi@magnetic.praxis-sw.com (Gyepi SAM)
Subject: qx// and here doc puzzle
Message-Id: <slrn7v1t2c.n30.gyepi@magnetic.praxis-sw.com>
In cooking up a response to a posting, I discovered that the qx// operator
does not work with here documents. Example code follows.
#!/usr/bin/perl -w
use strict;
my $retval;
$|++; #we want results to show up in correct order
#this works as expected.
$retval=<<`EOC`;
date
EOC
print $retval;
$retval=qx(<<EOC);
echo unreachable code
EOC;
print $retval;
__END__
prints the following two lines:
Tue Sep 28 12:46:07 EDT 1999
Can't locate object method "code" via package "EOC" at /tmp/qx.pl line 15.
instead of the expected output.
Obviously the qx// operator is eating up the here doc terminating string,
leading perl to parse the following lines as a method call attempt.
Increasing the number of words echoed causes a syntax error.
I had always thought that `` was equivalent to qx//, but this seems to show
an inequivalency. I realize that qx// is an operator, not a function, but
even that seems to belie the line in the Camel book, "If it looks like a
function, it is a function!" I forget which page.
Am I missing something or is perl?
--
Gyepi Sam --+-- Designer/Programmer --+-- Network/System Administrator
gyepi@praxis-sw.com --+-- http://www.praxis-sw.com/gyepi
The world is coming to an end! Repent and return those library books!
------------------------------
Date: 28 Sep 1999 19:09:56 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: reconnecting a closed pipe
Message-Id: <x7r9jiy6nv.fsf@home.sysarch.com>
>>>>> "MF" == Michael Frost <msfrost@celluloidnexus.com> writes:
MF> I'm writing a server which spawns off concurrent processes to execute
MF> especially long-running blocks of code, then goes back to listening for
MF> more tasks to manage. The status of the long-running blocks of code will
MF> be logged in a single html file which is periodically loaded by a web
MF> browser. I'd like to handle all error messages in the server, rather
MF> than the children, so the thought was to have the child reconnect when
MF> it's ready to send status data back to the parent. The problem is, since
MF> the parent is a server, it is busy listening for new connections which
MF> will result in the spawning of even more children.
i am guessing you have a simple loop around an accept on a listen
socket. that is a poor man's server and won't scale or allow any
flexibility.
instead spawn off the children with a pipe to the parent by using open(
$handle, "$child_cmd |" ) or some variant of that in the IO:: modules so
you get a fresh handle for each child. then the parent can read the
results from those pipes. the parent uses a select loop or IO::Select
to ee when children have written some status and when you have a
connection request on your listen socket.
the Event.pm module also can do most of that work for you.
uri
PS. i can't believe i am telling an ibm employee how to write
servers. the irony of it all.
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Tue, 28 Sep 1999 23:49:26 GMT
From: Kenneth Bandes <kbandes@home.com>
Subject: Re: Regex == Turing? (was remove the html tag in the file)
Message-Id: <37F15423.127485E@home.com>
Anno Siegel wrote:
> >> >>>>> "Dan" == Dan Sugalski <dan@tuatha.sidhe.org> writes:
> >>
> >> Dan> That'd be kinda tough at this point. Perl's regexes are Turing-complete,
> >> Dan> after all. (Anyone care to rewrite GCC as a regex? :)
> >Is this true? [...]
>
> Well, backreferences (\1 and friends) make it possible to match things
> that regular grammars don't. A popular example is
>
> <exp> := "x" | "y" <exp> "y"
>
> that is an "x" preceded and followed by like numbers of "y"s. This
> is not a regular expression in the strict sense, yet it is trivially
> matched by Perl's m/(y*)x\1/.
>
> Backreferences are a powerful tool.
Indeed, and they make Perl regexps more expressive than standard
ones. But they do not make them capable of handling general
context-free grammars. Most useful languages have matched pairs of
unlike things, whereas back-references can find matched pairs (or
other combinations) of like things. But parentheses, curly braces,
<em>start and end tags</em>, and so forth are not amenable to this
technique.
> TomC notes in the _Cookbook_
> (p. 196) that they can be used to solve Diophantine equations of
> order one.
Yes - a spectacular example which, however, doesn't answer my
question. Are Perl regexps equivalent to Turing Machines? Can
they really be used to parse a language such as Perl? I still
don't see how.
Ken Bandes
------------------------------
Date: Tue, 28 Sep 1999 13:19:26 -0400
From: gyepi@magnetic.praxis-sw.com (Gyepi SAM)
Subject: Re: Simple Mail Transfer Protocol ... Not So Simple!
Message-Id: <slrn7v1u3r.n30.gyepi@magnetic.praxis-sw.com>
On Tue, 28 Sep 1999 15:26:05 GMT, Majid Sharif <majid.sharif@mci.com> wrote:
>Dear helper,
>
>I writing a Multiscreen CGI Script (Form) that is to email some of the forms
>input within that email.
>The issue that I'm having is the email is not implementing the form fields
>that I'm referencing.
>For example, If the user inputs "TTI National" in the Account Name Field of
>the form, the body of the email sent should read,
>"The following product items for the TTI National Account have been
>Approved. However, the email reads,
>"The following product items for the Account have been Approved. I'm
>guessing that the issue has something to do with the return statement (which
>I do not understand). I have provided my code below.
>
>Can someone Please help!
>Thanks
>
># Approval/Disapproval Email Sent Page.
>sub email_confirmation
>{
> my $active = shift;
> return unless $active;
>
> my $SMTPHost = "send.mcit.com";
> my $ClientDevContact = "mailto:majid.sharif\@wcom.com;
missing quote here. ^
> my $UserEmailAddress = $Cgi->param('EmailAddress');
>
> my $EmailSubject = $Cgi->param('AcctName'). " Account Product Approval";
> my $EmailTitle = "The following product items for the " .
>$Cgi->param('AcctName'). " Account have been Approved:\n\n";
[snip smtp code]
The error is probably not in the smtp code.
How can you be sure that the CGI param method will always
return a value much less a valid one?
You may also want to double check the param names you in your form
generating code versus the name you are using to get values.
--
Gyepi Sam --+-- Designer/Programmer --+-- Network/System Administrator
gyepi@praxis-sw.com --+-- http://www.praxis-sw.com/gyepi
C for yourself. Perhaps this should be Perl for yourself.
------------------------------
Date: 28 Sep 1999 18:50:17 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Sorting weird numeric data
Message-Id: <slrn7v2lg7.9kl.abigail@alexandra.delanet.com>
Bob Walton (bwalton@rochester.rr.com) wrote on MMCCXIX September MCMXCIII
in <URL:news:37F02930.F3C909C@rochester.rr.com>:
[] Mike Sosteric wrote:
[] >
[] > How can I sort strings like this
[] >
[] > 1.1
[] > 1.1.1
[] > 1.1.2
[] > 1.2
[] > 1.3
I think there's a module on CPAN somewhere, but this ought to work as well:
@sorted = map {join "." => @$_}
sort {my $i = 0;
{defined $a -> [$i] or return defined $b -> [$i] ? -1 : 0;
defined $b -> [$i] or return 1;
$a -> [$i] <=> $b -> [$i] or ++ $i && redo}}
map {[split /\./ => $_]}
@unsorted;
Abigail
--
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Tue, 28 Sep 1999 17:16:50 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Sorting weird numeric data
Message-Id: <37F15A72.D0067249@mail.cor.epa.gov>
Uri Guttman wrote:
>
> >>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
>
> LR> I'll keep posting these packed-sort examples until other people
> LR> start to. :-)
>
> we just aren't as famous as the ST yet. :-( we need to be written up in
> a book or somewhere other than our paper. and we need a catchy
> name. anyone have any suggestions? i have seen guttman/rosler sort but
> however gratifying that is, it doesn't roll off the tongue and it not
> likely to be used.
My suggestion:
The GRP [Guttman/Rosler Pack-sort]. It even has a variety
of possible pronunciations. Cassell's 7th Law of Linguistics
says that the pronunciation which is most liked will be one
of the ones you like least [cf 'SCSI'].
You could even re-name your paper "The World According To GRP".
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 28 Sep 1999 17:38:15 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Sorting weird numeric data
Message-Id: <MPG.125aff52db161010989ff6@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <x7zoy6y7k8.fsf@home.sysarch.com> on 28 Sep 1999 18:50:31 -
0400, Uri Guttman <uri@sysarch.com> says...
> >>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
>
> LR> I'll keep posting these packed-sort examples until other people
> LR> start to. :-)
>
> we just aren't as famous as the ST yet. :-( we need to be written up in
> a book or somewhere other than our paper. and we need a catchy
> name. anyone have any suggestions? i have seen guttman/rosler sort but
> however gratifying that is, it doesn't roll off the tongue and it not
> likely to be used.
'GR Sort' would be OK. I thought about 'SSS' (Super String Sort) also.
I agree that we could use help here.
> LR> print map substr($_, 1 + rindex $_, "\0") =>
> LR> sort
> LR> map pack('C*' => split /\./) . "\0$_" =>
>
> you like the rindex \0 trick. seems likes it works in many cases.
Yes. When the data have internal null bytes, 'the rindex \0 trick' will
still work on an index sort.
> this also assumes (probably correctly) tha 1.2 sorts before 1.2.1 but
> does it sort before 1.2.0? the problem space needs to be defined more
> clearly.
Shorter should sort first.
> the ones with the extra .0 sort before shorter strings because
> that byte is compared to the first char of the actual string of the
> short version. i am not claiming it is wrong but not well defined. since
> your data set had 10.0 i think it is legit to try others.
>
> print map substr($_, 1 + rindex $_, "\0") =>
> sort
> map pack('C5' => split /\./) . "\0$_" =>
> <DATA>;
> __END__
...
> that seems to be better. but i think it is using the original key
> appended to the string to compare 2 equivilent values created by the
> padding. this sorta works but i need to look into it more to make sure
> it is ok. i feel there may be a special case where this will fail.
That packs nonexistent trailing values in the list from 'split' into
null bytes. This is exactly what is wanted, but I don't know why '-w'
doesn't complain. It also restricts the number of fields in the input
to a maximum of 5. (But that can be raised arbitrarily without slowing
the sort unduly.)
Note that having done that, one no longer needs the null byte to
separate the sortkey from the data, and can replace the 'rindex' stuff
by simply "substr($_, 5)".
print map substr($_, 5) =>
sort
map pack('C5' => split /\./) . $_ =>
<DATA>;
__END__
> LR> WAGER: No one can write a more efficient solution.
>
> maybe a more correct solution. :-)
'More correct' is similar to 'more perfect' or 'more unique' -- ain't no
such thing. But as modified above, it handles any trailing '.0' fields
just fine.
> LR> EXERCISES:
>
> LR> Modify the above to work with arbitrary 32-bit unsigned integers.
>
> i can't count that high. but the answer is in pur paper.
>
> LR> Modify the above to work with unbounded unsigned integers.
>
> this has me stumped partially. how unbounded is unbounded? if they can be
> printed as ascii strings then you can do a packed sort on those strings.
I had in mind a rather neat article posted by Abigail last week, that
showed how to write a laddered sortsub for arbitrarily long signed
floating-point strings. But a prepass would be required to compute the
appropriate sortkey length for a packed sort. Here's one that just
takes an arbitrary maximum length:
#!/usr/local/bin/perl -w
use strict;
my $max_len = 30;
print map substr($_, 1 + rindex $_, "\0") . "\n" =>
sort
map {
chomp;
join("" => map sprintf("%${max_len}s", $_) =>
split /\./) . "\0$_"
} <DATA>;
__END__
A final note: If all that is being sorted is the list of numbers (a
poor assumption), then appending the entire datum to the sortkey isn't
required. The input can be reconstructed from the sortkey very
straightforwardly.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 29 Sep 1999 00:30:07 GMT
From: eric_poulsen@my-deja.com
Subject: Win32::API -- how to call functions using NULL pointers?
Message-Id: <7srmi3$2et$1@nnrp1.deja.com>
I'm trying to use the Windows NT API to complete a RAS connection. For
some reason the rasdial.exe program has proven itself to be unstable and
prone to lockups.
In any case, I've found that a RasDial function is available via the
rasapi32.dll file. Several of the pointers can be set to NULL according
to the SDK spec for this dll file.
Unfortunately, the documentation for the Win32::API doesn't specify how
to send a NULL pointer. I've tried using "pointers" (scalars) that are
undefined, or set to 0. Of course, if they're set to 0, then it's just
a pointer to that number.
Does anyone know how I'd specify a NULL pointer using the module? I've
included the complete test script I'm using below. My perl is Gurusamy
version 5.004. I've used the Win32::API module with much success in the
past.
Currently, the program below returns error 632, which "should not occur
under normal operation" according to the rasphone.hlp file.
Thanks for your time.
My working description of the function is at:
http://msdn.microsoft.com/library/sdkdoc/network/remacces_22ss.htm
----------------------------------------------------------------------
use Win32::API;
$RasDial = new Win32::API('rasapi32', 'RasDial', [P,P,P,N,P,P], N);
$params{ras_entry} = 'kiosk';
$params{ras_username} = 'not_a_real_user';
$params{ras_password} = 'yeah_right';
$params{ras_number} = '2773500';
$LPRASDIALEXTENSIONS = undef;
$LPSZPHONEBOOK = undef;
$RASDIALPARAMS =
"$params{ras_entry}\x00$params{ras_number}\x00\x00$params{username}\x00$
params{password}\x00\x00";
$RASDIALPARAMS = pack
("L",length($RASDIALPARAMS)+4).$RASDIALPARAMS;
$DWNOTIFIERTYPE = 0;
$LPVNOTIFIER = undef;
$LPHRASCONN = pack("L",0);
$result =
$RasDial->Call($LPRASDIALEXTENSIONS,$LPSZPHONEBOOK,$RASDIALPARAMS,$DWNOT
IFIERTYPE,$LPVNOTIFIER,$LPHRASCONN);
#$result =
$RasDial->Call(undef,undef,$RASDIALPARAMS,$DWNOTIFIERTYPE,undef,undef);
print $result;
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 936
*************************************