[11333] in Perl-Users-Digest
Perl-Users Digest, Issue: 4933 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 18 17:17:18 1999
Date: Thu, 18 Feb 99 14:00:27 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 18 Feb 1999 Volume: 8 Number: 4933
Today's topics:
(blush) Stupid question about Perl in Win/DOS (shudder) <draeger@NOSPAM4ME.uiuc.edu>
Re: (blush) Stupid question about Perl in Win/DOS (shud (Steve Linberg)
ActivePerl for Windows 95 - browser Reed_Wurts@prodigy.net
curious problem (aol? lwp?) (Michael Budash)
Re: DEMO: dynamic scoping and typeglob trickery <tchrist@mox.perl.com>
Re: DEMO: new qr// operator (Ilya Zakharevich)
Re: DEMO: new qr// operator (Randal L. Schwartz)
Re: DEMO: separating stderr (Ilya Zakharevich)
Re: Encrypting then Decrypting a Password? (Michael Budash)
Re: Encrypting then Decrypting a Password? <jeromeo@atrieva.com>
Re: Encrypting then Decrypting a Password? (I R A Aggie)
Re: FAQ 5.16: How can I reliably rename a file? (Ilya Zakharevich)
Re: FAQ 5.16: How can I reliably rename a file? <tchrist@mox.perl.com>
Re: FAQ 5.17: How can I lock a file? (Ilya Zakharevich)
FAQ 5.27: How do I do a C<tail -f> in perl? <perlfaq-suggestions@perl.com>
Re: help! navigating URLs in Perl (Gord Barentsen)
How do you format decimal numbers in Perl? <craig@skybound.demon.nl>
Re: How do you format decimal numbers in Perl? (Steve Linberg)
Re: how to sort by file date with year (Larry Rosler)
Re: Intresting Error droby@copyright.com
Re: number of keys in a hash?? <tchrist@mox.perl.com>
Re: OLE on client browser <sebastien.nadeau@bibl.ulaval.ca>
perl 5.005_02 and Digital Unix 4.0e <harry@damp.atmos.washington.edu>
Re: reading a whole file into a string dhosek@webley.com
Re: reading a whole file into a string (Larry Rosler)
Re: Speed Up Perl <jeromeo@atrieva.com>
Re: Speed Up Perl (I R A Aggie)
Re: Speed <ebohlman@netcom.com>
Re: Speed <ebohlman@netcom.com>
suid script philosophy? <dkoleary@tako.wwa.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 18 Feb 1999 14:30:11 -0600
From: Erik Draeger <draeger@NOSPAM4ME.uiuc.edu>
Subject: (blush) Stupid question about Perl in Win/DOS (shudder)
Message-Id: <36CC7853.AE554FB2@NOSPAM4ME.uiuc.edu>
Hey all,
I've only used Perl in Unix. However, my girlfriend has a tedious
computer task which desperately needs to be automated, and unfortunately
is running on a Win95 machine. I naturally thought of Perl (because,
deep down, I just want to do everything with Perl), so I installed
ActivePerl on the PC, and am now trying to figure out how to do the
following in a command window:
echo "line1\nline2\nline3\n" | C program
(The actual command will be @output = `echo "line1\nline2\nline3\n" |
program`; but it has become clear that DOS doesn't quite grasp the idea
of \n, in that simply typing "echo \n\n\n" at the prompt just returns
exactly that -- \n\n\n, and not three blank lines.)
So the real question is whether or not there is a Windows/DOS equivalent
of \n. Or some syntax (quotes, extra backslash, etc.) that will make it
recognize it as a linefeed. All the DOS/Win faqs and books I've ever
looked at just tell you how to edit autoexec.bat and how to run disk
defrag. Sad, really.
I'd greatly appreciate any advice, etc. on how to do simple tasks on
this infernal operating system. :)
Thanks!!
Erik Draeger
P.S. Also, if someone could tell me how to specify a drive letter in a
path for Win32 Perl, that'd be super. I read in a faq somewhere that
you just use //, but it doesn't seem to work.
e.g.
system("../windows/calc.exe"); <---- runs the calculator
program
system("c://windows/calc.exe"); <---- doesn't.
------------------------------
Date: Thu, 18 Feb 1999 16:25:10 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: (blush) Stupid question about Perl in Win/DOS (shudder)
Message-Id: <linberg-1802991625100001@ltl1.literacy.upenn.edu>
In article <36CC7853.AE554FB2@NOSPAM4ME.uiuc.edu>, Erik Draeger
<draeger@NOSPAM4ME.uiuc.edu> wrote:
> P.S. Also, if someone could tell me how to specify a drive letter in a
> path for Win32 Perl, that'd be super. I read in a faq somewhere that
> you just use //, but it doesn't seem to work.
Backslashes, not forward slashes.
"c:\\foo\\bar\\baz.exe" or 'c:\foo\bar\baz.exe'
--
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
email: <linberg@literacy.upenn.edu>
WWW: <http://www.literacyonline.org>
------------------------------
Date: Thu, 18 Feb 1999 20:45:58 GMT
From: Reed_Wurts@prodigy.net
Subject: ActivePerl for Windows 95 - browser
Message-Id: <7ahu64$vuf$1@nnrp1.dejanews.com>
I need to write a couple of form parsers for a web site.
I downloaded and installed ActiveStates ActivePerl for Win32 (and also the
required DCOM for Windows 95 from the Microsoft site).
I saw the messages posted here at DejaNews comp.lang.perl.misc, but am still
having trouble.
I am running Windows 95. I am using Netscapes 4.5 browser, but have IE 4.01
available on another machine if neccesary.
Do I really need Server software installed to get an html form to use a perl
script to process the form input? Shouldnt I be able to just submit info to
the perl routines the same way I can call up Java applets from my browser?
I noticed (because of the do you wish to review the release notes? question
at the end of the ActivePerl install) that am able to call up the browser by
opening the DOS-prompt window, finding the proper directory, and typing
start release.htm. (the DOS commands in my little-blue-pocket-PCRef, by
Glover & Young, doesnt list start as a DOS command [through version 6.22].
So is start a DOS 7 command or a Perl command?
With one exception, every time I try start whatever.pl, I get error
messages and then then the DOS (or Perl at this time?) window closes so fast
I cant read the error messages. (No, the close on exit box is not checked in
the perl.exe file properties sheet).
I did get the simplest of all files to run, a one line file named
helloworld.pl:
print "Hello World!\n";
but, the window again dissappears in a fraction of a second.
I tried to figure out Steve Palincsars (see comp.lang.perl.misc, Date:
1999/02/01, Re: i may be stupid) answer to Jons message (see
comp.lang.perl.misc, Date: 1999/02/02, Title: i may be stupid, Author: jon
<jon@jonstuff.force9.co.uk>, but I need it explained more clearly, maybe a
listing of the corrected files. (Jon did say he had the Sambar Server, but I
dont have any)
So, Im trying to figure out how I can get started with:
1) being able to read the error messages before the window closes.
2) getting a simple html form submit action to generate a response back to
the browser.
3) once I have figured those things out, my goal is to have the form info
parsed, returned to the browser for viewing, and emailed to me. [eventually I
want to do the same, and also save the form info for every submitter in a
file, in my secure cgi-bin folder on a remote Windows NT IIs 4.0 (I think)
server].
Anybody, help?
Reed Wurts
Reed_Wurts@prodigy.net
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 18 Feb 1999 12:30:54 -0800
From: mbudash@trantracks.com (Michael Budash)
Subject: curious problem (aol? lwp?)
Message-Id: <mbudash-1802991230540001@d51.nas1.napa.sonic.net>
hey all -
got a perl shopping cart script (non-parsed-header) i mod'd to do live c/c
dinging. uses LWP module to contact the c/c processor. there's logging to
a file at certain steps along the way, like just before the c/c processor
is contacted, and just after it comes back. problem is, sometimes the
pre-cc-processor log is written, then that's it - no post-cc-processor log
entry. the script doesn't die (nothing in the error log), it just, well,
stops.
this is perplexing to me, esp. since the c/c *is* being charged, but the
product *isn't* delivered, since that can only happen if the script
continues on to where it emails it (the product, a zipfile of midi files)
to the surfer.
so far, my only real clues are that it's happening for aol 4.x folks,
though not *all* aol 4.x folks.
anybody have any thoughts on this? what the heck can i do? is it some kind
of LWP issue? an AOL issue? aaarrrggghhhhh!!!
--
@-----------------------------@--------------------@
| Michael Budash Consulting | 707-255-5371 |
| Perl, Javascript, Html | 707-258-7800 x7736 |
| Official Extropia Developer | mbudash@sonic.net |
@-----------------------------@--------------------@
------------------------------
Date: 18 Feb 1999 13:03:00 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: DEMO: dynamic scoping and typeglob trickery
Message-Id: <36cc71f4@csnews>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, gward@cnri.reston.va.us (Greg Ward) writes:
:> defined $id{$id} ? $id{$id} : ($id{$id} = id);
:
:Shouldn't that be either "&id" or "id()"? As it stands, it gets
:compiled as a bareword, and the script's output is
That's right. It should be &id. The darn compiler refuses
to count it as a function until it's done compiling it. This
always tricks me.
--tom
--
X-Windows: A moment of convenience, a lifetime of regret.
--Jamie Zawinski
------------------------------
Date: 18 Feb 1999 20:48:52 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: DEMO: new qr// operator
Message-Id: <7ahubk$1f4$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tom Christiansen
<tchrist@mox.perl.com>],
who wrote in article <36cc2514@csnews>:
> This shows how to use spiffy new qr// operator, with /i flag even.
>
> use 5.005;
> @popstates = qw(CO ON MI WI MN);
> @poppats = map { qr/\b$_\b/i } @popstates;
> while ($line = <>) {
> for $patobj (@poppats) {
> print $line if $line =~ /$patobj/;
> }
> }
And I repeat: there should be no need to use qr// in such simple
contexts.
@poppats = map { "(?i)\b$_\b" } @popstates;
while ($line = <>) {
for $pat (@poppats) {
print $line if $line =~ /$pat/;
}
}
*should* cache the results of compilation - behind the scenes (say, to
speed up old programs, *and* to simplify new ones). A 3-line patch
which implemented this is available on p5p archives.
Ilya
------------------------------
Date: 18 Feb 1999 13:34:48 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: DEMO: new qr// operator
Message-Id: <m14soj1jlz.fsf@halfdome.holdit.com>
>>>>> "Ilya" == Ilya Zakharevich <ilya@math.ohio-state.edu> writes:
Ilya> And I repeat: there should be no need to use qr// in such simple
Ilya> contexts.
Ilya> @poppats = map { "(?i)\b$_\b" } @popstates;
Ilya> while ($line = <>) {
Ilya> for $pat (@poppats) {
Ilya> print $line if $line =~ /$pat/;
Ilya> }
Ilya> }
Ilya> *should* cache the results of compilation - behind the scenes (say, to
Ilya> speed up old programs, *and* to simplify new ones). A 3-line patch
Ilya> which implemented this is available on p5p archives.
But when would the cache be freed? With qr//, I can "manage a cache"
myself. Think "mod_perl" and other long-living applications.
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 18 Feb 1999 20:40:22 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: DEMO: separating stderr
Message-Id: <7ahtrm$14a$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tom Christiansen
<tchrist@mox.perl.com>],
who wrote in article <36cc1e52@csnews>:
> open (CMD,
> "(cmd args | sed 's/^/STDOUT:/') 2>&1 |");
>
> while (<CMD>) {
> if (s/^STDOUT://) {
> print "line from stdout: ", $_;
> } else {
> print "line from stderr: ", $_;
> }
> }
Btw, can somebody try to do it with Open2, select() and read(1byte) -
accumulating results until \n?
Ilya
------------------------------
Date: Thu, 18 Feb 1999 12:29:11 -0800
From: mbudash@trantracks.com (Michael Budash)
Subject: Re: Encrypting then Decrypting a Password?
Message-Id: <mbudash-1802991229110001@d51.nas1.napa.sonic.net>
In article <36CC30E2.1C265B2F@loraincounty.com>, Mike Skimin
<mskimin@loraincounty.com> wrote:
>Hello All,
>
> Please excuse my ignorance on this.
>
> I have a Perl program that connects to a MySQL Database. In order
>for the connection to work I must put in my admin password, in non
>encrypted form in the script.
>
> This frightens me a little. Is there a way I can put an encrypted
>password in the script then have the script decrypt it so when it is
>passed to MySQL it is the correct password. Thus never having my admin
>password in plan form?
>
> I kind of understand the crypt function but can't figure out how to
>go from a crypt password back to normal.
>
> Any and all help is appreciated.
not sure how to answer the first part, but i do know you can't [at the
very least: easily] decrypt data 'A' that's been crypt'd. what you do is
crypt data 'B', and if the two encryptions match, then data 'A' = data
'B'.
hth -
--
@-----------------------------@--------------------@
| Michael Budash Consulting | 707-255-5371 |
| Perl, Javascript, Html | 707-258-7800 x7736 |
| Official Extropia Developer | mbudash@sonic.net |
@-----------------------------@--------------------@
------------------------------
Date: Thu, 18 Feb 1999 13:16:42 -0800
From: Jerome O'Neil <jeromeo@atrieva.com>
To: Mike Skimin <mskimin@loraincounty.com>
Subject: Re: Encrypting then Decrypting a Password?
Message-Id: <36CC833A.FADEAB10@atrieva.com>
Mike Skimin wrote:
> I kind of understand the crypt function but can't figure out how to
> go from a crypt password back to normal.
>
> Any and all help is appreciated.
You can't go back. crypt() uses a one-way hash. Pick up a copy of
Bruce Schneier's Applied Cryptography for all the exciting detail of one
way hash algorithms, and other cryptographic toppics, including secure
logon.
Sadly, there is no perl source, only C.
--
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947
The Atrieva Service: Safe and Easy Online Backup http://www.atrieva.com
------------------------------
Date: 18 Feb 1999 21:33:13 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Encrypting then Decrypting a Password?
Message-Id: <slrn7cp1th.fvc.fl_aggie@enso.coaps.fsu.edu>
aOn Thu, 18 Feb 1999 10:25:22 -0500, Mike Skimin
<mskimin@loraincounty.com> wrote:
+ I have a Perl program that connects to a MySQL Database. In order
+ for the connection to work I must put in my admin password, in non
+ encrypted form in the script.
No, your script should be prompting you for it. There is a way of
reading in from STDIN without echoing it to the screen, but I
don't know what that is. :( But it has been posted here, so it
may be findable.
And if you're very cautious, you may want the script to do a checksum
on itself, to insure no tampering has occured...
+ I kind of understand the crypt function but can't figure out how to
+ go from a crypt password back to normal.
Mainly because you can't. This is a feature, not a bug.
James
------------------------------
Date: 18 Feb 1999 20:35:19 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: FAQ 5.16: How can I reliably rename a file?
Message-Id: <7ahti7$uo$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tom Christiansen
<perlfaq-suggestions@perl.com>],
who wrote in article <36cc1582@csnews>:
> How can I reliably rename a file?
>
> Well, usually you just use Perl's rename() function. But that may not
> work everywhere, in particular, renaming files across file systems.
This description is has serious flaws, since it does not explain the
difference of rename()ing on POSIX and DOSISH systems.
On DOSISH systems you cannot rename() if the target exists. Moreover,
you cannot unlink() the target if it is readonly, you need to chmod()
it first. Additionally, if either source or target are locked (say,
open()ed) everything is lost.
Ilya
------------------------------
Date: 18 Feb 1999 14:00:44 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: FAQ 5.16: How can I reliably rename a file?
Message-Id: <36cc7f7c@csnews>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
:This description is has serious flaws, since it does not explain the
:difference of rename()ing on POSIX and DOSISH systems.
No sir, it's your embarrassingly miserable excuse for a disk loader
that has serious flaws. Upgrade to a real system, or fix the perl port
in question. Perl is supposed to be the same everywhere, insofar as
this is possible. In this case, it is. Just because whoever did the
CP/M port got it wrong doesn't mean that the fault lies in Perl.
Bark up another tree. Don't you have something you could be
writing documentation and test suites for?
--tom
--
Sockets are the X windows of IO interfaces. --Rob Pike
------------------------------
Date: 18 Feb 1999 20:42:46 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: FAQ 5.17: How can I lock a file?
Message-Id: <7ahu06$17i$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tom Christiansen
<perlfaq-suggestions@perl.com>],
who wrote in article <36cc214d@csnews>:
> of native locking. Here are some gotchas with Perl's flock():
>
> 1 Produces a fatal error if none of the three system calls (or their close
...
> 2 lockf(3) does not provide shared locking, and requires that the
...
> 3 Some versions of flock() can't lock files over a network (e.g. on NFS
...
4 On some systems locking files is advisory only.
Ilya
------------------------------
Date: 18 Feb 1999 14:27:18 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 5.27: How do I do a C<tail -f> in perl?
Message-Id: <36cc85b6@csnews>
(This excerpt from perlfaq5 - Files and Formats
($Revision: 1.34 $, $Date: 1999/01/08 05:46:13 $)
part of the standard set of documentation included with every
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq5.html
if your negligent system adminstrator has been remiss in his duties.)
How do I do a `tail -f' in perl?
First try
seek(GWFILE, 0, 1);
The statement `seek(GWFILE, 0, 1)' doesn't change the current position,
but it does clear the end-of-file condition on the handle, so that the
next <GWFILE> makes Perl try again to read something.
If that doesn't work (it relies on features of your stdio
implementation), then you need something more like this:
for (;;) {
for ($curpos = tell(GWFILE); <GWFILE>; $curpos = tell(GWFILE)) {
# search for some stuff and put it into files
}
# sleep for a while
seek(GWFILE, $curpos, 0); # seek to where we had been
}
If this still doesn't work, look into the POSIX module. POSIX defines
the clearerr() method, which can remove the end of file condition on a
filehandle. The method: read until end of file, clearerr(), read some
more. Lather, rinse, repeat.
There's also a File::Tail module from CPAN.
--
"The purpose of most computer languages is to lengthen your resume by
a word and a comma." --Larry Wall
------------------------------
Date: Thu, 18 Feb 1999 20:02:51 GMT
From: gpb@ppaolucci.com (Gord Barentsen)
Subject: Re: help! navigating URLs in Perl
Message-Id: <36cd71b5.20009368@news.the-wire.com>
yes...no luck. I tried using the LWP module as well, and that
has not worked. It doesn't seem to be recognizing the Location:
header in the print statement.
On Thu, 18 Feb 1999 14:46:22 -0500, "Professeur Alfred"
<ughridk@bbbhotmail.com> wrote:
>Did you write the "\n\n" at the end of your statement?
>
>Gord Barentsen a icrit dans le message
><36cc514a.11708929@news.the-wire.com>...
>>
>>
>> Hello,
>> I am currently having a problem with a Perl script that asks
>>for userID and password and then, upon receiving correct validation,
>>goes directly to an order form.
>> I need to push the client directly to the form page, but I
>>need to carry over a string of values in the Location line to be
>>harvested for populating text fields. I have tried the CGI Location
>>header, i.e.
>>
>>print "Location:
>>http://somewhere.com/perlscript.pl?name1=value1&name2=value2 etc.
>>etc., but it doesn't seem to want to work - it just displays the
>>string to the screen.
>>
>> Is there a Perl function that can be used to push to another
>>webpage/perl script that will carry name-value pairs over with it? If
>>you reply, please reply to the list and to my email
>>(gpb@ppaolucci.com). Thanks a lot!
>>
>>Gord Barentsen
>>
>>
>
------------------------------
Date: Thu, 18 Feb 1999 22:01:25 +0100
From: Craig <craig@skybound.demon.nl>
Subject: How do you format decimal numbers in Perl?
Message-Id: <36CC7FA5.6E51@skybound.demon.nl>
Hi,
I'm a Windows programmer and don't know much about Perl.
I'ld like to know how you format a number so that you always have a
fixed number of decimal places.
Example:
4.5 -> 4.50
-Craig.
P.S. I use Windows (and have no "man" stuff).
------------------------------
Date: Thu, 18 Feb 1999 16:22:48 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: How do you format decimal numbers in Perl?
Message-Id: <linberg-1802991622480001@ltl1.literacy.upenn.edu>
In article <36CC7FA5.6E51@skybound.demon.nl>, Craig
<craig@skybound.demon.nl> wrote:
> I'ld like to know how you format a number so that you always have a
> fixed number of decimal places.
printf / sprintf
> P.S. I use Windows (and have no "man" stuff).
The documentation should still be on your system, unless you threw it away.
--
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
email: <linberg@literacy.upenn.edu>
WWW: <http://www.literacyonline.org>
------------------------------
Date: Thu, 18 Feb 1999 12:38:58 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: how to sort by file date with year
Message-Id: <MPG.11361a3d2c771bea989a58@nntp.hpl.hp.com>
In article <7ahpfn$rjv$1@nnrp1.dejanews.com> on Thu, 18 Feb 1999
19:25:55 GMT, glenn.west@ptsc.slg.eds.com <glenn.west@ptsc.slg.eds.com>
says...
> In article <36c91404.39026059@news.enteract.com>,
> syarbrou@nospam.enteract.com (Steve .) wrote:
> > I have a list of files with the year in it. I want to sort from
> > newest to oldest. Thought of a system call with a reverse listing,
> > but didn't work, because it doesn't account for the year the way I
> > want. Basically it looks like this:
> >
> > PC122198
> > PC010799
> >
> > Linux/UNIX thinks that 122198 is newer because technically it's a
> > larger number. How would you do a sort so that it sets the second
> > file as the newer one in the list? Thanks. By the way, this sort
> > would be done on a large group of files.
>
> I think you're looking for the sort options "sort -r +0.7 inputfile", or
> something like that...
That is too simple, as it fails when the year rolls over, which is
darned soon now!
Here's an ST-based Perl solution:
#!/usr/local/bin/perl -w
use strict;
my @a = qw(
PC122298
PC122100
PC122200
PC010799
);
print map "$_->[0]\n",
sort { $b->[1] <=> $a->[1] || $b->[0] cmp $a->[0] }
map { [ $_,
substr($_, 6, 2) + 100 * (substr($_, 6, 2) < 70) ]
} @a;
__END__
PC122200
PC122100
PC010799
PC122298
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 18 Feb 1999 20:11:14 GMT
From: droby@copyright.com
Subject: Re: Intresting Error
Message-Id: <7ahs4p$u6k$1@nnrp1.dejanews.com>
In article <7afid3$m4t@bgtnsc02.worldnet.att.net>,
"Justin Saul" <wfs-dominion@worldnet.att.net> wrote:
> Hi,
> I took a standard Guestbook CGI and modified it heavily to do what I want.
> I actually changed it to become a very nice XML Database utility. When I
> check for syntax errors on the server it comes back saying there are none.
> "Great" I say. So I run it...bah comes back with an Internal Error (500), so
> I went back and "chmod 755" then made sure I uploaded it correctly.
> In the code I require "cgi-lib.pl" and made sure all those links were
> correct. Does anyone have an idea of what went wrong?
Yes. There are many things that might be wrong.
> Also I didn't really change to much and the code makes sense. It should
> have worked.
>
Did you consider looking at the FAQ?
There is a nice little section in perlfaq9 with the heading "My CGI script
runs from the command line but not the browser. (500 Server Error)". Reading
it might help.
The FAQ should be on your system. It's also on-line at http://www.perl.com.
--
Don Roby
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 18 Feb 1999 13:06:44 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: number of keys in a hash??
Message-Id: <36cc72d4@csnews>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, f rosen <f_rosen@hotmail.com> writes:
:How can I find the number of keys in a hash _without_ looping over the
:hash with a foreach or map loop?
It would appear that you have been negligent in perusing the standard
perl documentation and in particular its frequently asked questions list,
which you have on your very own system because it comes with every valid
distribution of Perl, answers your question.
% man perlfaq4
...
How can I know how many entries are in a hash?
If you mean how many keys, then all you have to do is take the
scalar sense of the keys() function:
$num_keys = scalar keys %hash;
In void context it just resets the iterator, which is faster for
tied hashes.
Ignorance of the documentation need not be a permanent condition.
Good luck.
--tom
--
Fancy algorithms are slow when n is small, and n is usually small. --Rob Pike
------------------------------
Date: Thu, 18 Feb 1999 21:29:41 GMT
From: Sebastien Nadeau <sebastien.nadeau@bibl.ulaval.ca>
Subject: Re: OLE on client browser
Message-Id: <36CC82F5.7C1AFFC1@bibl.ulaval.ca>
> I want to dump an HTML file to MS Excel or Word. I have already written a
> front end using PERL and ODBC and a CGI script for DB manipulation via a web
> page, but once I am done I would like for the Web Client to be able to dump
> the results to an excel spreadsheet. This works fine now if I am on the web
> server with MS Office and Perl installed, but how do I use OLE to open an
> excel session on a client that does not have perl installed (local) ? Am I
> gonna have to use an Active-x control or something to allow a browser to
> manipulate an OLE session on the client side after perl manipulates the
> server-side DB?
Can't do something like that. Allowing a javascript or Active-X control to do
such a thing on the client side would be a huge security hole. You could then
execute anything (including viruses) on the client computer and I guess nobody
wishes to visit a Web site that will infect his computer.
Sebastien Nadeau
------------------------------
Date: 18 Feb 1999 12:31:47 -0800
From: Harry Edmon <harry@damp.atmos.washington.edu>
Subject: perl 5.005_02 and Digital Unix 4.0e
Message-Id: <x7emnncv2k.fsf@damp.atmos.washington.edu>
I cannot get the tests to work for perl under Digital Unix 4.0e. I am
using "Configure -des" and when I run the tests I get:
op/pack............FAILED at test 9
When I run the individual test I get:
not ok 9 1.84467440737096e+19
Anyone else see this? It works fine under 4.0d.
--
Dr. Harry Edmon E-MAIL: harry@atmos.washington.edu
(206) 543-0547 FAX: (206) 543-0308
Dept of Atmospheric Sciences
University of Washington, Box 351640, Seattle, WA 98195-1640
------------------------------
Date: Thu, 18 Feb 1999 20:24:12 GMT
From: dhosek@webley.com
Subject: Re: reading a whole file into a string
Message-Id: <7ahst2$up8$1@nnrp1.dejanews.com>
In article <x3y7ltijpvg.fsf@tigre.matrox.com>,
Ala Qumsieh <aqumsieh@matrox.com> wrote:
> Mike Arms <marms@sandia.gov> writes:
> > undef $/; open(IN, $fn); $s = <IN>; close(IN);
> > print length($s) . "\n"; # Some test to see if it read whole file
> As a note, always try to localize any changes to your global variables
> as you might forget (later on in the program) the changes you have
> made.
> { undef $/; local @ARGV = ($fn); $s = <> }
Or, rather than mucking about with $/, one could do something like:
$s = join "\n", <IN>;
because there's always more than one way to solve a problem.
This is probably slower than the $/ solution, but will be a bit less opaque to
the casual perl reader.
-dh
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 18 Feb 1999 12:52:10 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: reading a whole file into a string
Message-Id: <MPG.11361d56aec43198989a59@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7ahst2$up8$1@nnrp1.dejanews.com> on Thu, 18 Feb 1999
20:24:12 GMT, dhosek@webley.com <dhosek@webley.com> says...
...
> Or, rather than mucking about with $/, one could do something like:
> $s = join "\n", <IN>;
Is there a particular reason why you want to add an empty line after
every line in the file? I think you mean:
$s = join "", <IN>;
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 18 Feb 1999 12:56:49 -0800
From: Jerome O'Neil <jeromeo@atrieva.com>
Subject: Re: Speed Up Perl
Message-Id: <36CC7E91.17C4FD45@atrieva.com>
If you guys would use Debug::Psychic you could prognosticate with a much
higher degree of acuracy.
Ala Qumsieh wrote:
>
> fl_aggie@thepentagon.com (I R A Aggie) writes:
>
> >
> > On 17 Feb 1999 09:04:15 -0500, Clay Irving <clay@panix.com> wrote:
> >
> > + How do you expect anyone to tell you how to speed up your program
> > + without posting the program? The usual answer in this case is improve
> > + line 17...
> >
> > No, you fool! Its line 21!
>
> I believe lines 17 thru 21 (inclusive) can be safely deleted without
> any loss of functionality. The real problem lies in the OS. Switch to
> Linux and go get a refund for Winblows from Micro$oft.
>
> Ala
--
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947
The Atrieva Service: Safe and Easy Online Backup http://www.atrieva.com
------------------------------
Date: 18 Feb 1999 21:35:36 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Speed Up Perl
Message-Id: <slrn7cp221.gi3.fl_aggie@enso.coaps.fsu.edu>
On Thu, 18 Feb 1999 12:56:49 -0800, Jerome O'Neil <jeromeo@atrieva.com> wrote:
+ If you guys would use Debug::Psychic you could prognosticate with a much
+ higher degree of acuracy.
I just downloaded and installed that module! Thanks! Boy, you sure did
have a disgusting thought there...ow! another one! Stop that!
James
------------------------------
Date: Thu, 18 Feb 1999 20:46:38 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Speed
Message-Id: <ebohlmanF7DB1q.4vF@netcom.com>
------------------------------
Date: Thu, 18 Feb 1999 20:48:08 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Speed
Message-Id: <ebohlmanF7DB48.4zI@netcom.com>
ghost <haiti@stc.com> wrote:
: Would Perl be a feesible language to use if I wanted to interface with a
: MSQL database built to handle large amounts of traffic ie. database quering
: and such, on the web?
Yes. Regardless of what language you're using, you should avoid opening
and closing a database connection on each query. See
comp.infosystems.www.authoring.cgi for more information.
------------------------------
Date: 18 Feb 1999 21:31:34 GMT
From: "Douglas K. O'Leary" <dkoleary@tako.wwa.com>
Subject: suid script philosophy?
Message-Id: <7ai0rm$n4l$1@hirame.wwa.com>
Hi;
I've been tasked to develop a script that will allow certain users
to kill the processes of other users. Yes, I know this is an
incredibly stupid thing to do - and I've even convinced most
people that this is an incredibly stupid thing to do. However,
some pinheaded, flaming idiot of a salesman wrote it into the contract
as a requirement and, naturally, the client is complaining about
their inability to do this incredibly stupid thing. Enough ranting,
on to the question:
As I see it, I have two choices (three including leaving...)
1. Write a script that runs as a normal user and does all
the error checking, logging, and protection. This script will
then call a suid script which does the actual process killing.
2. Write one script that runs suid root that does everything.
I was originally leaning towards the first option - following the
C programming philosophy of keeping root privs to the absolute
minimum needed. However, if someone finds the second script, it
doesn't take a rocket scientist to figure out how they could
bring my system down.
The second option appears to be more secure, because the protection
logic and the actual killing are kept in one place; but, the script
as a whole will run suid instead of just the kill command - at least
as I understand it from the perlsec manpage.
So, what I'm looking for is which option is better? Any other tips/
suggestions will be greatly appreciated.
Thanks for your time.
Doug O'Leary
--
--------------------
Douglas K. O'Leary
Senior System Admin
dkoleary@mayspeh.com
dkoleary@wwa.com
--------------------
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 4933
**************************************