[11669] in Perl-Users-Digest
Perl-Users Digest, Issue: 5269 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 31 14:04:15 1999
Date: Wed, 31 Mar 99 11:00:22 -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, 31 Mar 1999 Volume: 8 Number: 5269
Today's topics:
Re: 'find' for PPT (Clinton Pierce)
Re: Comment controls <cassell@mail.cor.epa.gov>
Equivalent of initgroups() in Perl? <greg.wimpey@waii*removetomail*.com>
Re: File Upload in Internet Explorer <flo@allgaeu.org>
Re: File Upload in Internet Explorer <biwillia@cisco.com>
Re: flat file query Help!!! <cassell@mail.cor.epa.gov>
Re: Getting parent process's environment variable to ch <droby@copyright.com>
HELP !!! <Remedy@bigfoot.com>
Re: Help... Running Perl on NT <fvdm@dds.nl>
Re: How to use set uid in Perl? <greg.wimpey@waii*removetomail*.com>
netCDF - Perl krish_v@my-dejanews.com
Newbie ques. re cgi script testing wedrawforyou@my-dejanews.com
Re: Newbie questions... <fvdm@dds.nl>
Re: Opening >2Gb files on AIX (Clinton Pierce)
Re: Opening >2Gb files on AIX <greg.wimpey@waii*removetomail*.com>
Re: Perl calling MS Word <cassell@mail.cor.epa.gov>
Re: program interaction using <<HERE docs <cassell@mail.cor.epa.gov>
Re: Q Mail::** - solved <tavi367@ibm.net>
Re: random elements from an array (David Alan Black)
Re: random elements from an array <droby@copyright.com>
Re: random elements from an array <cassell@mail.cor.epa.gov>
Regex with lookahead help (Arthur Newhall)
Re: Running a perl script as a daemon.... <ddelikat@protix.com>
search and replace in a file jimbob4334@my-dejanews.com
Re: search and replace in a file (Jordan I. K. McClure)
Sorting lines. jambutter@my-dejanews.com
Uninstalling modules???? <craigh@visio.com>
Re: Unknown Error <newsgroups@kidkaboom.frogspace.net>
Use of Require in Win32 karasp@my-dejanews.com
Re: Use of Require in Win32 (Steve Linberg)
Re: Win32::Internet FTP question <rkoehler@osmre.gov>
www.pm.org <tbriles@austin.ibm.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 31 Mar 1999 16:51:45 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: 'find' for PPT
Message-Id: <370b4ff8.8833792@news.ford.com>
On Wed, 31 Mar 1999 09:35:13 GMT, NukeEmUp@ThePentagon.com (David
Cantrell) wrote:
>As no-one else has done it yet, I'm going to have a go at writing a
>'find' clone. Before I get started, I'd appreciate any comments on
>the following issues, and anything else you can think of.
>
>[Copying newsgroup posts to me by mail is considered rude]
Talking about PPT plans, and not cc'ing the mailing list is...nuts. S/N
is waaaaay too low in c.l.p.m not to do otherwise.
>As NT doesn't have symlinks, does anyone have any preferences about
>[..]
>-empty tests whether a file is a 'real' file/directory or a 'special'
>[..]
>-type and -xtype will be barely functional on NT, again, because of
>[..]
All of these options should be stubbed in, at least. IMHO. Accepted at
the command line, but not actually used anywhere. Choose sensible
defaults.
That way when a UNIX geek gets a hold of your program it won't be terribly
difficult to get options working for a Real Filesystem (tm).
>-empty tests whether a file is a 'real' file/directory or a 'special'
>file such as a device file. On NT, the $rdev field in the list
>returned by stat() is the number corresponding to the drive containing
>the file - so I'll have to handle this as a special case.
Only as a very small special case. You already know from st_mode if the
file is a device or not.
--
Clinton A. Pierce "If you rush a Miracle Man, you get rotten
clintp@geeksalad.org Miracles." -- Miracle Max, The Princess Bride
http://www.geeksalad.org
------------------------------
Date: Wed, 31 Mar 1999 09:50:18 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Comment controls
Message-Id: <3702605A.2CABE6B8@mail.cor.epa.gov>
Jonathan Feinberg wrote:
> Andy Cantrell <cantrela@agcs.com> writes:
>
> > I haven't poured over the camel book looking for this.
> > The index has a few things to say about #'s but I guess
> > they didn't hit the right note with me and so I turned
> > here. Any feedback?
>
> [jdf@joshua jdf]$ perlindex '# line'
> 1 0.795 lib/perl5/5.00502/Text/ParseWords.pm
> 2 0.761 lib/perl5/5.00502/pod/perlsyn.pod
> 3 0.663 lib/perl5/5.00502/pod/perlfaq6.pod
>
> perlsyn looks like a good bet.
But you'll have to pore [not 'pour'] over it, since the
answer you want isn't near the front.
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 31 Mar 1999 11:08:46 -0700
From: Greg Wimpey <greg.wimpey@waii*removetomail*.com>
Subject: Equivalent of initgroups() in Perl?
Message-Id: <sn90cd8rbl.fsf@ddcspn37.denver.waii.com>
I have a Perl script that will be executed on a Unix system by root
and then setting it's effective userid to that of a non-root user. I
would also like to set the effective group set to that user's total
group set. In C, one would do this by using initgroups().
I know that in Perl, one can set the effective group set by setting $)
to a space-delimited set of numerical group IDs. However, I see no
(easy) way of getting the entire group set for an arbitrary user.
Right now, the only way I see of doing this is to use getgrent to get
a list of all the groups, then search the member list of each group
for the user name, saving the group IDs of those groups for which
there is a match.
This is not too difficult to write, but it would seem nice if there
were a prebuilt function in perl to do this for me. But maybe I'm
just too lazy.
Thanks in advance for the help...
--
Greg Wimpey
greg.wimpey@waii*removetomail*.com
------------------------------
Date: Wed, 31 Mar 1999 20:20:20 +0200
From: "Florentin Hauber" <flo@allgaeu.org>
Subject: Re: File Upload in Internet Explorer
Message-Id: <7dtpbf$79j$1@janeway.allgaeu.org>
Hi!
Hast Du sowas wie
ENCTYPE="multipart/form-data"
in Deinem Form-Tag stehen?
gru_
Florentin
--
/* Scripts nach Mass
Florentin Hauber
fh@webaid.de */
------------------------------
Date: Wed, 31 Mar 1999 13:37:31 -0500
From: Bill Williams <biwillia@cisco.com>
Subject: Re: File Upload in Internet Explorer
Message-Id: <37026B6B.E04246AB@cisco.com>
--------------2243D4315199261A497AD1F5
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Not bad for "Shei_deutcsh"
:-)
Steve Linberg wrote:
> In article <3701C556.B05902C1@abs.ascom.ch>, Toggweiler Mike
> <ntogmi@abs.ascom.ch> wrote:
>
> > Hi
> >
> > Ich habe erneut ein Problem mit dem File Upload im Internet Explorer 3.0
> > und 4.0. Den Patch f|r IE3 habe ich installiert. Jetzt kann ich die
> > Datei via Brows Button auswdhlen, das Verzeichnis und der Dateinamen
> > werden mir |bermittelt, aber die Datei kann ich immer noch nicht lesen.
> > Durch das erstellt mein Script eine 0 Byte Datei. Wie schon gesagt
> > funktioniert im Gegensatz dies alles mit Netscape.
> > Hat jemand eine Idee, an was das liegen kvnnte?
>
> Ihr Problem hat nichts mit Perl zu tun, glaube Ich. Versuch mal
> vielleicht in comp.infosystems.www.authoring.cgi, oder
> comp.infosystems.www.browsers.misc. (Entschuldigen Sie mich, Ich spreche nur
> Shei_deutcsh. :)
>
> --
> Steve Linberg, Systems Programmer &c.
> National Center on Adult Literacy, University of Pennsylvania
> email: <linberg@literacy.upenn.edu>
> WWW: <http://www.literacyonline.org>
--
Thanks,
__________________________
Bill Williams
ERP Systems Administrator
Cisco Systems - RTP-IS
--------------2243D4315199261A497AD1F5
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Not bad for "Sheißdeutcsh"
<p>:-)
<p>Steve Linberg wrote:
<blockquote TYPE=CITE>In article <3701C556.B05902C1@abs.ascom.ch>, Toggweiler
Mike
<br><ntogmi@abs.ascom.ch> wrote:
<p>> Hi
<br>>
<br>> Ich habe erneut ein Problem mit dem File Upload im Internet Explorer
3.0
<br>> und 4.0. Den Patch für IE3 habe ich installiert. Jetzt kann
ich die
<br>> Datei via Brows Button auswählen, das Verzeichnis und der Dateinamen
<br>> werden mir übermittelt, aber die Datei kann ich immer noch nicht
lesen.
<br>> Durch das erstellt mein Script eine 0 Byte Datei. Wie schon gesagt
<br>> funktioniert im Gegensatz dies alles mit Netscape.
<br>> Hat jemand eine Idee, an was das liegen könnte?
<p>Ihr Problem hat nichts mit Perl zu tun, glaube Ich. Versuch mal
<br>vielleicht in comp.infosystems.www.authoring.cgi, oder
<br>comp.infosystems.www.browsers.misc. (Entschuldigen Sie mich,
Ich spreche nur
<br>Sheißdeutcsh. :)
<p>--
<br>Steve Linberg, Systems Programmer &c.
<br>National Center on Adult Literacy, University of Pennsylvania
<br>email: <linberg@literacy.upenn.edu>
<br>WWW: <<a href="http://www.literacyonline.org">http://www.literacyonline.org</a>></blockquote>
<pre>--
Thanks,
__________________________
Bill Williams
ERP Systems Administrator
Cisco Systems - RTP-IS</pre>
</html>
--------------2243D4315199261A497AD1F5--
------------------------------
Date: Wed, 31 Mar 1999 10:49:52 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: flat file query Help!!!
Message-Id: <37026E50.514FE09C@mail.cor.epa.gov>
Adolphus Harris wrote:
> Hi,
> I am searching a flat file and it works well when I have a few fields
> per record.
> I have gone up to 19 fields and the length of a record now extends four
> lines in
> a pico editor. The @database=<Sourcefile>; and subsequent 'split'
> commands,will only
> work with one line of ASCII text at a time. How do I read in an entire
> record for splitting thereby avoiding the line wrap issue?
> Thanks..,
> Al.
Your construct for reading in the lines uses newlines as separators
between elements of @database. But you [and your editor] are putting
more newlines in there. You have lots and lots of options, but here
are some of the choices you have:
(1) Don't let pico put the hard returns in when you wrap a record over
multiple lines.
(2) Get a different editor that doesn't do this.
(3) Use something other than a newline to separate your records, and
learn how to use $/ to change the default input record separator.
(4) Since each record now extends over 4 lines, use join() to glue
every four elements of @database together into one line.
(5) Decide to start using one of the database modules Perl comes with,
so you don't have to mess with stuff like this anymore.
HTH,
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 31 Mar 1999 18:33:49 GMT
From: Don Roby <droby@copyright.com>
Subject: Re: Getting parent process's environment variable to change when running a perl script
Message-Id: <7dtpqe$8re$1@nnrp1.dejanews.com>
In article <7dqtsn$38f$1@client2.news.psi.net>,
abigail@fnx.com wrote:
> Timothy Trinh (timothy.trinh@attws.com) wrote on MMXXXVII September
> MCMXCIII in <URL:news:3700277A.8A20BFC3@attws.com>:
> [] I am currently running perl5 on WinNT4.0 inside of a Z-Shell. From what
> [] I understand, when ever you run a perl script, it is run in a child
> [] process. In the child process, you can access all the environment
> [] variables and make any modification to them within the child process.
> [] When the script is done executing any modification you have made to the
> [] environment variable does not affect the parent process. How can I get
> [] the modification or creation of environment variables to stick to the
> [] parent process?
>
> You install VMS.
>
But don't try this unless your NT box is an Alpha.
--
Don Roby
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 31 Mar 1999 20:17:29 +0300
From: Remedy <Remedy@bigfoot.com>
Subject: HELP !!!
Message-Id: <370258A9.AD6E4099@bigfoot.com>
I'm trying to run a DIENST server (= a perl daemon which handles digital libraries ... anyhow !)
The problem is that when the main script tries to call a sub called "open_socket" the script dies
and gives me the error msg "socket : Protocol not supported" .
Have you ever heard of any function called open_socket ?
It takes to arguments (port number and the number of servers to run - or something like that ...!)
Please if you know anything reply by email !!!
ThanX !
------------------------------
Date: Wed, 31 Mar 1999 20:30:33 +0200
From: "F." <fvdm@dds.nl>
Subject: Re: Help... Running Perl on NT
Message-Id: <37026870$0$8073@pascal>
Open regedit and follow this path:
HKEY_LOCAL_MACHINE, System, CurrentControlSet, Services, W3svc, Parameters,
ScriptMap
Then add this string value in your register:
.pl
With this value:
path/to/perl.exe "%s" "%s"
Restart your PC.
I hope this helps,
Frank.
H.A. wrote in message <7dfta0$hgd$1@News.Dal.Ca>...
>I've been having so many trouble getting Perl script to run on my NT server
4.0
>that about to quite :-( I configured everything right according to the
>instructions and the help I got from the newsgroup.
>
>The error I'm getting lately is simply when I click on Submit in one of my
HTML
>forms to run the .PL file, it opens a Save As window instead of executing
the
>script? Does anyone out there know why I'm getting that?
>
>
>Any help or hints will greatly be appreciated.
>Thanks
>
------------------------------
Date: 31 Mar 1999 10:45:14 -0700
From: Greg Wimpey <greg.wimpey@waii*removetomail*.com>
Subject: Re: How to use set uid in Perl?
Message-Id: <snbth98set.fsf@ddcspn37.denver.waii.com>
efflandt@xnet.com (David Efflandt) writes:
> On Tue, 30 Mar 1999 18:38:49 -0500, Fu Chin Liu
> <fuchin@mail.nwos.lucent.com> wrote:
> >Does anyone know how to set uid in Perl?
[snip]
> You probably need a C wrapper since most systems ignore suid on scripts
> for security reasons.
[snip]
Easier would be to take advantage of perl's ability to recognize the
ignored setuid bits and execute 'suidperl', a setuid version of perl
that is installed by default in most(all?) Unix perl installations.
However, you then must deal with issues surrounding "tainted"
variables (i.e. variables inherited from the process environment that
evil people might try to manipulate to gain unauthorized security
privileges). See the 'perlsec' manpage for more detail.
--
Greg Wimpey
greg.wimpey@waii*removetomail*.com
------------------------------
Date: Wed, 31 Mar 1999 18:28:11 GMT
From: krish_v@my-dejanews.com
Subject: netCDF - Perl
Message-Id: <7dtpfg$8lo$1@nnrp1.dejanews.com>
Is there anyone who can provide sample Perl code
for reading files in netCDF format?
Thank you
-----------
Krish Vijayaraghavan
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 31 Mar 1999 17:24:56 GMT
From: wedrawforyou@my-dejanews.com
Subject: Newbie ques. re cgi script testing
Message-Id: <7dtlot$4vs$1@nnrp1.dejanews.com>
Hi,Apologies for what might be a real dumb ques. that maybe I should have
foundthe answer to without wasting bandwidth here but the reading that I
have doneso far leaves me unclear. So here's whats tormenting me:
I am
about to begin learning Perl with the intention of writing scripts to process
forms that I want to put up at my web site. Once I have a script how do I
testit with forms in a realistic manner. From what I have read so far I need
accessto a server, the cgi-bin directory etc. But I plan to develop at home
on myWin 95 PC with no server software on it. So what do I do after I have a
Perlscript (assuming I get that far) to see if it would work if someone
actually filledout my form and pressed submit, without having access to a
web server(I still havent rented space from an ISP).
Many many thanks in
advance,Sam G.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 31 Mar 1999 20:56:46 +0200
From: "F." <fvdm@dds.nl>
Subject: Re: Newbie questions...
Message-Id: <37026e95$0$8748@pascal>
Hello Hendrik,
I presume you are using NTServer as a host for your pages because you want
to use Access.
ASP (Active Server Pages) is better than Perl if you are using Access.
The Internet Information Server has ASP.
You can find good documentation about ASP here:
http://www.15seconds.com/
http://www.activeserverpages.com/learn/
If you're sure that you want to use Perl then you can find all the answers
here:
http://www.perl.com
Grtz,
Frank.
Henrik Widenfors wrote in message <3701F14A.D88@student.hk-r.se>...
>Hi
>
>Notice: I4ve never done Perl or CGI programming before.
>
>1. I4m supposed to do a homepage with a form that a visitor can fill in.
>Then a e-mail is supposed to be sent to a sertain e-mail adress
>containing what the visitor just wrote (name, address and comments etc).
>How can this be done? I know that I must (or?) use a CGI script. But how
>do I make my owne CGI-script? Do I have to use Perl? What is the most
>common to use in this situation? What would YOU suggest?
>
>
>2. How can I make a HTML page access a Database (for example : MS Access
>or FileMakerPro) located on the same server as the HTML page? Can YOU
>give a basic explaination.
>Here what I think about it so far (please correct me) : I use a
>HTML-page and in this page I call my CGI-script. From the CGI-script I
>access the Database. Can the CGI-script forwad data loacated in the
>Database to the HTML-page? What4s the difficulties in building a
>application like this? Where do YOU think I have to spend the most time?
>
>
>Any suggestions and answer would be greatly appretiated. Thanks
>
>Please email to : pt98hwi@student.hk-r.se aswell
>
>
>/ Henrik Widenfors
------------------------------
Date: Wed, 31 Mar 1999 16:37:33 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: Opening >2Gb files on AIX
Message-Id: <37094e91.8474345@news.ford.com>
On Wed, 31 Mar 1999 11:19:33 +0800, Ron Grunwald
<rong@prth.tensor.pgs.com> wrote:
>Hi all,
Hi there. comp.lang.perl no longer exists as a viable newsgroup.
>I've recently come across a problem where my Perl script attempts
>to open a file of around 2.2Gb in size. It couldn't do it.
>Files below 2Gb in size do open successfully. I've used the open ()
>and sysopen () Perl functions for this.
>
>The operating system that the script runs on is AIX 4.2.1, which
>does support file sizes of > 2Gb. The Perl release that I'm using
>is 5.004.
I had a similar problem a while ago. I got rid of it by re-compiling and
re-linking perl under AIX 4.2. It's not perl's fault, it was probably
compiled when the underlying OS/Libraries only supported <2GB.
It's time to get a newer version of Perl anyways. :-)
--
Clinton A. Pierce "If you rush a Miracle Man, you get rotten
clintp@geeksalad.org Miracles." -- Miracle Max, The Princess Bride
http://www.geeksalad.org
------------------------------
Date: 31 Mar 1999 10:53:03 -0700
From: Greg Wimpey <greg.wimpey@waii*removetomail*.com>
Subject: Re: Opening >2Gb files on AIX
Message-Id: <snaewt8s1s.fsf@ddcspn37.denver.waii.com>
Khelben Blackstaff <khelben_blackstaff@my-dejanews.com> writes:
> In article <Pine.SOL.3.96.990331105834.3464I-100000@swan>,
[snip]
> > My question then is: Does Perl provide a facility whereby files
> > of size greater than 2Gb can be processed successfully ?
> >
>
> I have never tried to open such large files, but do you use the
> "Large file enabled JFS" with some latter fix ?
>
> Perhaps upgrading to perl 5.005_02 would also help.
The problem with large files on AIX (and maybe other OSes as well) is
that not only must the file system be "large file enabled", but
special system calls must be used to work with large files. These
system calls expect 64-bit offsets and thus have names like open64,
read64, etc. So, even if you have a >2GB file on a large-file-enabled
filesystem, you still won't be able to read the file unless your code
is 64-bit clean. I imagine that perl does not attempt to handle files
with 64-bit offsets. There would either need to be a perl equivalent
of the 64-bit system calls (which doesn't sound very perl-ish) or else
perl would need to figure out that a file is large and open it with
the correct system call and use the 64-bit calls on all subsequent
file operations (which sounds perl-ish but also sounds tricky).
--
Greg Wimpey
greg.wimpey@waii*removetomail*.com
------------------------------
Date: Wed, 31 Mar 1999 10:56:43 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Perl calling MS Word
Message-Id: <37026FEB.8CAC6ECF@mail.cor.epa.gov>
Scott McMahan wrote:
> Bob Daly (bdaly@averstar.com) wrote:
> > Does anyone know how to call Word in Perl?
>
> You must use Automation.
>
> If you can wait til August, I have a book coming out which
> discusses this.
Or, if you're the impatient type (:-), you could use DejaNews
to search through the threads on this from the listserv
win32-perl-users. Or you could subscribe to this by going
to ActiveState and following their links.
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 31 Mar 1999 09:34:28 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: program interaction using <<HERE docs
Message-Id: <37025CA4.6418DA08@mail.cor.epa.gov>
Christian M. Aranda wrote:
> On Wed, 31 Mar 1999 02:53:41 GMT, Rick Delaney <rick.delaney@home.com>
> wrote:
>
> >You *really* aught to look into installing the module yourself. Please
> >don't ignore people's helpful suggestions.
> >
> >I hope James doesn't mind me ripping off his answer, but it *will* help
> >you out.
> >
> >I R A Aggie wrote:
> >:
> >: I believe what you seek is 'perldoc perlfaq8', specifically:
> >:
> FYI - I wasn't ignoring his help. I stated a couple of times that the
> sysadmin WILL NOT let a module be on his machine. Period. End of
> story. It doesn't matter where I put it. Period.
I believe that the newsgroup is trying to gently lead you to a section
in the FAQ which explains that you can put the modules you want on your
machine, and just tell Perl where to look. Since you have referred to
the machine in question as 'his machine', I am assuming that you work
from a different one.
If not, then perhaps you can get a new sysadmin. :-)
> I don't mean to sound hostile, I'm not. I just don't like getting
> responses to messages that don't take in to account what my original
> post said.
>
> (I'm sure I'll get flamed for this.)
I hope not. I think that part of the problem is that English is not
always as specific a language as we like to pretend. There may have
been some misunderstanding on the part of one or more people in this
thread. Including perhaps you. And certainly me. :-)
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 31 Mar 1999 13:13:37 -0500
From: "tavi" <tavi367@ibm.net>
Subject: Re: Q Mail::** - solved
Message-Id: <3702655f@news1.us.ibm.net>
Steve Linberg wrote in message ...
>In article <37021982@news1.us.ibm.net>, "tavi" <tavi@earthling.net> wrote:
>
>> It seems that after explaining my problem to you fine folks, and
re-reading
>> the documentation I have, I stumbled upon my answer.
>
>Why not share it so others can benefit from your solution?
Your right, sorry.
This is what I have done to get just the HEAD of an e-mail via STDIN
Walter
=========
#! /usr/local/bin/perl -w
use Mail::Header;
use Mail::Internet;
# Pull message in from pipe
my @mail = <STDIN>;
# Place message into Mail Object
my $r_mail = new Mail::Internet(\@mail);
# Place just the header into an Object
my $r_header = $r_mail->header();
# Retrieve a single TAG from header
my $from = $r_mail->get ('List-Unsubscribe');
# Un-comment any one of these to see results.
# Print the TAG
# print $from;
# Display entire Header
# &display_array ($r_header);
# Display entire message
# $header->print(\*STDOUT);
# eof
------------------------------
Date: 31 Mar 1999 12:18:16 -0500
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: random elements from an array
Message-Id: <7dtlco$30u$1@pilot.njin.net>
Hello -
"TinP" <tgj@snip..net> writes:
>How can you take a random element of an array yet not randomly choose it
>again?
>I want to simulate some cardgames and I set up an array called @cards
>("Ad","2d","3d", etc for 52 elements
>(to let you know: Ad = Ace of Diamonds 2d = 2 of Diamonds......)
>What I want to do is grab a random element but not repeat it. I can do that
>but I would like to know how I can "Deal a hand" without repeating an
>element I already chose.
One way would be to randomize the whole deck, and then deal from it.
Here's an implementation of that approach:
#!/usr/local/bin/perl -w
use strict;
# Regular deck:
my @cards = map{my $s=$_;map{"$_$s"}('A',2..10,qw(J Q K))}qw(d c q s);
# Create a list of numbers 0..51, in random order.
my @ord = (0..51);
my @mixed;
while (@ord) { push @mixed, splice (@ord, int(rand(@ord)), 1) }
# Shuffle the deck.
my @shuf = @cards[@mixed];
# Deal a hand, removing the cards from the deck (no danger of repeating)
my @hand = splice (@shuf, 0, 5);
print join "\n", @hand, "";
__END__
(You could modify that to just choose a hand randomly from the ordered
deck, of course.)
David Black
dblack@pilot.njin.net
------------------------------
Date: Wed, 31 Mar 1999 17:48:13 GMT
From: Don Roby <droby@copyright.com>
Subject: Re: random elements from an array
Message-Id: <7dtn4q$6ee$1@nnrp1.dejanews.com>
In article <7dsd12$4kj$1@news1.fast.net>,
"TinP" <tgj@snip..net> wrote:
> How can you take a random element of an array yet not randomly choose it
> again?
>
You remember which ones you've already chosen. There are several ways to do
this. If you don't mind rearranging the array, the easiest way is to swap
the chosen element to the end or the array and reduce your random range for
the next selection.
> I want to simulate some cardgames and I set up an array called @cards
> ("Ad","2d","3d", etc for 52 elements
> (to let you know: Ad = Ace of Diamonds 2d = 2 of Diamonds......)
>
> What I want to do is grab a random element but not repeat it. I can do that
> but I would like to know how I can "Deal a hand" without repeating an
> element I already chose.
>
If you're going to deal the whole deck (or even near it), you might want to
shuffle it first and then deal. See perlfaq4's section "How do I shuffle an
array randomly?" for a good algorithm.
--
Don Roby
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 31 Mar 1999 10:16:39 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: random elements from an array
Message-Id: <37026687.E7E86DEC@mail.cor.epa.gov>
TinP wrote:
> How can you take a random element of an array yet not randomly choose it
> again?
>
> I want to simulate some cardgames and I set up an array called @cards
> ("Ad","2d","3d", etc for 52 elements
> (to let you know: Ad = Ace of Diamonds 2d = 2 of Diamonds......)
>
> What I want to do is grab a random element but not repeat it. I can do that
> but I would like to know how I can "Deal a hand" without repeating an
> element I already chose.
>
> For example this below will pick 5 random elements but it may pick the same
> one twice.
> @cards = ("Ad","2d","3d", etc up to 52 );
>
> srand();
> while ($count < 5){
> print @cards[&randomcard];
> print "\n";
> $count++;
> }
> sub randomcard{
> $num = int(rand(52));
> }
Ah yes. Sampling without replacement vs. sampling with replacement.
You have several choices (of course - this is Perl). One way is to
use splice() to cut the element out of @cards.. but this will eventually
eat your array, so you'll have to re-create it each time.
An alternative (which I recommend if you want to pull more than 5 cards
out) is the shuffling algorithms provided in the Perl Cookbook. The
code is available at www.ora.com if you hunt for it.
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 31 Mar 1999 17:17:52 GMT
From: anewhall@whoi.edu (Arthur Newhall)
Subject: Regex with lookahead help
Message-Id: <7dtlc0$nu42@dilbert.whoi.edu>
Hi all,
I am having trouble creating a regex to do this
"match everything up to the first % that isn't preceded by a \"
I seem to be able to do this with a loop, split,... but I would
rather use a regular expression.
This is my problem and what I have come up with so far:
$a = 'aa\%bbb%ccc';
($good) = $a =~ /^(.*)(?!\\)%/;
print "found: $good \n\n";
It works correctly for such things as:
aaa%bbb --> aaa
%aaa --> nul
aaa\%bbb%ccc --> aaa\%bbb
However, it doesn't work correctly for:
aaa%bbb%ccc --> aaa%bbb
aaa\%bbb --> aaa\
It seems like this should be an easy problem to solve but I am
running into a brick wall. Any suggestions on how to do this
would be greatly appreciated!
Thanks,
Arthur
--
Arthur Newhall, Research Specialist email: anewhall@whoi.edu
Applied Ocean Physics & Engineering Dept. office: (508) 289-3317
Woods Hole Oceanographic Institution fax: (508) 457-2194
Woods Hole, MA 02543 http://www.oal.whoi.edu
------------------------------
Date: Wed, 31 Mar 1999 12:37:32 -0600
From: David Delikat <ddelikat@protix.com>
Subject: Re: Running a perl script as a daemon....
Message-Id: <37026B6C.2F1C@protix.com>
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?
>
> --
> Tad McClellan SGML Consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
oh for crying out loud, I just joined this group and the first thing I
see is some bonehead picking on spelling, and it isn't even wrong.
it just isn;t the spelling he likes. I might just as well turn around
and go home.
-dav
--
<((((><
Consultant: Internet, Database, Business Systems
Unix/Linux, Windows95/NT
mailto:david-delikat@usa.net / http://obj.webjump.com/
------------------------------
Date: Wed, 31 Mar 1999 17:21:09 GMT
From: jimbob4334@my-dejanews.com
Subject: search and replace in a file
Message-Id: <7dtlhr$4tm$1@nnrp1.dejanews.com>
I already have a file open,
I am able to chop off the end of the file and print stuff to bottom.
How would I open the file, find the first occurence of /\d{d} and
substitute is with $today?
I am missing something subtle.
I was trying
while (<FILE_OUT1>) {
last if s/\d{6}/$today/;
}
It is not putting the substitution into the file - I was not sure of the best
way to do it without saving to a temp file.
Thanks for any help,
Jim
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 31 Mar 1999 17:53:58 GMT
From: jimcclur@ews.uiuc.edu (Jordan I. K. McClure)
Subject: Re: search and replace in a file
Message-Id: <7dtnfm$c63$1@vixen.cso.uiuc.edu>
This is an FAQ from perlfaq5: How do I change one line in a
file/delete a line in a file/insert a line in the middle of a
file/append to the beginning of a file?
jimbob4334@my-dejanews.com wrote:
:
: I already have a file open,
:
: I am able to chop off the end of the file and print stuff to bottom.
:
: How would I open the file, find the first occurence of /\d{d} and
: substitute is with $today?
:
: I am missing something subtle.
:
: I was trying
:
: while (<FILE_OUT1>) {
: last if s/\d{6}/$today/;
: }
:
: It is not putting the substitution into the file - I was not sure of the best
: way to do it without saving to a temp file.
:
: Thanks for any help,
:
: Jim
:
: -----------== Posted via Deja News, The Discussion Network ==----------
: http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
--
Think "HONK" if you're a telepath!
------------------------------
Date: Wed, 31 Mar 1999 18:01:52 GMT
From: jambutter@my-dejanews.com
Subject: Sorting lines.
Message-Id: <7dtnub$74j$1@nnrp1.dejanews.com>
I want to sort the lines of a file, is there anyway to do this without using
an array?
I've assumed so and am trying to use an array. Each element of the array will
be something like "abc.def". I want to sort on everything after the '.' (if
equal, ideally, I'd like to then search on everything before the '.').
This is what I've tried so far:
@array = sort by_afterdot @array.
sub by_afterdot
{
$a =~ /\./;
$a = $';
$aa = $`;
$b =~ /\./;
$b = $';
$bb = $`;
($a cmp $b) || ($aa cmp $bb);
}
Unfortunately, I do not seem to get anywhere near the result I want when I do
a print.
What am I doing wrong?
Also, if I am trying to get everything after the . of a string, is the method
I've used best? Or should I use split?
Any help would be much appreciated.
Thanks.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 30 Mar 1999 18:02:57 -0800
From: "Craig Hobbs" <craigh@visio.com>
Subject: Uninstalling modules????
Message-Id: <922845778.145.97@news.remarQ.com>
Seems that there's volumes of information on installing modules. What about
uninstalling a module? Is there any reliable way to do this? Or does one
just have to start deleting files?
Thanks,
Craig
------------------------------
Date: Wed, 31 Mar 1999 18:24:41 GMT
From: "Theodore" <newsgroups@kidkaboom.frogspace.net>
Subject: Re: Unknown Error
Message-Id: <3702688f.0@news3.escape.ca>
Your going to have better luck if you install apache to a dir right on the
root, like c:\apache then it works a lot better in my experience. You
should also install perl to something like c:\usr (similar to unix) then you
can put #!/usr/bin/perl as the first line (same as Unix)
>From Theodore
--------------------
Digital Space CGI Programmer
<http://digitalspace.net/>
Web sites I maintain:
<http://kidkaboom.frogspace.net/>
<http://geocities.com/~kidkaboom/>
<http://reviewcenter.com/>
--------------------
souhaib@my-dejanews.com wrote in message
<7dt2ka$jnu$1@nnrp1.dejanews.com>...
>When i try to execute a CGI-Perl program in my page web, the program don't
>execute.
>So, when i consult the file "error.log", always the next message was
writing:
>
>Premature end of script headers: c:/program files/apache
group/apache/cgi-bin/
>[programme.pl]
>
>Q: what means this message?
>Q: Where is the problem?
>Q: what the purpose solution?
>
>NB: in the perl program's header, i put always "#!c:/perl/bin/perl.exe"
>
>Thanks !
------------------------------
Date: Wed, 31 Mar 1999 16:48:36 GMT
From: karasp@my-dejanews.com
Subject: Use of Require in Win32
Message-Id: <7dtjl1$310$1@nnrp1.dejanews.com>
I am trying to use the require statement to re-use sub routines in several
scripts. I keep getting the error that the file to be included does not return
a true value. I am using perl version 5.005_02.
Thanks
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 31 Mar 1999 12:12:42 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Use of Require in Win32
Message-Id: <linberg-3103991212420001@ltl1.literacy.upenn.edu>
In article <7dtjl1$310$1@nnrp1.dejanews.com>, karasp@my-dejanews.com wrote:
> I am trying to use the require statement to re-use sub routines in several
> scripts. I keep getting the error that the file to be included does not return
> a true value. I am using perl version 5.005_02.
Well, your file is probably not returning a true value then. :)
End it with this:
1;
--
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
email: <linberg@literacy.upenn.edu>
WWW: <http://www.literacyonline.org>
------------------------------
Date: Wed, 31 Mar 1999 18:37:17 GMT
From: "Rick K" <rkoehler@osmre.gov>
Subject: Re: Win32::Internet FTP question
Message-Id: <F9H2Ds.E83@igsrsparc2.er.usgs.gov>
Andy Watts asked:
>I have a question, what would make the following code work? I'm trying to
>upload to a NT server and nothing ever seems to be either read, or sent at
>all.
>
>------------------------------
>
>use Win32::Internet();
[snip rest of code ...]
Without delving into what you may or may not be doing wrong in your code,
I'd suggest you take a gander at Net::FTP as an alternative module.
It will accomplish what you desire, works well (for me, at least), and is
documented fairly well. I've run it on NT boxes, etc., and have gotten
the results I wanted (cleaner cleans, fresher breath, more zip).
Not to say that Win32::Internet can't do it, but I think you'll find Net::FTP
easier (?). Of course, if you want to use Win32::Internet for other reasons,
I've done you no help. Good luck.
------------------------------
Date: Wed, 31 Mar 1999 10:49:27 -0600
From: Tom Briles <tbriles@austin.ibm.com>
Subject: www.pm.org
Message-Id: <37025217.7465BAA0@austin.ibm.com>
Not a perl (or Perl) question, but is this still supposed to be the Perl
Monger page?
Seems the page now goes to Smith Renaud (who was hosting, I believe?).
- Tom
------------------------------
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 5269
**************************************