[11677] in Perl-Users-Digest
Perl-Users Digest, Issue: 5277 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 1 12:04:31 1999
Date: Thu, 1 Apr 99 09:00:26 -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, 1 Apr 1999 Volume: 8 Number: 5277
Today's topics:
Re: 'find' for PPT (I R A Aggie)
Re: <STDIN> <upsetter@ziplink.net>
Active perl / Win98 and Apache <david@bluewave.com>
Re: Active perl / Win98 and Apache c4jgurney@my-dejanews.com
Re: Active perl / Win98 and Apache <dturley@pobox.com>
AIX bug with Getopt::Std? (Christian M. Aranda)
Re: Almost a disaster <droby@copyright.com>
CGI help with LED sign applet <webbastard@spacebastards.com>
Re: create html (Tad McClellan)
Extracting Lines That Match With grep? global3@my-dejanews.com
Re: Extracting Lines That Match With grep? <jeffp@crusoe.net>
Form to Email Problem <lsobilo@whitingcorp.com>
Re: Getting user last login time and date from perl (Steve Linberg)
Re: Hello World <cederstrom@removethis.kolumbus.fi>
IPC, best way to handle in Win32? <nospam@here.com>
munch, munch, munch(the sound of many crows being eaten <ddelikat@protix.com>
Re: munch, munch, munch(the sound of many crows being e (Larry Rosler)
Re: Newbie questions... <upsetter@ziplink.net>
Re: perl+UDP socket timeout <mis@sparc.spb.su>
PerlCOM <gary@wics.demon.co.uk>
Re: quick question... (Tad McClellan)
Re: random elements from an array (Larry Rosler)
Re: random elements from an array (Randal L. Schwartz)
Re: Reference to built-in function (M.J.T. Guy)
Re: Reference to built-in function <jeffp@crusoe.net>
Re: Reference to built-in function <jeffp@crusoe.net>
rotating arrays and files <dave@cinemas-online.co.uk>
Re: rotating arrays and files (Larry Rosler)
Re: Running a perl script as a daemon.... <ddelikat@protix.com>
script for getting <a href> tag in Netscape <leehn@ee-wp.bham.ac.uk>
Re: Script produced no output... (Steve Linberg)
Re: Server Side Includes (Steve Linberg)
Re: Server Side Includes (Jonathan Stowe)
Re: Server Side Includes <droby@copyright.com>
Re: Subst some strings with '$xxx (Tad McClellan)
Re: Threads: ready for real applications? Perl Internal <bbense+comp.lang.perl.misc.comp.lang.perl.modules.Apr.01.99@telemark.stanford.edu>
Re: trying to build C like structure in perl <droby@copyright.com>
Re: URGENT <upsetter@ziplink.net>
Re: Validating Email addresses (Lee)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 1 Apr 1999 15:26:48 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: 'find' for PPT
Message-Id: <slrn7g746h.bqi.fl_aggie@stat.fsu.edu>
On Thu, 01 Apr 1999 15:07:35 +0200, Philip Newton
<Philip.Newton@datenrevision.de> wrote:
+ You do know about 'find2perl', don't you? I believe it comes with
+ standard Perl distributions. You feed it the same options as find, and
+ it spits out a Perl script on STDOUT. For example, 'find2perl . -name
+ foo -print'. So something like eval `find2perl @ARGV` is already a good
+ emulation of find.
The PPT page on 'find' basically suggests building a frontend to execute
the output of find2perl. That would be the Lazy way. :)
The code in find2perl is pretty scary looking. It looks to check for
everything, except perhaps the kitchen sink...
James
------------------------------
Date: Thu, 01 Apr 1999 14:42:32 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: <STDIN>
Message-Id: <sBLM2.614$eJ.116170@news.shore.net>
Elliot Slater <eslater@frinc.com> wrote:
: Am I able to assign a value to <STDIN> as I would any other variable?
No, and what are you trying to accomplish anyway? There's probably some
simple way to do what you want to do, but from this question we have no
way of knowing. Post some code or give us a description of what you're
trying to accomplish and maybe we can help (or at least point you to the
right part of the FAQ! :)
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Thu, 1 Apr 1999 14:57:40 +0100
From: "David Smith" <david@bluewave.com>
Subject: Active perl / Win98 and Apache
Message-Id: <37037aeb.0@nnrp1.news.uk.psi.net>
I have the following installed
ActivePerl 509
Win98
Apache 1.3.6
It would seem that although the line :
perl prog.pl
will run the webserver does not want to run any scripts at all,
any Help gratefully received
Thanks
Dave
david@bluewave.com
------------------------------
Date: Thu, 01 Apr 1999 15:25:26 GMT
From: c4jgurney@my-dejanews.com
Subject: Re: Active perl / Win98 and Apache
Message-Id: <7e034r$8gi$1@nnrp1.dejanews.com>
In article <37037aeb.0@nnrp1.news.uk.psi.net>,
"David Smith" <david@bluewave.com> wrote:
> I have the following installed
>
> ActivePerl 509
> Win98
> Apache 1.3.6
>
Okay,
> webserver does not want to run any scripts at all,
> Dave
Check your shebang for a start. For ActivePerl the default location of
perl.exe is c:\perl\bin so try #! c:\perl\bin\perl.exe
If you've already got that then check your script is somewhere that apache
wants to run cgi from e.g. the cgi-bin dir.
These are the two most common problems. You've given very little info about
exactly what apache is telling you when you try to run the scripts, if these
two tips don't work then post some more info.
You might also look at the following;
perlfaq9 "My CGI script runs from the command line but not the browser. (500
Server Error)" which should be part of the online documentation with
activeperl.
David Turley's cgi help (That's your second plug from me today Mr Turley) at
http://www.binary.net/dturley/cgi_testing.html
And comp.infosystems.www.authoring.cgi is a good bet - they have a useful faq
for this sort of thing.
HTH
Jeremy Gurney | Proteus Molecular Design Ltd.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 01 Apr 1999 16:18:35 GMT
From: David Turley <dturley@pobox.com>
Subject: Re: Active perl / Win98 and Apache
Message-Id: <7e068g$ben$1@nnrp1.dejanews.com>
In article <7e034r$8gi$1@nnrp1.dejanews.com>,
c4jgurney@my-dejanews.com wrote:
> David Turley's cgi help (That's your second plug from me today Mr Turley) at
> http://www.binary.net/dturley/cgi_testing.html
Just updated for apache 1.3.6 BTW. :-)
--
David Turley
dturley@pobox.com
http://www.binary.net/dturley
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 01 Apr 1999 17:36:30 GMT
From: christianarandaOUT@OUTyahoo.com (Christian M. Aranda)
Subject: AIX bug with Getopt::Std?
Message-Id: <3703ac19.4744992@news.bmc.com>
I believe I may have found a bug in the Getopt::Std module. The
following code works on (at least) SunOS and AIX:
use Getopt::Std;
$optstring = "v";
getopts($optstring);
if ($opt_v) { # -f patfile
print "\nVersion 1.00.00\n";
print "---------------------------------------\n";
print "Written by Christian Aranda\n";
print "(C) Copyright 1999 BMC Software, Inc.\n";
print "All rights reserved.\n";
print "---------------------------------------\n\n";
exit(0);
}
this code works on SunOS but not AIX:
use Getopt::Std;
$optstring = "v";
getopts($optstring, \%opt);
if ($opt{v}) { # -f patfile
print "\nVersion 1.00.00\n";
print "---------------------------------------\n";
print "Written by Christian Aranda\n";
print "(C) Copyright 1999 BMC Software, Inc.\n";
print "All rights reserved.\n";
print "---------------------------------------\n\n";
exit(0);
}
It seems that on AIX, returning the hash %opt does not work. If I
were to put in an option such as -D1999 and then print $opt{D} it has
no value.
Additional Info:
$ uname -a
AIX aix7 1 4 00019110A000
$ perl -v
This is perl, version 5.004_04 built for aix
Copyright 1987-1997, Larry Wall
Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5.0 source
kit.
------------------------
$ uname -a
SunOS topgun 5.5.1 Generic_103640-18 sun4u sparc SUNW,Ultra-2
$ perl -v
This is perl, version 5.004_04 built for sun4-solaris
Copyright 1987-1997, Larry Wall
Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5.0 source
kit.
------------------------------
Date: Thu, 01 Apr 1999 16:01:23 GMT
From: Don Roby <droby@copyright.com>
Subject: Re: Almost a disaster
Message-Id: <7e058c$an0$1@nnrp1.dejanews.com>
In article <3702EA97.E4C6FCAB@toolcity.net>,
Ben Bullock <bullock@toolcity.net> wrote:
> As part of a script to automate adding users to a system running
> Solaris 2.5.1, I had a couple of lines of code that essentially looked
> like this:
>
> $home_dir="/home/username";
> system("chmod 711 $home_dir");
>
> When this script executed, it not only changed permissions on the new
> user's home directory to 711, but it also changed the permissions to
> 711 on "/". And that caused some problems, like the inability for
> normal users to look at man pages, run simple commands like 'pwd',
> etc. After the permissions on / were changed back to the original
> 755, everything was normal.
>
Perhaps someone has hacked your system and chmod is not what it should be?
Are you running this as root without -T? And without setting $ENV{PATH}
elsewhere in your program? The -T switch will catch this and other security
flaws and make you fix them.
Are you sure the user's home and / were the only things changed? If I saw the
permissions on / unexpectedly change, I'd wonder what else changed!
Paranoia is good.
perldoc perlsec
You should also test that the system() succeeded. It's also safer to use
lists in system().
perldoc -f system
perldoc -f exec
This phenomenon doesn't happen on my Solaris. Though I'm running 2.7, I doubt
that it happens on 2.5.1 either. At any rate, if it does, it happens from a
command line chmod also, and means there's something wrong with your chmod.
Or there's a system('chmod 711 /') elsewhere in your program. Or something.
> I know I could have used something like this for changing permissions:
> @filelist="/home/username";
> chmod(0711, @filelist);
>
You don't need a list for a single value here. Perl function call semantics
will make it work with a scalar.
And this is probably a better idea than the system("chmod ...") stuff.
> but why did the original script give such an unexpected result? BTW,
> the perl interpreter is an older version, 5.003 IIRC.
>
You should of course upgrade it to a more current version. But I seriously
doubt that's the problem.
--
Don Roby
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 1 Apr 1999 17:08:35 +0100
From: "Web Bastard" <webbastard@spacebastards.com>
Subject: CGI help with LED sign applet
Message-Id: <922982919.15331.0.nnrp-04.9e98e70a@news.demon.co.uk>
I'm trying to use the LED sign applet (ver 3.1) on a site I'm developing
and I want to generate the LED script from a CGI script but
am having no luck at all.
I've tried just using print to output the script file but this doesn't
work.
The LED script is as follows:
Do
ScrollRight delay=30 startspace=0 endspace=10 text=hello
Repeat times=0
and this was my last attempt to get a CGI script to work
#!/usr/bin/perl
print "Content-type: text/plain\n";
print "Pragma: no-cache\n\n";
print <<'SCRIPT';
Do
ScrollRight delay=30 startspace=0 endspace=10 text=hello
Repeat times=0
SCRIPT
exit;
I'm a newbie to Perl and this is the only way I know to try so if
anyone can help.
Web Bastard
------------------------------
Date: Thu, 1 Apr 1999 03:19:22 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: create html
Message-Id: <a6avd7.k26.ln@magna.metronet.com>
apple (jearanai@science.gmu.edu) wrote:
: Can I create a html file from my perl file without usong CGI?
Sure.
Perl just outputs text. It doesn't care if there happens to
be lots of angle brackets in it or not.
Like this:
print <<ENDHTML;
<html>
<body>
<h1>Hello World</h1>
</body>
</html>
ENDHTML
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 01 Apr 1999 16:06:06 GMT
From: global3@my-dejanews.com
Subject: Extracting Lines That Match With grep?
Message-Id: <7e05h6$as1$1@nnrp1.dejanews.com>
Hi All,
Can someone tell me how to use grep or some other code to extract only
those lines that match the pattern between the pattern matching / /
lines into an array?
I used the code below to extract only those lines that don't match
into the @hits array.
open(FILE,"list.txt);
@lines= <FILE>;
close(FILE);
@hits = grep(! /pattern/i,@lines);
print @hits;
exit;
I've been checking my Perl books and searching the net for the answer
to this question for over two days without success. Please help me if
you can.
I tried the code below but that didn't work.
@hits = grep(!~ /pattern/i,@lines);
Thank you very much and I do hope to hear from someone soon.
Best regards,
Alan
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 1 Apr 1999 11:24:56 -0500
From: evil Japh <jeffp@crusoe.net>
Subject: Re: Extracting Lines That Match With grep?
Message-Id: <Pine.GSO.3.96.990401112317.15023H-100000@crusoe.crusoe.net>
> Can someone tell me how to use grep or some other code to extract only
> those lines that match the pattern between the pattern matching / /
> lines into an array?
>
> I used the code below to extract only those lines that don't match
> into the @hits array.
>
> open(FILE,"list.txt);
> @lines= <FILE>;
> close(FILE);
> @hits = grep(! /pattern/i,@lines);
> print @hits;
> exit;
It appears you don't know the use of the ! operator in Perl. It is a
negation. Let me explain briefly: !0 = 1. !34 = 0. !4 = 0.
Think of it as "not", for that is what it is.
Not false = true
Not true = false
therefore look at changing grep(! /pattern/i,@files).
--
Jeff Pinyan (jeffp@crusoe.net)
www.crusoe.net/~jeffp
Crusoe Communications, Inc.
732-728-9800
www.crusoe.net
------------------------------
Date: Thu, 01 Apr 1999 10:28:02 -0600
From: Lawrence Sobilo <lsobilo@whitingcorp.com>
Subject: Form to Email Problem
Message-Id: <37039E92.5F2A6621@whitingcorp.com>
We have a very simpl script to create an email message from a form. The
script works fine - for U.S. users. Recently, we've had users from other
countries. The email does not contain any form data, or, occasionally
NIL or -.
Here's a sample of the script:
&ReadParse(*input);
print "Content-type: text/html\n\n";
if (open(MAIL,"| /usr/lib/sendmail -B7BIT ".$input{"sendto"}))
{
print MAIL "Subject: LICENSEE ORDER: ".$input{"RefNumber"}."\n\n";
print MAIL "Remote Host was ".$ENV{'REMOTE_HOST'}."\n";
print MAIL "Ref Number : ".$input{"RefNumber"}."\n";
print MAIL "Customer : ".$input{"Customer"}."\n";
print MAIL "Order Date : ".$input{"OrderDate"}."\n";
print MAIL "Description : ".$input{"description"}."\n";
Would appreicate any help!
--------------------------------------------------------------
Lawrence Sobilo, Director, MIS
--------------------------------------------------------------
Whiting Corporation - Material Handling Equipment for Industry
Equipment & Parts: http://www.whitingcorp.com
Service: http://www.whiting-serv.com
Canada: http://www.whiting.ca
Chemical Process Equipment: http://www.swenson-equip.com
------------------------------
Date: Thu, 01 Apr 1999 10:51:36 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Getting user last login time and date from perl
Message-Id: <linberg-0104991051370001@ltl1.literacy.upenn.edu>
In article <slrn7g633l.6ne.tonyk@pluto.rcode.com.au>,
keating@mech.uq.edu.au wrote:
> Is there a way to easily get the last login time and date of a user on the
> system directly from perl? Or do I have to run finger and extract the
> relevent data?
Um. Perl doesn't know anything about users and login times. If your
system stores information you want anywhere, there's almost certainly a
way to use Perl to find it. You could run a finger process from a perl
script and parse the results, for example. But it's not coming "from"
perl.
--
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, 1 Apr 1999 08:58:18 +0300
From: "Juho Cederstrvm" <cederstrom@removethis.kolumbus.fi>
Subject: Re: Hello World
Message-Id: <7e01p1$lah$1@news.kolumbus.fi>
> "What is your name? Hello !"
>is it me or the Perl Builder environment.
It's not you, becouse the program works here.
Guess: Maybe there's something in STDIN even before running command?
How to check or prevent that? That's another story... :(
--
# This is a Perl-script which will display juhoc's email address
$_ = "ohuj s'ciameda lserdsi sdec tsreAmorlokTubmuTODsfi";
s/(.)(.)(.)(.)/$4$3$2$1/g;s/AT/\@/;s/DOT/\./;print $_."\n";
------------------------------
Date: Thu, 1 Apr 1999 09:52:01 -0600
From: "Jim Johnson" <nospam@here.com>
Subject: IPC, best way to handle in Win32?
Message-Id: <7e04n2$k25@mars.dsu.edu>
I want to write a perl program which deletes directories on different
servers. Since network and disk access are both slow, I'd all the directory
deletions to happen at the same time, with different child process or
threads each handling one server. After reading through some of the
ActiveState perl docs, I'm still not sure of the best way to do this. Can
anyone give me any pointers, tips, or help? What I'd like to do in psuedo
codeish fashion is this:
create child1
create child2
tell child1 delete "\\server1\dir1"
tell child2 delete "\\server2\dir2"
wait for children to finish deleting
continue processing
Should I be using threads, sockets, pipes? Or am I completely out to lunch?
I've used the fork command in a Unix programming class before, but I don't
think that works in NT?
Thanks,
JIM
------------------------------
Date: Thu, 01 Apr 1999 08:53:54 -0600
From: David Delikat <ddelikat@protix.com>
Subject: munch, munch, munch(the sound of many crows being eaten)
Message-Id: <37038882.167E@protix.com>
as many of you saw yesterday, I made a complete fool of
myself right here for the whole world to see. what can
I say? a fool and his wisdom are soon parted.
my humblest apologies to all who were offended,
particularly Larry.
Thanks for a lesson well learned.
-dav
--
<((((><
Consultant: Internet, Database, Business Systems
Unix/Linux, Windows95/NT
mailto:david-delikat@usa.net / http://obj.webjump.com/
------------------------------
Date: Thu, 1 Apr 1999 08:04:44 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: munch, munch, munch(the sound of many crows being eaten)
Message-Id: <MPG.116d38f438793081989804@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <37038882.167E@protix.com> on Thu, 01 Apr 1999 08:53:54 -
0600, David Delikat <ddelikat@protix.com >says...
> as many of you saw yesterday, I made a complete fool of
> myself right here for the whole world to see. what can
> I say? a fool and his wisdom are soon parted.
>
> my humblest apologies to all who were offended,
> particularly Larry.
>
> Thanks for a lesson well learned.
Well, let's just assume that April Fools Day came a day early for you.
Meanwhile, you have made me several new email friends, and fomented a
small spike in accesses to my website, even though my URL was buggy.
So thanks to you (I guess :-).
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 01 Apr 1999 14:40:04 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: Newbie questions...
Message-Id: <8zLM2.612$eJ.116170@news.shore.net>
David L. Cassell <cassell@mail.cor.epa.gov> wrote:
: Errm, ASP and Perl are not equivalent. ASP is not *better* [or worse]
: than Perl. It is in a different functional space. If you're using ASP, you
: can use PerlScript or VBScript or JavaScript or... Base testing reported
: in the last week or two on the win32-perl-users listserv suggests that
: PerlScript may be the way to go. But check out their benchmarks and decide
: for yourself. YMMV.
Do you have a link for those benchmarks, by any chance?
Thanks,
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Thu, 1 Apr 1999 18:16:34 +0400
From: Manida Ivan <mis@sparc.spb.su>
Subject: Re: perl+UDP socket timeout
Message-Id: <Pine.GSO.4.02.9904011811480.20679-100000@minerva.sparc.spb.su>
On Thu, 1 Apr 1999 mikepitt@my-dejanews.com wrote:
> In article <Pine.GSO.4.02.9904011155050.16709-100000@minerva.sparc.spb.su>,
> Manida Ivan <mis@sparc.spb.su> wrote:
> > Hello, I suppose someone here ever dealt with UDP sockets via perl?
>
> Hi,
>
> The Perl Cookbook (Christiansen and Torkington, ISBN 1-56592-243-3, O'Reilly &
> Associates, $39.95, available at Amazon and so on...) has a couple of good
> examples, and it got me up and running.
Thanks for the reference, will look at it.
>
> BUT... it only gives timeouts using alarms, which means it doesn't solve your
> specific problem.
>
> (Especially irritating on Win32 which doesn't support the alarm function!)
>
Hmmm... I wonder - if what you say about win32 not supporting alarm
timers is true (sorry, perl eq Unix for me) then someone must know some
way around it... Don't tell me people just don't use UDP under Win32 :)
Anyone who was able to get his perl UDP program working on Win32? Share
the experience with us please :)
Actually, I could stick to $SIG because it *does* work for me, but I'm
trying to avoid *hacks* and this thing looks like a big smelly hackaround
to me :]
Thanks for the reply btw :)
//--- Ivan S. Manida aka PiRaMidA <mis@sparc.spb.su>
Sun Microsystems software engineer, russian C compilers team
http://agsm.gagames.com : aGSM : multiplayer games on your PC
------------------------------
Date: Thu, 1 Apr 1999 15:01:28 +0100
From: "Gary Land" <gary@wics.demon.co.uk>
Subject: PerlCOM
Message-Id: <922975317.7345.0.nnrp-03.c2debcd8@news.demon.co.uk>
We have been using a PerlCOM.Script object through VB 4.
When closing the VB4 application PerlCOM.DLL GPFs.
Tried testing with this simple VB4 program and it still GPFs on exit.
Dim objPerl
Set objPerl = CreateObject("PerlCOM.Script")
Set objPerl = Nothing
This example means that No subPerlCom objects have been used. The PerlCom
is actually doing nothing except instancing and then destroying, so it
should not crash?
Tried the PRK service pack from Active State now we cannot actually register
the PerlCom object.
Help needed.
system info:
Perl 5.005
win 95
VB4
------------------------------
Date: Thu, 1 Apr 1999 03:20:07 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: quick question...
Message-Id: <n7avd7.k26.ln@magna.metronet.com>
apple (jearanai@science.gmu.edu) wrote:
: How can I create a HTML file by using Perl in case of I don't want to use CGI?
You don't need to ask the same question many different ways.
Once is enough.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 1 Apr 1999 07:19:36 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: random elements from an array
Message-Id: <MPG.116d2e5d86a266a2989803@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <m1d81oh37k.fsf@halfdome.holdit.com> on 01 Apr 1999 05:37:03
-0800, Randal L. Schwartz <merlyn@stonehenge.com >says...
...
> Of course, there's no point storing it if you're just going to pop it.
>
> my $i = int rand @array;
> $element = $array[$i];
> if ($i < @array) {
> $array[$i] = pop @array;
> } else {
> $#array--;
> }
Inasmuch as $i is always less than scalar(@array), your test doesn't do
a great deal. Though interesting things happen if $i == @array - 1.
(Actually, *nothing* happens to the array.)
ITYM
if ($i < $#array) {
Newbie error or April Fool (always give the man a face-saving out :-)?
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 01 Apr 1999 08:57:20 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: random elements from an array
Message-Id: <m17lrwgtxr.fsf@halfdome.holdit.com>
>>>>> "Larry" == Larry Rosler <lr@hpl.hp.com> writes:
Larry> Inasmuch as $i is always less than scalar(@array), your test doesn't do
Larry> a great deal. Though interesting things happen if $i == @array - 1.
Larry> (Actually, *nothing* happens to the array.)
Larry> ITYM
Larry> if ($i < $#array) {
Larry> Newbie error or April Fool (always give the man a face-saving out :-)?
E_NO_TEST :)
--
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: 1 Apr 1999 15:56:47 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Reference to built-in function
Message-Id: <7e04vv$meo$1@pegasus.csx.cam.ac.uk>
Thelma Lubkin <thelma@alpha2.csd.uwm.edu> wrote:
>
>###I want these to be references to system built in functions
>my ($pushref,$shiftref) = (\&push,\&unshift);
You can't take references to builtin functions, unfortunately.
The simplest, if not the most efficient thing to do is to define your
own subroutine:
my $pushref = sub { my $aref = shift; push @$aref, @_ };
Note that when using subroutine references, you lose the prototype
processing. So you'll have to write the first argument as an array
reference rather than an array.
> &$action(@aray), $newmem;
That's an odd way to write a call - presumably you mean
&$action(@aray, $newmem);
But that won't work as noted above, so you'll have to write
&$action(\@aray, $newmem); # or
$action->(\@aray, $newmem);
Mike Guy
------------------------------
Date: Thu, 1 Apr 1999 11:14:33 -0500
From: evil Japh <jeffp@crusoe.net>
Subject: Re: Reference to built-in function
Message-Id: <Pine.GSO.3.96.990401111111.15023E-100000@crusoe.crusoe.net>
You can, however, refer to CORE::push(), or CORE::log(), if you define
your own functions with those names:
sub shift (\@$){ # allow for shift X number of times
my ($aref,$iter) = @_;
my @ret;
for (1..$iter){ push @ret, CORE::shift(@$aref); }
return @ret;
}
--
Jeff Pinyan (jeffp@crusoe.net)
www.crusoe.net/~jeffp
Crusoe Communications, Inc.
732-728-9800
www.crusoe.net
------------------------------
Date: Thu, 1 Apr 1999 11:17:30 -0500
From: evil Japh <jeffp@crusoe.net>
Subject: Re: Reference to built-in function
Message-Id: <Pine.GSO.3.96.990401111650.15023F-100000@crusoe.crusoe.net>
> You can, however, refer to CORE::push(), or CORE::log(), if you define
> your own functions with those names:
>
> sub shift (\@$){ # allow for shift X number of times
sub shift (\@;$){
> my ($aref,$iter) = @_;
$iter ||= 1;
> my @ret;
> for (1..$iter){ push @ret, CORE::shift(@$aref); }
> return @ret;
> }
--
Jeff Pinyan (jeffp@crusoe.net)
www.crusoe.net/~jeffp
Crusoe Communications, Inc.
732-728-9800
www.crusoe.net
------------------------------
Date: Thu, 1 Apr 1999 16:18:41 +0100
From: "Dave Lowry" <dave@cinemas-online.co.uk>
Subject: rotating arrays and files
Message-Id: <7e02lb$t99$1@mendelevium.btinternet.com>
Hi there
I have a problem as I'm new to PERL
I have a file that I read into and array, that's the easy bit ...
Now I need to take the 1st line of that file (1st element in the array),
then move this element to the back (deleting the original entry as we go)
and then re-save the original file
Do I have to use Perl's PUSH and POP functions or is there a easier way ??
Can you please also E-mail me with any answers or questions as well as
posting them here
Thanks in advance
Colin Bell
colin@cinemas-online.co.uk
------------------------------
Date: Thu, 1 Apr 1999 08:25:16 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: rotating arrays and files
Message-Id: <MPG.116d3dbe2786c19b989805@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7e02lb$t99$1@mendelevium.btinternet.com> on Thu, 1 Apr 1999
16:18:41 +0100, Dave Lowry <dave@cinemas-online.co.uk >says...
...
> Now I need to take the 1st line of that file (1st element in the array),
> then move this element to the back (deleting the original entry as we go)
> and then re-save the original file
>
> Do I have to use Perl's PUSH and POP functions or is there a easier way ??
The FAQs are your friend. From perlfaq4:
How do I handle circular lists?
Circular lists could be handled in the traditional fashion with linked
lists, or you could just do something like this with an array:
unshift(@array, pop(@array)); # the last shall be first
push(@array, shift(@array)); # and vice versa
> Can you please also E-mail me with any answers or questions as well as
> posting them here
No problem, because you didn't munge your email address.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 01 Apr 1999 09:54:09 -0600
From: David Delikat <ddelikat@protix.com>
Subject: Re: Running a perl script as a daemon....
Message-Id: <370396A1.FF6@protix.com>
Tad McClellan wrote:
>
> David Delikat (ddelikat@protix.com) wrote:
> : Tad McClellan wrote:
> : > Diggy Tim (tim@diggy.com) wrote:
> : >
> : > : Subject: Re: Running a perl script as a daemon....
> : > ^^^^^^
> : > ^^^^^^
> : > : How do I go about running a perl script from the command line and have it
> : > : sit in the background and not die when I log out.
> : >
> : > What happened when you did a word search in the Perl FAQs
> : > before posting?
>
> [ snip quoted signature]
>
> : oh for crying out loud, I just joined this group
>
> Welcome.
>
> : and the first thing I
> : see is some bonehead
>
> Oh yeah?
>
> Well ... ... your feet stink!
all the way to texas? ( from WI ) I did shower this morning.
>
> So there.
>
> : picking on spelling, and it isn't even wrong.
> ^^^^^^^^^^^^^^^^^^^
>
> Which did not suggest to you that picking on spelling
> was not what I was doing at all?
>
munch munch
> I was telling him how to find the definitive answer to his
> question in the standard Perl docs.
>
munch munch
> I don't think you have to worry about me following up to any
> of your future postings with spelling corrections...
>
> --
> Tad McClellan SGML Consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
thank you for a nice complete answer. my misunderstanding is
greatly enlightened by good healthy comunications.
-dav
PS. Why didn't anyone else notice this?
PPS. ( PSS? ) munch munch, I think I've had enough crow for today.
--
<((((><
Consultant: Internet, Database, Business Systems
Unix/Linux, Windows95/NT
mailto:david-delikat@usa.net / http://obj.webjump.com/
------------------------------
Date: Thu, 01 Apr 1999 16:18:16 +0100
From: Don Lee <leehn@ee-wp.bham.ac.uk>
Subject: script for getting <a href> tag in Netscape
Message-Id: <37038E37.301C22AF@ee-wp.bham.ac.uk>
Hi ,
I would like to know to write a script that will extract all the
hyperlink in a web page
currently view in the Netscape Navigator?
I know that Navigator do cache a copy of the current page in a cache
folder...
but the problem is that the cache page(file) seems to have a random file
name.
Hope someone out there, could point me the way .....
Thanks....
Don
------------------------------
Date: Thu, 01 Apr 1999 10:43:42 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Script produced no output...
Message-Id: <linberg-0104991043420001@ltl1.literacy.upenn.edu>
In article <7dtrp1$rh$1@news2.xs4all.nl>, "Frank" <fvdm@dds.nl> wrote:
> Interestingly, if I run the scripts directly from the URL (as in
> http://www.mysite.com/cgi-bin/myscript.plx) they execute as they are
> intended. But if I try to run them inside an HTML page as a SSI, then I get
> the following output:
>
> HTTP/1.0 200 OK Date: Mon, 15 Mar 1999 20:08:51 GMT Server:
> Microsoft-IIS/4.0
> Content-type: text/html 'c:\webroot\www.mysite.com\web\scriptpage.html'
> script produced no output"
SSIs don't need headers. Rewrite it so it just prints. A very simple SSI is:
print "hello";
__END__
No HTTP headers. Try that and see if you can get it working.
--
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, 01 Apr 1999 10:45:32 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Server Side Includes
Message-Id: <linberg-0104991045320001@ltl1.literacy.upenn.edu>
In article <7dvene$73o$1@black.news.nacamar.net>, "Holger Kasten"
<hkasten@abm-soft.de> wrote:
> Isnt it possible to start scripts on other servers?
Your question is really a CGI / server question, and has nothing
specifically to do with Perl. You'll do much better in
comp.infosystems.www.authoring.cgi.
--
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, 01 Apr 1999 16:06:42 GMT
From: gellyfish@gellyfish.com (Jonathan Stowe)
Subject: Re: Server Side Includes
Message-Id: <3703993a.29633619@news.dircon.co.uk>
On Thu, 1 Apr 1999 11:36:45 +0200, "Holger Kasten"
<hkasten@abm-soft.de> wrote:
>Hello, i have a question:
>
>Why does the folowing code not work:
>
><!--#exec cgi="http://www.xyz.com/cgi-bin/script.pl"-->
><!--#include virtual="http://www.xyz.com/cgi-bin/script.pl"-->
>
>but this works fine:
>
><!--#exec cgi="cgi-bin/script.pl"-->
><!--#include virtual="cgi-bin/script.pl"-->
>
>Isnt it possible to start scripts on other servers?
>Or, how to do so?
>
I would suggest that this is best discovered in the documentqation for
your server of failing that in a newsgroup in the
comp.infosystems.www.server.* branch
/J\
------------------------------
Date: Thu, 01 Apr 1999 16:30:54 GMT
From: Don Roby <droby@copyright.com>
Subject: Re: Server Side Includes
Message-Id: <7e06vv$cb1$1@nnrp1.dejanews.com>
In article <7dvene$73o$1@black.news.nacamar.net>,
"Holger Kasten" <hkasten@abm-soft.de> wrote:
> Hello, i have a question:
>
> Why does the folowing code not work:
>
> <!--#exec cgi="http://www.xyz.com/cgi-bin/script.pl"-->
> <!--#include virtual="http://www.xyz.com/cgi-bin/script.pl"-->
>
Sounds like an SSI problem.
> but this works fine:
>
> <!--#exec cgi="cgi-bin/script.pl"-->
> <!--#include virtual="cgi-bin/script.pl"-->
>
Sounds like not a Perl problem.
> Isnt it possible to start scripts on other servers?
Certainly, if the other server and the protocol you're using support it.
> Or, how to do so?
>
>
You might want to try asking this in a group where it's not off-topic.
Try comp.infosystems.www.authoring.cgi.
--
Don Roby
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 1 Apr 1999 03:24:32 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Subst some strings with '$xxx
Message-Id: <0gavd7.k26.ln@magna.metronet.com>
chanwit@my-dejanews.com wrote:
: How to subst some strings with '$xxx'?
----------------
#!/usr/bin/perl -w
use strict;
my $str = 'this has mystr in it';
$str =~ s/mystr/\$xxx/g;
print "$str\n";
----------------
: I've tried $str =~ s/mystr/\$xxx/g
: but it does not work.
Works for me.
There is something that you are not telling us...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 1 Apr 1999 15:22:05 GMT
From: <bbense+comp.lang.perl.misc.comp.lang.perl.modules.Apr.01.99@telemark.stanford.edu> ;
Subject: Re: Threads: ready for real applications? Perl Internals.
Message-Id: <7e02ut$a3r$1@nntp.Stanford.EDU>
In article <3703772E.795C2B32@ll.mit.edu>, <rkc@ll.mit.edu> wrote:
>I would like to write a threaded perl application, but some
>documentation that comes with perl 5.00502 indicates that there remain
>problems--a memory leak, and some other unlisted bugs. In another
>location in the documentation, this capability is listed as
>"experimental".
- - It's alot better in perl5.005_03, but I'd still list it as
experimental. I use it every day in some personal apps, but I
wouldn't depend on it for an application that would cause my
pager to go off if it broke. I wouldn't attempt to use threads
in anything less than perl5.005_03.
> I need to write an application that will run for
>extended periods of time, and am trying to decide how to proceed. Two
>options come to mind:
> (1) Write threaded perl code.
>
> (2) Write my own roll-back and sleep code.
>
>I would rather do (1), as it is easier and uses less computation, but I
>want to know what the state of the perl threading work is. Is someone
>still actively improving this code?
- - Yes, development is proceding. When it works it works just fine,
when it doesn't work it's pretty obvious. Alot depends on how good
the underlying OS thread library is, you'll have better luck on some
platforms than others. (I'm using solaris, which is pretty good.)
> Any estimate on when a
>non-experimental version might be ready?
- - Your guess is as good as mine. I'd look for gradual improvement
rather than a flat announcement of "non-experimental". If you can
live with some uncertainity, I'd suggest at least trying a threaded
version. It's pretty simple to use and you can pretty easily back
out if it's not working.
- - Booker C. Bense
Version: 2.6.2
iQCVAwUBNwOPGQD83u1ILnWNAQH/EQP/XVItPa9rmKHZ5vKHpkb1GO9jnkwKq7ve
cdUa+j3Cqu1709y8qAKlVJcOa7HOVn9cq7rZXxA2rDCXexipV0Oow7GYswo7sbMK
VYbTpp46fM73ptzOJkgSeu6on9dqHZYBjvTINi3eqjEPT1X3WZxlIbQcjtQQfqzW
JqMkygzvnxg=
=4XA2
-----END PGP SIGNATURE-----
------------------------------
Date: Thu, 01 Apr 1999 14:58:30 GMT
From: Don Roby <droby@copyright.com>
Subject: Re: trying to build C like structure in perl
Message-Id: <7e01ih$6vh$1@nnrp1.dejanews.com>
In article <kxHM2.2$o05.104@weber.videotron.net>,
"S.Faust" <sfaust@isi-mtl.com> wrote:
> I'm kinda new to perl and I'm trying tom build C like structure.
>
> here is the code I was able to write.
>
> sub deux_struct{
>
> $struct{name}[0] = "mike";
> $struct{name}[1] = "steve";
> $struct{age}[0] = 10;
> $struct{age}[1] = 20;
>
> foreach $element ( keys %struct ) {
> foreach $i ( 0 .. $#{ $struct{$element} } ) {
> print $struct{$element}[$i] . "\n";
> }
> }
> }
>
> is there a better way to build them?
There are other ways to initialize it that might be clearer. Take a look at
perldsc for some good examples. There's also alot of info in perlref and
perllol on stuff like this.
> I tried to print the element like
> $struct{name}[0] . $struct{age}[0] in the same line with a loop that attach
> the 2 element together but I was unable ( maybe I just need to take my eyes
> off the code
> and go sleep a bit). Anyone that have a way to do that I would appreciate
> some pointers.
>
Sleep is good. Since you have a hash of lists, and there's no guarantee that
all lists in the hash will have the same size, there's not a real natural way
to do it. If you know they all have exactly two entries, you can certainly
do something like
for (0..1) {
print $struct{'name'}[$_] . $struct{'age'}[$_] . "\n";
}
Emulating a C structure isn't necessarily the best way to deal with data
structures in Perl though. If you're storing info about people, and want to
retreive it based on name, you might do better to use a hash of hashes with
the actual names as first key, instead of having 'name' as a "fieldname" key.
This makes it much easier to retrieve all the data on a particular person.
--
Don Roby
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 01 Apr 1999 14:44:26 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: URGENT
Message-Id: <eDLM2.616$eJ.116170@news.shore.net>
Markus Staas <markus@umm.no> wrote:
: I forgot the beginning of my request above !!!!!!
: I have to use a form processing script.
: I tried a lot like FormMail and so on, but since Iam not a Perl Guy I don4t
: know what to do anymore !!!
: PLEASE PLEASE HELP ME !!!! :-))))))))))
It sounds like you need to hire a consultant.
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Thu, 01 Apr 1999 10:59:56 -0600
From: rlb@intrinsix.ca (Lee)
Subject: Re: Validating Email addresses
Message-Id: <B329022C9668DC3C7C@204.112.166.88>
In article <Pine.HPP.3.95a.990401021059.9211A-100000@hpplus01.cern.ch>,
"Alan J. Flavell" <flavell@mail.cern.ch> wrote:
>> I have been stuggling to develop a method of checking for valid email
>> address
>
>It's impossible. The FAQ says it's impossible. The FAQ is correct.
Does the FAQ mention that it is nevertheless useful to weed out putative
email addresses which will crash sendmail?
Lee
------------------------------
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 5277
**************************************