[7780] in Perl-Users-Digest
Perl-Users Digest, Issue: 1405 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 3 09:23:59 1997
Date: Wed, 3 Dec 97 06:00:47 -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 Wed, 3 Dec 1997 Volume: 8 Number: 1405
Today's topics:
'Middle of String' sort revisited cotal@delphi.com
Re: 2 element associate array <apeterso@ctberk.com>
Re: Alphanumeric Ranges Using .. and ++ <rootbeer@teleport.com>
Announcing availability of Crowds 1.1.1 for Win95, WinN (Aviel Rubin)
Anyone Successfully compiled 5.004_4 on DG/UX? <sherlock.holmes@worldnet.att.net>
Re: eval, catch/try, and parameters <bowlin@sirius.com>
Re: Executing an external command from a Perl CGI (Jay Herder)
Ignore a "bad free"? <sherlock.holmes@worldnet.att.net>
Re: open and whitespace (Bart Lateur)
Re: Perl Plug-In for Netscape? <eric@hilding.com>
Re: perl-cgi frames (Andrew Williams)
Re: Random numbers, perl and win95 :( <rootbeer@teleport.com>
Re: Scheduling the execution of a script (John Erjavec V)
Re: Trimming space <rootbeer@teleport.com>
Re: Window dies/string error <rootbeer@teleport.com>
Re: Windows 95 flock problem (hapless newbie question) <warren@brachot.jct.ac.il>
Re: Year 2000: -M -A -C operators <rpsavage@ozemail.com.au>
Re: Year 2000: -M -A -C operators (I R A Aggie)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 02 Dec 1997 18:13:27 -0600
From: cotal@delphi.com
Subject: 'Middle of String' sort revisited
Message-Id: <881077541.4294@dejanews.com>
I've read several notes and references, but still don't follow how to
accomplish the following.
Want to sort an array of links based on a string in the middle, in my case
the country and state abbreviation (US-...)
for example, input array contains;
<li><a href="..pnj.txt">US-NJ-North </a>
<li><a href="../IPS006.txt">US-CA-Anaheim </a>
when sorted should result in a string containing;
<li><a href="../IPS006.txt">US-CA-Anaheim </a>
<li><a href="..pnj.txt">US-NJ-North </a>
I've unsuccessfully tried variations of the following;
#!/usr/local/bin/perl5
open(FILE,"$addpage") || &unable("$addpage"); #addpage contains the list
@contents=<FILE>; #get contents
close(FILE);
@sorted_contents=sort { substr($a, 59) <=> substr($a, 59) } @contents;
What I want to do is find "US-" in each line then print them out in sorted
order.
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Tue, 02 Dec 1997 14:13:50 -0800
From: Arvid Peterson <apeterso@ctberk.com>
Subject: Re: 2 element associate array
Message-Id: <3484881E.4E9993E0@ctberk.com>
Actually, there is a section on simulated md arrays in the typerl 5 book (if it
is the one by SAMS that you are referring to). Take a look at page 640. I
actually use this type of array processing quite a bit, but with textual array
pointers instead of numeric. My bet is that you are running into problems with
the numbers. Either that or, taking your example literally, you are defining the
array wrong using parentheses '()' instead of brackets '{}'.Hope this helps out
a bit.
cheers.
> Mark Aurit wrote
> >I cant figure out how to work a 2-element associate array table. With a
> >...
> >with <array>(1,2). But Im having no luck, I can work a single element hash,
> >...
> >The book Im using (Teach Yourself perl 5... I know, its not the Camel book,
> >but isnt bad) doesnt mention how to do this.
>
------------------------------
Date: Tue, 2 Dec 1997 15:58:08 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Mark Stallard <mrs@cae091.ed.ray.com>
Subject: Re: Alphanumeric Ranges Using .. and ++
Message-Id: <Pine.GSO.3.96.971202155359.19514L-100000@usertest.teleport.com>
On Mon, 1 Dec 1997, Mark Stallard wrote:
> I'm writing a module which must generate sequences of alphanumeric
> strings. For example, the module might be asked to issue the first
> 3 "numbers" between 1715A51882 and 1715A51932, and it would return
> the list ( 1715A51882, 1715A51883, 1715A51884 ). The next request
> would begin where the previous request left off.
Hmmm... You haven't yet given a full specification: What comes after
1715A99999? It it 1715B00000 or 1715A100000? Or maybe 1715A9999A? :-)
> Other functions would include boolean test for whether or not a
> value lies in a given range, and a count of values not yet issued
> from a given range.
Oh, even more difficult! :-) But here's an easy way to do what you want:
Create a pair of functions to map your strings to (say) bitstrings, and
back again. Armed with those conversion functions, it's trivial to
increment, decrement, or compare these values. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 2 Dec 1997 22:04:50 GMT
From: rubin@quip.eecs.umich.edu (Aviel Rubin)
Subject: Announcing availability of Crowds 1.1.1 for Win95, WinNT, Unix
Message-Id: <6620m2$mlh$1@news.eecs.umich.edu>
Crowds is written entirely in Perl and full source code
is now available.
Top 10 reasons why you might be interested in Crowds
10. The price - crowds is free
9. Easy to install - download the code, untar, and run.
Then, simply point your browser proxy settings to
it and you can browse anonymously
8. Public service - by running the crowds code, you provide
others with anonymity, even if you don't use it all the
time.
7. Big brother is on the net - this helps you hide
6. It's nobody's business what you are browsing
5. For this to work, there needs to be a large user community
4. Portable - now works on Windows95, WindowsNT, and all
versions of Unix we tried
3. Win Crowds T-shirts and coffee mugs - details to come
2. Take a stand for privacy
1. Don't be the last person on the Internet to obtain privacy
More information, including full source code is avilable at
http://www.research.att.com/projects/crowds.
- Mike Reiter
- Avi Rubin
*********************************************************************
Aviel D. Rubin rubin@research.att.com
Secure Systems Research Dept. Adjunct Professor at NYU
AT&T Labs - Research
180 Park Avenue http://www.research.att.com/~rubin/
Florham Park, NJ 07932-0971 Voice: +1 973 360-8356
USA FAX: +1 973 360-8809
--> Check out http://www.clark.net/pub/mjr/websec/ for a new
book on web security (The Web Security Sourcebook).
*********************************************************************
------------------------------
Date: Tue, 2 Dec 1997 18:15:04 -0500
From: "Alan Fahrner" <sherlock.holmes@worldnet.att.net>
Subject: Anyone Successfully compiled 5.004_4 on DG/UX?
Message-Id: <66252k$52h@mtinsc04.worldnet.att.net>
Hi...
I'm having difficulties compiling perl5.004_4 on a DG/UX box 4.11MU03
(non-intel)...
Anyone been successful that could tell me what they did differently than
follow the defaults?
Thanks
Alan
------------------------------
Date: Tue, 02 Dec 1997 15:57:42 -0800
From: Jim Bowlin <bowlin@sirius.com>
To: Aaron Minner <minner@chirondiag.com>
Subject: Re: eval, catch/try, and parameters
Message-Id: <3484A076.6C161BF6@sirius.com>
Try using
$proto = (getprotobyname( "tcp"))[2]
in step 4.
------------------------------
Date: Tue, 2 Dec 1997 15:14:53 GMT
From: jay.herder@boeing.com (Jay Herder)
Subject: Re: Executing an external command from a Perl CGI
Message-Id: <EKKz0t.54w@news.boeing.com>
Just use the following:
$cmd = "ls -la"; # whatever
open (DOIT,"$cmd | ") || die "Couldn't open $cmd; $!\n";
while (<DOIT>) {
print "$_"; # or put in an array or whatever
}
close (DOIT);
Jay Herder
In article <347AA297.32C09ED6@pge.com>, Billy Glenn <bdg3@pge.com> wrote:
>Fellow Perl Hacks-
>
>I've been on a binge of developing Perl CGI interfaces for routine
>administration tasks on many of our infrastructure unix systems. In
>each of these cases (things ranging from kicking off an RDIST job to
>push an update to a web server, user and paging service administration,
>adding and deleting records from DBM database files), the task which
>ALWAYS causes me grief is executing external commands (i.e. running
>another script, executing a command line, etc). In one case (my
>earliest CGI, written 'the hard way') I ended up having to fork off
>another process to run the RDIST. Then I discovered cgi-lib.pl, and
>created a few more admin tools. This time I was finally able to make it
>work by simply doing a:
>
> print `/usr/local/bin/myscript.pl`;
>
>Now, my newest effort (since discovering the JOYS of CGI.pm!!)
>incorporates many of the previous functions, and needs to invoke several
>external commands. I've tried using system like this:
>
> system ("/usr/local/db2file.pl");
>
>as well as the previously shown 'backtick' method. Obviously I don't
>want to 'exec', as I want to retain control of the flow of execution.
>Ideally, I would like the invocation to return the output of the called
>script (i.e. $output = `/usr/local/db2file.pl`;) so that I could later
>use this output in my HTML.
>
>I'm not sure why this is so difficult - in a regular Perl script both of
>the methods above seem to work (some of the tools started as
>command-line scripts before they were CGIs). I've unbuffered standard
>out to no avail - and really don't want to deal with the mess of forking
>of a new process (which caused it's own set of difficulties ;-) if I can
>help it.
>
>I've pored over both the camel book and 'Advanced CGI Programming', as
>well as everything I can read about CGI.pm - but nothing seems to help
>me with this (embarassingly simple-seeming) problem! Since it seemed
>like my results varied as I began using cgi-lib.pl, and then CGI.pm, I'm
>wondering if these might be effecting the way external commands are
>executed. In my CGI.pm scripts, I'm using the 'standard' methods as
>follows:
>
> use CGI qw(:standard);
>
>Any suggestions, comments, or examples are greatly appreciated. If
>anyone has specific questions regarding my code or would like to see
>full examples demonstrating the problem, I will be happy to provide
>whatever is necessary to help resolve this pesky problem..
>
>Thanks in advance, and have a great day!
>Billy Glenn
>Sr. Network Specialist - Internet Services
>Pacific Gas & Electric Co.
>bdg3@pge.com
>
=======================================================\
| Jay Herder Unix Technical Services Boeing Wichita |
| (8)523-4795 Jay.Herder@Boeing.Com M/S K79-66 |
|_______________________________________________________|
------------------------------
Date: Tue, 2 Dec 1997 18:17:03 -0500
From: "Alan Fahrner" <sherlock.holmes@worldnet.att.net>
Subject: Ignore a "bad free"?
Message-Id: <66252r$52h@mtinsc04.worldnet.att.net>
Hi Again...
I've written a perl program that is sometimes causing an error message I
never got before about a bad free being ignored.
Research leads me to believe that this is an internal perl error.
Is this bad free safe to ignore? Is it safe to ignore if the program is
going to run as root (I have the -T flag going)?
Thanks!
Alan
------------------------------
Date: Tue, 02 Dec 1997 22:38:42 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: open and whitespace
Message-Id: <34848dc4.10330678@news.tornado.be>
Oh by the way, I didn't hear you complain about any troubles in using
files with names starting with any of these characters:
+><|
That, too, are legal characters for filenames, on a Mac.
HTH,
Bart.
------------------------------
Date: Tue, 02 Dec 1997 15:29:07 -0800
From: Eric Hilding <eric@hilding.com>
Subject: Re: Perl Plug-In for Netscape?
Message-Id: <348499C3.7B1A@_hilding.com>
Eric Hilding wrote:
***UPDATED***
>
> Tad McClellan (tadmc@metronet.com) wrote:
> : Eric Hilding (eric@hilding.com) wrote:
> : : I've looked around but just can't seem to find the
> : : info on an alleged Perl 'Plug-In' for Netscape. Any
> : : references would be appreciated. Tnx.
>
> : Where did you hear the allegations?
>
> It was on a Tcl related website somewhere...can't remember where,
> but sent an inquiry to an e-mail link on the page in the wee hours
> of the morning. After several days, still no response so I posted.
12/2/97 ***FOUND IT AGAIN*** ...
(SOURCE:) http://sunscript.sun.com/plugin/faq.html#a32
33. I hate Tcl, but I think Tk is cool. Can I create a Perl or Python
plugin that uses Tk?
First, we're sorry you hate Tcl :). It's not so bad, really..
Of course we're happy that you like Tk. We also think it's
way cool!
Second, there are already plugins for Perl and Python. You can
find them on the web.
OK... "where are the 'perl plug-ins' hiding "on the web"???????????????
Eric Hilding
eat-my-dust-spammer@_hilding.com
** Substitute "eric" for "eat-my-dust-spammer" and ditch the underscore
after the "@" symbol if replying via e-mail (Thanks)
------------------------------
Date: Tue, 02 Dec 1997 21:49:24 GMT
From: andrew@edoc.com (Andrew Williams)
Subject: Re: perl-cgi frames
Message-Id: <348d822f.967584984@news.clark.net>
>
>> I need help using frames in cgi-perl. I have created a page with two
>> frames with a form on one side and information on the other. When the
>> user clicks on a button I would like the user to go to a new page
>> without any frames. This is where I need help, I do not know how to
>> delete the frames and show the user a new page.
>> If it is possible I would like a response in english.
>>
Frames have exactly what to do with perl? Look at the TARGET=top
option to links and form output. Or you could even try posting this
to a relavent news group.
------------------------------
Date: Tue, 2 Dec 1997 15:52:08 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Daryn Brightblade <daryn@solamnia.demon.co.uk>
Subject: Re: Random numbers, perl and win95 :(
Message-Id: <Pine.GSO.3.96.971202153829.19514K-100000@usertest.teleport.com>
On Tue, 2 Dec 1997, Daryn Brightblade wrote:
> the random number generator refuses to generate random numbers
That's what srand is good for. But 5.004 removes the most frequent cause
of this problem.
> $file=int(rand(100000));
And you should know that on many systems, that won't actually have 100_000
possible values. If you want to be able to get _any_ value from 0 to
99_999, I'd use something like this.
$file = 1000 * int(rand 100) + int(rand 1000); # 0 to 99_999
Some more information on why this may be needed is available at this URL.
Hope this helps!
http://www.perl.com/CPAN/doc/FMTEYEWTK/random
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 2 Dec 1997 22:41:26 GMT
From: jev@pconline.com (John Erjavec V)
Subject: Re: Scheduling the execution of a script
Message-Id: <6622qm$ckv$1@bell.pconline.com>
Lisa-
This is not really a perl question, but if you are under Unix, you
could look at 'cron'. It will do what you want. If you are under
WinNT, then there is an 'at' command, and a windows interface to it
in the server utilities (I think) disk. That one is called 'win at'.
Hope this helps.
-JEV
Lisa Radinski (lmrad@minutezt.com) wrote:
: I have a script that sends mail to a number of e-mail addresses.
: Specifically, I have several students in a course I'm teaching and
: want to send them automated letters throught the session at given
: dates.
:
: I don't want to have to remember to run the script that sends the
: letters; therefore, I need to know if there's a way to schedule a job
: that will run the script at a particular time of the month.
:
: Is this possible?
:
: Thanks.
:
--
John Erjavec V
jev@pconline.com
http://www.pconline.com/~jev/
------------------------------
Date: Tue, 2 Dec 1997 16:06:16 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Matthew Rice <Matthew.Rice@ftlsol.com>
Subject: Re: Trimming space
Message-Id: <Pine.GSO.3.96.971202160331.19514N-100000@usertest.teleport.com>
On 1 Dec 1997, Matthew Rice wrote:
> bart.mediamind@tornado.be (Bart Lateur) writes:
> > $str =~ s/^\s+//; #trim leading blanks
> > $str =~s/\s+$//; #trim trailing blanks
> I like this one better:
> $str =~ s/^\s+|\s+$//g;
It's slower and harder to understand; the only virtue that I see is that
it is all one line. Is there another reason you like it better?
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Tue, 2 Dec 1997 16:02:13 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Mark Holmes <mhol003@stat.auckland.ac.nz>
Subject: Re: Window dies/string error
Message-Id: <Pine.GSO.3.96.971202155947.19514M-100000@usertest.teleport.com>
On Mon, 1 Dec 1997, Mark Holmes wrote:
> When I submit a form for processing, 9 times out of 10 it works fine,
> but every now and then either the netscape window either vanishes or I
> get the error:
>
> A network error occurred while Netscape was sending data.
Sounds like a bug in Netscape. Have you tried asking about this in a
newsgroup about Netscape?
> Any idea what kind of bugs in my program could lead to this kind of
> error
Your program may not be following a protocol which Netscape expects. You
could ask about that in a newsgroup about the protocol, of course. But
there's nothing Perl-specific about this. Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 2 Dec 1997 21:37:07 GMT
From: "Warren Burstein" <warren@brachot.jct.ac.il>
Subject: Re: Windows 95 flock problem (hapless newbie question)
Message-Id: <01bcff6a$47674de0$cd785ac2@wb.jen.co.il>
"Benjamin Geer" <benjamin.geer@worldnet.att.net> writes:
> Using code lifted from "Learning Perl for Win32", I'm writing a little
CGI
> script, under Windows 95, that takes form input and appends it to a file.
> The program runs fine, as long as this line is commented out :
>
> flock(MESSAGES, $LOCK_EX) || die("Can't flock $filename : $!");
When I use flock on Windows 95, using Activeware "Perl for Win32 Build
313", which is Perl version 5.003_07, I get:
flock() is not available on Win95!
Is there another way to lock files? fcntl locking doesn't work, either:
Your vendor has not defined Fcntl macro F_GETLK, used at fcntl line 2.
--
The entire world is a very strange carrot
but the farmer is not worried at all
------------------------------
Date: Wed, 03 Dec 1997 09:46:39 +1000
From: Ron Savage <rpsavage@ozemail.com.au>
Subject: Re: Year 2000: -M -A -C operators
Message-Id: <34849DDF.693C@ozemail.com.au>
Tom Christiansen wrote:
[snip]
> But in this case, you're just being paranoid: the number of seconds
> in each day in not apt to change with the millenium. ^^^ ^^^^^^
[snip]
Just as we have leap years, we have leap seconds. Thus, some minutes have 61 seconds.
You have been warned...
--
Cheers,
Ron Savage
Office: savage.ron.rs@bhp.com.au
Home (preferred): rpsavage@ozemail.com.au
------------------------------
Date: Tue, 02 Dec 1997 18:25:49 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Year 2000: -M -A -C operators
Message-Id: <-0212971825490001@aggie.coaps.fsu.edu>
In article <34849DDF.693C@ozemail.com.au>, Ron Savage
<rpsavage@ozemail.com.au> wrote:
+ Just as we have leap years, we have leap seconds. Thus, some minutes
have 61 seconds.
+ You have been warned...
And the long-term average is still 86,400 seconds/day...
James
--
Consulting Minister for Consultants, DNRC
Support the anti-Spam amendment <url:http://www.cauce.org/>
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 1405
**************************************