[6317] in Perl-Users-Digest
Perl-Users Digest, Issue: 939 Volume: 7
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 13 11:17:24 1997
Date: Thu, 13 Feb 97 08:00:30 -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, 13 Feb 1997 Volume: 7 Number: 939
Today's topics:
Re: "scalar each" - what does it mean? <nmljn@wombat.staff.ichange.com>
Re: $I{$J}{$K} (Anthony Bucci III)
[Q] Installing Perl on NT4 running EMWACS (Donncha Redmond)
Re: Appending to the top of a document... <jander@jander.com>
Re: Calling html page from perl script????? <nmljn@wombat.staff.ichange.com>
Convert real names --> email aliases <paul.joslin@sdrc.com>
Re: DBfile verses no DBfile <tmh@possibility.com>
Re: first PERL program <merlyn@stonehenge.com>
Re: Getting "return status" from cmd in a rsh call <nmljn@wombat.staff.ichange.com>
Re: grep in `command|grep pattern` seems not to work ?? <rfi@uebemc.siemens.de>
Re: Help in setting up S/// <ajohnson@gpu.srv.ualberta.ca>
Re: Help in setting up S/// (Keith Arner)
Re: Help with Redirect Script <nmljn@wombat.staff.ichange.com>
How do I know if my perl-bin has been build with sfio? (Kjetil Skotheim)
Re: How do I know if my perl-bin has been build with sf (Mike Stok)
how to e-mail the content of a associate arry? (Zhitao Wang)
howto match newlines? (Christoph Ender)
Re: howto match newlines? (Dave Thomas)
It was supposed to be easy... socket.. <sgbeal@icsi.net>
Need to convert from Date to Work Week.... How can this <patrickt@tm.net.my>
Re: Perl5 : Calling Parent Method <jander@jander.com>
Re: REQ: Getting the amount of files in a certain direc <jander@jander.com>
search engines like infoseek (David Waters)
Re: Solaris2.5 Perl 5 instalation (Mike Stok)
Re: Sorting a Hash of a Hash ? <jander@jander.com>
Re: Sorting a Hash of a Hash ? (Mik Firestone)
Stumped on INPUT_RECORD_SEPARATER problem - please help <cc42735@hrp6.FMR.com>
Re: subtle (to me) RE problem <jander@jander.com>
Using dbmopen and dbmclose in a cgi script (Tamas Acs)
writing to guestbook-file under UNIX doesn't work... (Arjan)
Re: writing to guestbook-file under UNIX doesn't work.. <jander@jander.com>
Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 13 Feb 1997 09:43:07 -0500
From: nelson <nmljn@wombat.staff.ichange.com>
Subject: Re: "scalar each" - what does it mean?
Message-Id: <w10g1z0ydfo.fsf@wombat.staff.ichange.com>
thomaso@best.com (Thomas Andrews) writes:
> My Perl 5 Camel book has the following code in the TIEHASH example
> (on pg 315):
>
> sub NEXTKEY {
> carp &whowasi if $DEBUG;
> my $self=shift;
> return scalar each %{ $self->{CONTENTS} };
> }
>
> For the life of me, I couldn't figure out what the "scalar" is doing
> here. I thought "each" returned a perl list of two elements - a
> key and value. And when you evaluate the list in "scalar" context
> it returns the number of elements, which would be 2 if we are still
> processing, and 0 otherwise.
Well, There's No General Rule For Turning A List Into A Scalar, as it
says somewhere in one of the fine documents. Without spending too
much time on this, I'd assume that when you get a two element list
back from each and you scalar() it, you probably just get the first
element. I'm basing this assumption off the fact that NEXTKEY's name
is exactly that: Next Key, which of course would be the first element
of the list returned by each.
I agree, after consulting p. 315, this is not explained very well at
all.
Cheers,
Laird
--
<laird.nelson@netsinc.com> perl FAQ: http://www.perl.com/perl/faq Perl manual:
http://www.perl.com/CPAN/doc/manual/html/frames.html. If CGI/web appears in
your comp.lang.perl.* post, see news:comp.infosystems.www.authoring.cgi. CGI
stands for Common Gateway *Interface*, not Language or Program or Script.
Consolidated perl reference page: http://www.amherst.edu/~ljnelson/perl.html
------------------------------
Date: 13 Feb 1997 15:40:19 GMT
From: axb21@po.CWRU.Edu (Anthony Bucci III)
Subject: Re: $I{$J}{$K}
Message-Id: <5dvcl3$t43@alexander.INS.CWRU.Edu>
In a previous article, jander@jander.com (Jim Anderson) says:
>Chris_Houck@i2.com writes:
>
>
>> Works in perl5, what do I do to get the same functionality
>> to be backward compatible with perl4?
>
>You don't; perl4 doesn't support multidimensional arrays. In order to
>get similar functionality in perl4, you need to use split/join. For
>example,
There were indeed multidimensional arrays in perl4, but they were
"faked." Thus, notation like:
$array[0,1,1] = 10;
will work in perl4, and will do what you expect it to. This notation is
actually shorthand for something like (this is paraphrased from the Camel
book):
$array[join($;,(0,1,1))];
Perl4 used the $; variable to hold the default separator in these "faked"
multidimensional arrays. The same notation works for associative arrays.
You could get pretty far using this notation, if you were tricky. Perl5's
references are far superior, though.
Anthony
--
------------------------------
Date: Thu, 13 Feb 1997 14:44:29 GMT
From: donncha@xcomms.ie (Donncha Redmond)
Subject: [Q] Installing Perl on NT4 running EMWACS
Message-Id: <33032806.97745360@news.ieunet.ie>
Hi all,
I've set up my machine as a web server. I'm running EMWACS under NT4 and am
trying to install Perl 5 on it. The Perl installation went OK, but when I
try and get a form to run a script i get told that it can't find the URL.
The path to the Perl exe is correct in the system path and I've assigned
the .pl extension to the Perl exe from explorer.
Have any of you come across a similar experience and if so can you help me
out?
Many thanks,
Donncha Redmond
------------------------------
Date: 13 Feb 1997 09:11:20 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: Appending to the top of a document...
Message-Id: <ybcsyewn.fsf@jander.com>
nvp@shore.net (Nathan V. Patwardhan) writes:
> ubiquitous (Jonathan Eisenman) (ubiquitous@beachside.com) wrote:
> : ...is it possible? I once saw it done (I think it is what they were doing)
> : with a for statement, but I like to be original, and after all, quoting
> [snip]
>
> I've always done something using read/write mode.
>
> $logfile = '/path/logfile.log';
>
> open(LOG, "+<$logfile") || print("NO: $!\n"); ###open in read/write mode
> @lines = <LOG>; ### slurp lines in an array
> seek(LOG,0,0); ### start at the beginning of the file
> print LOG "New text here.\n";
>
> ### now put the old stuff back.
> foreach $line (@lines) {
> print LOG $line; ### output the line back into the logfile
> }
> close(LOG);
Of course the safest thing is to write to a new file, close it, delete
the old, rename the new to the old.
--
Jim Anderson jander@jander.com
PGP Public Key Fingerprint: 0A 1C BB 0A 65 E4 0F CD
4C 40 B1 0A 9A 32 68 44
------------------------------
Date: 13 Feb 1997 09:01:56 -0500
From: nelson <nmljn@wombat.staff.ichange.com>
Subject: Re: Calling html page from perl script?????
Message-Id: <w10lo8syfcb.fsf@wombat.staff.ichange.com>
Charles Norton <Charles@hnnet.demon.co.uk> writes:
> The exact code I have used is:
> print "Location: http://www.axial.co.uk/netx_webx_dnld.html";
> But rather than displaying the web page netx_webx_dnld.html, the text
> enclosed in the brackets is shown on the web browser.
The reason that is not working is because you are not terminating it
with two newlines. Say this instead:
print STDOUT "Location: http://www.axial.co.uk/netx_webx_dnld.html\n\n";
That's the sorcery answer. For an understanding of the sorcery behind
said answer, see news:comp.infosystems.www.authoring.cgi, and the RFC
document for HTTP, available at ftp://ds.internic.com somewhere.
Cheers,
Laird
--
<laird.nelson@netsinc.com> perl FAQ: http://www.perl.com/perl/faq Perl manual:
http://www.perl.com/CPAN/doc/manual/html/frames.html. If CGI/web appears in
your comp.lang.perl.* post, see news:comp.infosystems.www.authoring.cgi. CGI
stands for Common Gateway *Interface*, not Language or Program or Script.
Consolidated perl reference page: http://www.amherst.edu/~ljnelson/perl.html
------------------------------
Date: 13 Feb 1997 08:58:23 -0500
From: Paul Joslin <paul.joslin@sdrc.com>
Subject: Convert real names --> email aliases
Message-Id: <y4du3ng95a8.fsf@heimdall.sdrc.com>
I vaguely remember a perl script that took a list of real names and
generated a list of plausible email aliases. AltaVista and similar
tools can't find anything. Does anyone have any pointers?
I'd like something that given
Paul Joslin user1@host1
Robert Smith user2@host2
Matt C. Jones user3
generates
Paul.Joslin user1@host
Paul_Joslin user1@host
P.Joslin user1@host
P_Joslin user1@host
pj1@host
Robert.Smith user2@host2
Robert_Smith user2@host2
R.Smith user2@host2
R_Smith user2@host2
Bob.Smith user2@host2
Bob_Smith user2@host2
Matt.C.Jones user3
Matt_C_Jones user3
Matt_Jones user3
Matt.Jones user3
Matthew_Jones user3
etc
and notify of collisions...
Respond here or via email. I will summarize email replies.
Thanks.
--
Paul R. Joslin paul.joslin@sdrc.com +1 513 576 2012
I guess we were all guilty, in a way. We all shot him, we all skinned
him, and we all got a complimentary bumper sticker that said, "I
helped skin Bob." -- Jack Handey
------------------------------
Date: Thu, 13 Feb 1997 07:27:20 -0800
From: Todd Hoff <tmh@possibility.com>
Subject: Re: DBfile verses no DBfile
Message-Id: <330332D8.6B72@possibility.com>
Geoffrey Hebert wrote:
>
> Proplem: 50 online internet users using an application. Count each
> application access by user. Each user has a user-id.
>
> Everyone uses DBfile. But why?
For a 50 user solution files are just fine. But 30000
files in one directory might be slow depending on the
OS. Many unix OSs use in a linear search for looking
up a file in a directory. At 30000 files this is a high
hit. If your transaction rate is low this may
not matter.
A way around this to use a deeper directory structure
so fewer files end up in the leaf directories. This approach
works well on several levels. Assuming the files are text
then humans can see and edit them. Flock works on files
which are naturally there in this approach. It increases
parallelism because you don't have to lock a single DBM
file. And the access time will be small and constant.
-------------------------------------------------------------------------
tmh@possibility.com | I have no interest in any ship that does
not
http://www.possibility.com | sail fast, for I plan to go in harm's way.
| J.P. Jones, Captain, U.S. Navy Jan 17, 1777
------------------------------
Date: 13 Feb 1997 07:46:07 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: senthil@ti.com
Subject: Re: first PERL program
Message-Id: <8cenekix1s.fsf@gadget.cscaper.com>
>>>>> "Senthil" == Senthil Velayudham <senthil@ti.com> writes:
Senthil> I am just about to create my first PERL program. I need your
Senthil> tips/help from all of you.
Senthil> I have a form with two list boxes. One listbox for region and
Senthil> another for year. If the user chooses a region and a year, my
Senthil> Perl program should be kicked off and a HTML file should be
Senthil> posted when the user hits the "SUBMIT" button. Its quite
Senthil> obvious that, if the user chooses a different Region and a
Senthil> different year, my program should bring up a totally
Senthil> different URL.
Gee, for *my* first Perl program, I just got "hello world" to work.
:-)
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 565 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
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@ora.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: 13 Feb 1997 09:20:06 -0500
From: nelson <nmljn@wombat.staff.ichange.com>
To: grajek@orasis.com
Subject: Re: Getting "return status" from cmd in a rsh call
Message-Id: <w10k9ocyei1.fsf@wombat.staff.ichange.com>
[courtesy copy sent to author via email]
grajek@orasis.com writes:
> I am having no luck getting the execution status of "tar"
> using "rsh" in a perl script. Here is my attempt:
> $rc = system("tar -cOz -T $TAR_LIST | rsh rsite tar -xz -C $REM_DIR");
> $rc = $? >> 8;
> print("Remote tar results rc=$rc\n");
Aha. Just the thing that took me months to solve. You will get at
least one response pointing you at ersh.sh, a very useful and totally
uncommented and therefore black-box shell script that echoes back the
status of a shell command on STDOUT. You can certainly use that.
It's uglier than sin. Basically you call it instead of rsh and it
will return the status of the command *it* executes.
How does it do what it does?
The basic premise is to do a lot of STDOUT/STDERR redirection and then
have a wrapper shell script fire off tar and then echo back the
shell's $? variable, which represents the status of the last command.
For those who are interested as well, I've written a module that I'm
using in production at work that lets you run shell commands remotely
via rsh, but in native perl (well, except for the rsh part :-)). You
basically feed it a moderately backslashified shell script (it does
all the NASTY quoting for you), wherein you may echo back strings that
describe the progress of your script. Then you feed it a hash table
of those response codes and code references, so that as your remote
script is running, you can run code based on its incremental output.
It needs a bit of generalizing work done to it, but if there's any
interest I'll invest the time and do it.
Hope this helps,
Cheers,
Laird
--
<laird.nelson@netsinc.com> perl FAQ: http://www.perl.com/perl/faq Perl manual:
http://www.perl.com/CPAN/doc/manual/html/frames.html. If CGI/web appears in
your comp.lang.perl.* post, see news:comp.infosystems.www.authoring.cgi. CGI
stands for Common Gateway *Interface*, not Language or Program or Script.
Consolidated perl reference page: http://www.amherst.edu/~ljnelson/perl.html
------------------------------
Date: 13 Feb 1997 13:05:19 +0100
From: Ronald Fischer <rfi@uebemc.siemens.de>
Subject: Re: grep in `command|grep pattern` seems not to work ????
Message-Id: <xz2zpx8kj28.fsf@uebemc.siemens.de>
Well, the problem with
@files = `(rsh -l $remoteUser $remoteMachine
'ls -1adp $dir/* $dir/.*')|grep -v '[,/~%]$'`;
is of course that $' is interpreted as a special Perl variable.
>From see@uebemc Thu Feb 13 12:00 MET 1997
Subject: Re: email adresse von herrn hartinger
To: rfi@obelix (Ronald Fischer)
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="US-ASCII"
Content-Length: 1799
>
> > > koennten Sie mir bitte nochmals die E-Mail-Adresse von Herrn Hartinger
> > > geben? Unter seiner Telefonnummer kann ich niemanden erreichen.
> >
> > hermann.hartinger@oen.siemens.de
>
> Ich habe das doch richtig in Erinnerung, dass Herr Hartinger fuer den Usenet-
> Server zustaendig sein sollte???
>
> Ich habe versucht, ihn unter dieser Mail Adresse zu erreichen. Die Mail ist
> als unzustellbar zurueckgekommen. Ich habe dann, nach mehreren versuchen,
> dort jemanden am Telefon erreicht (25057) und erfahren, dass
> - in dieser Abteilung bei VN niemand f|r die Newsgroups zustdndig ist,
> - Herr Hartinger schon viele Monate krank ist.
>
> Da ich noch im Dezember mit einem Herrn dieses Namens telefoniert habe, muss
> das ein anderer sein. Kvnnen Sie mir da weiterhelfen?
Also, ich habe Ihnen die Mailadresse gegeben ohne mich zu erinnern wann wir
ueber einen Herrn Hartinger gesprochen haetten.
---begin Einschub---
Mailadressen koennen Sie entweder, (nur fuer oen) via commandline
mit Hilfe von
$mailsuche name
herausfinden oder ebenfalls fuer oen via www
http://www1.oen.siemens.de/cgi-bin/mail_sucher.cgi
http://search.sbs.de/x400.html
---end Einschub---
Ich entnehme Ihrer Mail dass es um news geht, fuer news
ist momentan SBS zustaendig. (Tel 3 55 55, SBS Hotline)
Es ist bei OEN geplant einen eigenen Newsserver zu betreiben, das wird
OEN CN 5 machen, dort vermutlich Herr Roeser, Tel 47829
E-mail: eckhard.roeser@oen.siemens.de
MfG
M. Seeger
--
'""
(o o)
----------------o00--(_)--00o----------------------------
Michael Seeger Internet: see@uebemc.siemens.de
Siemens OEN CN 24 / ANL TD MWE 1
Opinions are my own, not necessarily those of my employer
---------------------------------------------------------
--
Ronald Otto Valentin Fischer
business: ronald.fischer@uebemc.siemens.de
private: ronald.fischer@acm.org
http://ourworld.compuserve.com/homepages/ronald_fischer
------------------------------
Date: Thu, 13 Feb 1997 00:30:20 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Help in setting up S///
Message-Id: <3302B4FC.4A0D14E9@gpu.srv.ualberta.ca>
Keith Arner wrote:
: In article <32f25e62.13062428@news.clc.cc.il.us> mreilley@clc.cc.il.us
: (Mike Reilley) writes:
:
: > I have a text line in the format of
: >
: > Multiple leading spaces (Must Be Kept)
: > an optional asterisk ( would like to remove it ) change it to a
blank.
: > Multiple spaces (Must be kept)
: > Text ..............
: >
: > The need is to remove the optional asterisk if it is there
: > but not to remove any asterisks that may be in the text.
:
: s/(\s+)\*(\s+)/\1 \2/
:
: Keith Arner
better with:
s/(\s+)\*(\s+)/$1 $2/;
cheers,
andrew
------------------------------
Date: 13 Feb 1997 14:29:40 GMT
From: keith@stage.netsinc.com (Keith Arner)
Subject: Re: Help in setting up S///
Message-Id: <KEITH.97Feb13092940@stage.netsinc.com>
In article <3302B4FC.4A0D14E9@gpu.srv.ualberta.ca> Andrew Johnson <ajohnson@gpu.srv.ualberta.ca> writes:
> Keith Arner wrote:
> : In article <32f25e62.13062428@news.clc.cc.il.us> mreilley@clc.cc.il.us
> : (Mike Reilley) writes:
> : > I have a text line in the format of
> : >
> : > Multiple leading spaces (Must Be Kept)
> : > an optional asterisk ( would like to remove it ) change it to a
> blank.
> : > Multiple spaces (Must be kept)
> : > Text ..............
> : >
> : > The need is to remove the optional asterisk if it is there
> : > but not to remove any asterisks that may be in the text.
> :
> : s/(\s+)\*(\s+)/\1 \2/
>
> better with:
> s/(\s+)\*(\s+)/$1 $2/;
WHOOPS! Forgot about the fact that it has to match only at the start of
a line. Try:
s/^(\s+)\*(\s+)/$1 $2/;
--
--
|/ /| Keith.Arner@Industry.Net
|\ e i t h /-| r n e r
@________________
When all else fails, duct tape it.|
----------------------------'
------------------------------
Date: 13 Feb 1997 09:35:19 -0500
From: nelson <nmljn@wombat.staff.ichange.com>
Subject: Re: Help with Redirect Script
Message-Id: <w10hgjgydso.fsf@wombat.staff.ichange.com>
"Tom Hill" <tom@tomagic.com> writes:
> I am creating a page with bookmarks to the names of all 50 States. What I
> want is a dropdown menu containing thses names so that when a user selects
> a name from the menu, he/she will be taken to the appropiate bookmark.
This is not a flame, and should be construed as an honest attempt to
point you in the right direction.
Your question should be asked like this (i.e. this is how the
terminology works):
"I have an HTML page with a form on it. One of the elements in that
form is a drop-down list. I would like the selected value of that
drop down list to cause a Common Gateway Interface (CGI) compliant
program to perform a redirect action. I don't know how to do this.
Can someone help, please?"
With such a phrasing, you should notice a couple of things, which you
may not have known:
1. Perl is not mentioned anywhere in the revised phrasing of the
question. Why? Because perl has nothing to do intrinsically with the
World Wide Web or forms or HTML or HTTP or CGI or any of that. Perl
is a programming language. The Common Gateway Interface is a, well,
an Interface, i.e. something that tells you *how* to get the
information you'll need to process. In this case, all the CGI really
tells you is where the information from your form is, and where to
send any output that you want the client to see. Then it's up to you
to write a program to actually find that information and do something
to it. Much of the mass media, writing about that which they do not
understand, equates the terms "perl", "CGI", and "Web programming"
(whatever the hell THAT is). That is like equating English, the card
catalog entries in your library telling you where to find the grammar
books, and The Art Of Writing Sonnets.
2. Since perl is not mentioned you might think, "Aha. If perl is a
language, and the CGI is an interface, then it sure seems to me that I
don't need to know any language in particular to write a program
that's CGI compliant." And you would be right. If you know C, then
write your CGI-compliant program in C.
3. Also, since perl is not mentioned, you would think to yourself,
"Hmm...I seem to be in a computer language newsgroup devoted to perl.
Why am I here? Shouldn't I be in
news:comp.infosystems.www.authoring.cgi?" And the answer would be
yes.
Hope this helps,
Cheers,
Laird
--
<laird.nelson@netsinc.com> perl FAQ: http://www.perl.com/perl/faq Perl manual:
http://www.perl.com/CPAN/doc/manual/html/frames.html. If CGI/web appears in
your comp.lang.perl.* post, see news:comp.infosystems.www.authoring.cgi. CGI
stands for Common Gateway *Interface*, not Language or Program or Script.
Consolidated perl reference page: http://www.amherst.edu/~ljnelson/perl.html
------------------------------
Date: 13 Feb 1997 13:21:16 GMT
From: kjetil.skotheim@usit.uio.no (Kjetil Skotheim)
Subject: How do I know if my perl-bin has been build with sfio?
Message-Id: <5dv4gc$bni@ratatosk.uio.no>
To install FCGI with perl5 i need a perl5.003-binary subpatch 02
with sfio.
perl5 -v outputs:
This is perl, version 5.003 with EMBED
built under hpux at Nov 27 1996 15:35:59
+ suidperl security patch
How do I know if I have subpatch 2? and
how do I know if the sfio lib was included?
------------------------------
Date: 13 Feb 1997 13:56:46 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: How do I know if my perl-bin has been build with sfio?
Message-Id: <5dv6iu$10k@news-central.tiac.net>
In article <5dv4gc$bni@ratatosk.uio.no>,
Kjetil Skotheim <kjetil.skotheim@usit.uio.no> wrote:
>
>To install FCGI with perl5 i need a perl5.003-binary subpatch 02
>with sfio.
>How do I know if I have subpatch 2? and
>how do I know if the sfio lib was included?
The subpatched versions identify themselves when you use -v e.g.
$ perl -v
This is perl, version 5.003_26
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.
If your perl recognises -V then
$ perl -V:usesfio
usesfio='true';
might help.
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 13 Feb 1997 13:45:28 GMT
From: 5u16wangz@vms.csd.mu.edu (Zhitao Wang)
Subject: how to e-mail the content of a associate arry?
Message-Id: <009AFD0A.5842CE99@vms.csd.mu.edu>
I am new to perl. Now I got to e-mail the content of a associate arry to somebody, could somebody give me some instruction on how to do that please?
I would appreciate it.
e-mail:5u16wangz@vms.csd.mu.edu
Zhitao Wang
------------------------------
Date: 13 Feb 1997 15:15:54 GMT
From: chrender@rbg.informatik.th-darmstadt.de (Christoph Ender)
Subject: howto match newlines?
Message-Id: <5dvb7a$1lhs@rs18.hrz.th-darmstadt.de>
Hi!
There has been a discussion about stripping text between <a> and </a>
including newlines some time ago. I've practically the same problem,
but none of the solutions seems to work for me.
File to change contains:
------------------------------------------------------------------------
printf(
"text");
------------------------------------------------------------------------
I'm looking for an expression that will cut out anything between '(' and
the first '"', including the newlines and spaces, so that the above
input will result in printf("text");
The expression
's#(printf\()\s*("text"\);)#$1$2#'
works perfectly on
printf( "text");
Then I tried to extend it in several ways to get rid of the newlines:
's#(printf\()\s*("text"\);)#$1$2#s'
's#(printf\().*("text"\);)#$1$2#s'
's#(printf\().*?("text"\);)#$1$2#sg'
's#(printf\()(.|\n)*("text"\);)#$1$2#'
All the lines above don't change anything, no expression will match. I
think the problem is quite basic, but what am I doing wrong?
Thanks in advance,
Christoph.
---
Christoph Ender
61169 Friedberg (Germany)
mail: chrender@rbg.informatik.th-darmstadt.de
------------------------------
Date: 13 Feb 1997 15:48:59 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: howto match newlines?
Message-Id: <slrn5g6dq3.h0h.dave@fast.thomases.com>
On 13 Feb 1997 15:15:54 GMT, Christoph Ender <chrender@rbg.informatik.th-darmstadt.de> wrote:
> File to change contains:
> ------------------------------------------------------------------------
> printf(
>
>
> "text");
> ------------------------------------------------------------------------
> I'm looking for an expression that will cut out anything between '(' and
> the first '"', including the newlines and spaces, so that the above
> input will result in printf("text");
$v = 'printf(
"text");
';
$v =~ s/printf\(\s*"/printf("/gs;
print "$v";
>
> Then I tried to extend it in several ways to get rid of the newlines:
> 's#(printf\()\s*("text"\);)#$1$2#s'
Worked for me!
> 's#(printf\().*("text"\);)#$1$2#s'
Also worked
> 's#(printf\().*?("text"\);)#$1$2#sg'
Worked too
> 's#(printf\()(.|\n)*("text"\);)#$1$2#'
Didn't work, but...
Maybe there's something wrong with your test program??
Regards
Dave
--
_________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Wed, 12 Feb 1997 22:10:13 +0000
From: Stephan Beal <sgbeal@icsi.net>
Subject: It was supposed to be easy... socket..
Message-Id: <33023FC4.3C17@icsi.net>
All:
It was supposed to be really simply... log in to a server on port 1121,
send 1 line of text and log out. Unfortunately, every script I find for
logging in to a server "requires" and "uses" 18 other packages that I
don't have.
Does anyone have a script that will log in to a server (via sockets),
send 1 line and hang up? It sounds so simple (a few lines in Java)!
BTW: It's got to run on Win32 platforms. I have one that fails on the
"connect" call, but I don't know if it's because I'm on Win32... seems I
read that Win32 Perl 5.001 had problems with sockets... or maybe it was
threads.
Thanks in advance,
----- Stephan Beal
Work: Stephan.Beal@Compaq.Com
Home: sgbeal@icsi.net
WWW: http://www.he.net/~sgbeal
------------------------------
Date: Thu, 13 Feb 1997 23:13:49 -0800
From: Patrick Tan <patrickt@tm.net.my>
Subject: Need to convert from Date to Work Week.... How can this be done??
Message-Id: <330410AD.1C98@tm.net.my>
Hi,
I am in the process of writing a simple Perl script to determine
the work week, once a particular date is given.
How can I achieve this ? Appreciate your time in helping me
get to the bottom of this......
Regards,
-Patrick Tan-
------------------------------
Date: 13 Feb 1997 09:22:38 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: Perl5 : Calling Parent Method
Message-Id: <u3ngyedt.fsf@jander.com>
Christian Roy <roychri@total.net> writes:
Take a look at the perltoot manpage. I think that'll solve your
problem.
--
Jim Anderson jander@jander.com
PGP Public Key Fingerprint: 0A 1C BB 0A 65 E4 0F CD
4C 40 B1 0A 9A 32 68 44
------------------------------
Date: 13 Feb 1997 09:18:01 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: REQ: Getting the amount of files in a certain directory.
Message-Id: <vi7wyeli.fsf@jander.com>
Nathan D Richards (nathanr@k2.ashpool.com) wrote:
> I need to know how many *.D files there are in a certain directory.
> Is there anyway to do this in a CGI script?
And yet another way :)
=============================
#!/usr/bin/perl -w
my @cnt = <*.D>;
print scalar @cnt, "\n";
=============================
--
Jim Anderson jander@jander.com
PGP Public Key Fingerprint: 0A 1C BB 0A 65 E4 0F CD
4C 40 B1 0A 9A 32 68 44
------------------------------
Date: 13 Feb 1997 15:14:48 GMT
From: przec@westminster.ac.uk (David Waters)
Subject: search engines like infoseek
Message-Id: <5dvb58$h15@badger.wmin.ac.uk>
Hi all,
I was wondering if anyone could tell me how the search engines
on the web work with regard to only displaying 10 search matches
at a time.
What I am doing is writing a search engine for a client that brings
back data from their catalog.
The client now wants me to only display 10 at a time.
Has anyone got any idea how I might go about this?
Thanks alot
David
--
\\\|///
\\ - - //
( @ @ )
+----------------oOOo-(_)-oOOo----------------------+
| David Waters Email: d.w.waters@wmin.ac.uk |
| |
| World Wide Web: http://www.wmin.ac.uk/~przec |
+-------------------------Oooo----------------------+
oooO ( )
( ) ) /
\ ( (_/
\_)
------------------------------
Date: 13 Feb 1997 13:49:18 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Solaris2.5 Perl 5 instalation
Message-Id: <5dv64u$d7@news-central.tiac.net>
In article <855827120.27586@dejanews.com>, <robert@tnet.es> wrote:
>I need help installing perl 5 on my sparc 5 with solaris 2.5
>After typing configure I get an error, after many default answers ,
>that I have two makefiles.
>
>I then get an error 1 after typing make.
If you have reasonable transatlantic bandwidth then
http://smc.vnet.net/solaris_2.5_list.html
has a lot of packages set up so that you can use pkgadd to install them.
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 13 Feb 1997 08:56:02 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: Sorting a Hash of a Hash ?
Message-Id: <4tfgzu6l.fsf@jander.com>
"Chris R. Contakes" <AFconcr@dia.osis.gov> writes:
>
> I am tring to sort a hash of a hash and am having some difficulties.
>
> The record gets read in from a file and looks like:
>
>
> while (<INPUT>) {
>
> $RECORD{$SSN}{last} = $lastname;
> $RECORD{$SSN}{first} = $firstname;
>
> ......
>
> }
>
>
> Then I try to sort by the lastname. I tried a staement like:
>
> foreach $SSN (sort keys %RECORD) {
> foreach $SSN(sort keys %{$RECORD}{$SSN}{$last}})
> print.....
>
> }
> }
It's hardly surprising that this sort doesn't work as you
expected. Afterall, there's a one-to-one mapping between ssn and
last_name, so all you'll get with this is sorting by ssn.
Probably the best thing is to make last_name the primary hash key. If
that's not possible, then you might try something more along these
lines:
========================================================================
#!/usr/bin/perl -w
while (<DATA>) {
($ssn, $sex, $first, $last) = split;
$person->{$sex}{"$last,$first"}{$ssn}++;
}
foreach (sort map keys %{$person->{$_}}, keys %$person) {
print "$_\n";
}
__DATA__
345678912 male bbb dddd
123456789 male eeeeeeeeeeeeee ffff
567891234 female aaaa zzzz
456789123 male ggggggg jjjj
234567891 female hhhhh mmmmm
========================================================================
--
Jim Anderson jander@jander.com
PGP Public Key Fingerprint: 0A 1C BB 0A 65 E4 0F CD
4C 40 B1 0A 9A 32 68 44
------------------------------
Date: 13 Feb 1997 14:01:54 GMT
From: mfiresto@vnet.ibm.com (Mik Firestone)
Subject: Re: Sorting a Hash of a Hash ?
Message-Id: <5dv6si$ogi$1@mail.lexington.ibm.com>
In article <33023CC4.73D7@dia.osis.gov>,
Chris R. Contakes <AFconcr@dia.osis.gov> wrote:
>I am tring to sort a hash of a hash and am having some difficulties.
>
>The record gets read in from a file and looks like:
>
>
> while (<INPUT>) {
>
> $RECORD{$SSN}{last} = $lastname;
> $RECORD{$SSN}{first} = $firstname;
>
> ......
>
>}
>
>
>Then I try to sort by the lastname. I tried a staement like:
>
> foreach $SSN (sort keys %RECORD) {
> foreach $SSN(sort keys %{$RECORD}{$SSN}{$last}})
> print.....
>
Try this instead:
foreach $SSN (sort {$RECORD{$a}{last} cmp $RECORD{$b}{last}} keys %RECORD) {
print ....
}
In perl 5.003 ( at least - I can't say much about earlier versions ), you
can include an anonymous sub as your sort routine. For more info, and a
better explanation, see the perlfunc man pages on sort( search on sort BL -
that will take you to the apropriate page without too much pain ), or check
out the Camel, pages 217-219.
---------------
Mik Firestone - mfiresto@mindspring.com
Evil Overlord Rule 15: I will make it clear that I _do_ know the meaning
of the word "mercy"; I simply choose not show them any.
------------------------------
Date: Wed, 12 Feb 1997 10:47:48 -0500
From: Mark Hickey <cc42735@hrp6.FMR.com>
Subject: Stumped on INPUT_RECORD_SEPARATER problem - please help
Message-Id: <3301E624.6260@hrp6.FMR.com>
Folks,
Platform: PERL 5.001 on Solaris 2.5
I am reading an input file consisting of multiline records. Each
record is seperated by a blank line. For example:
RecordStart
item1
item2
etc
RecordStart
item1
and so forth.
I want to use the $/ variable to handle seperating the records as I read
the file. I found that if I set the $/ to "", I have the problem that
if a line seperating two records has any whitespace in it, then the
records are concatenated. I tried using various other patterns as the
$/, like "\n[ \t\f\r]*\n", with and w/o various amounts of quoting, but
as soon as I put the "[]" in, things fall apart.
Can anyone shed some light on what I am doing wrong here, or a better
way to do what I want to do? Eor various, I would like to find a
solution that uses the $/ so that I can process the input records as a
whole.
I have resorted to preprocessing the input file to remove the whitespace
from the seperator lines, but would like a better way to do this.
Mark Hickey
------------------------------
Date: 13 Feb 1997 09:08:49 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: subtle (to me) RE problem
Message-Id: <zpx8yf0u.fsf@jander.com>
Eli the Bearded <usenet-tag@qz.little-neck.ny.us> writes:
> In a script which is scoring spam, I want to be able to
> detect N or more occurances of any one of these characters:
>
> ()!%*_+=|\/,<>:~-
>
> For N=7, I have
>
> /([\(\)!%*_+=|\\\/,<>:~-]).*${1}.*${1}.*${1}.*${1}.*${1}.*${1}/
>
> And that gives me a "nested *?+ in regexp" error. Why?
Where's Jeffrey Friedl when you need him :-?
The following compiles w/o syntax errors. Whether it does what you
want is another question...
/([()!%*_+=|\\\/,<>:~-]).*\1.*\1.*\1.*\1.*\1.*\1/;
--
Jim Anderson jander@jander.com
PGP Public Key Fingerprint: 0A 1C BB 0A 65 E4 0F CD
4C 40 B1 0A 9A 32 68 44
------------------------------
Date: 13 Feb 1997 15:14:27 GMT
From: tacs@visinet.ca (Tamas Acs)
Subject: Using dbmopen and dbmclose in a cgi script
Message-Id: <5dvb4j$b23@usenet81.supernews.com>
I am trying to read data into a dbm file from a form. The script works
fine when i substitute the form values for initialized variables.
Here is what I have so far.
#!/usr/local/bin/perl -w
#
#
use DB_File;
use strict;
my (%database,@datafields,@datavalues);
my ($key,$fname,$lname);
require(*formdata);
$key = $formdata{'key'};
$fname = $formdata{'firstname'};
$lname = $formdata{'lastname'};
@datafields = ("KEY", "FIRSTNAME", "LASTNAME");
@datavalues = ($key,$fname,$lname);
dbmopen(%database,"userdata",0666);
for ($count = 1; $count <= @datafields; $count++){
$database{$datafields[$count - 1].$datavalues[0]} =
$datavalues[$count - 1];
}
dbmclose(%database);
------------------------------
Date: Thu, 13 Feb 1997 12:56:29 GMT
From: arjan.zuidhof@94.student.wau.nl (Arjan)
Subject: writing to guestbook-file under UNIX doesn't work...
Message-Id: <33030f3e.8597959@news.wau.nl>
Hi everybody,
I'm a bit of a newbie to CGI/Perl.
Now I'm seting up a guestbook ( at
http://www.student.wau.nl/~arjan/guest.htm ). Everything seems to work
fine (a new entry is mailed to me etc) only the part in which the
entry is written toi the guestbook and the entry-log doesn't work. It
seems impossible to open a file on my server and write to it.
Well, didn't make the very simple mistakes like wrong CHMOD, but
still it does;nt work. Here's the loggin-the-entry part of the script:
# Log The Entry
if ($uselog eq '1') {
open (LOG, ">>$guestlog");
print LOG "$ENV{'REMOTE_HOST'} - [$shortdate]<br>\n";
close (LOG);
}
Characters are defined of course, it should work, but it doesn't.....
What can it be? Thank you in advance for yr answers.....
Arjan
-----------------------------------------------------------------------------------------------
Arjan Zuidhof, Marijkeweg 28-C4, 6709 PG, Wageningen, Netherlands
WWW - http://www.student.wau.nl/~arjan
talk - arjan@flex123.hhome.wau.nl
mail - mailto:arjan.zuidhof@94.student.wau.nl
------------------------------
Date: 13 Feb 1997 09:28:27 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: writing to guestbook-file under UNIX doesn't work...
Message-Id: <raikye44.fsf@jander.com>
arjan.zuidhof@94.student.wau.nl (Arjan) writes:
>
> Hi everybody,
> I'm a bit of a newbie to CGI/Perl.
> Now I'm seting up a guestbook ( at
> http://www.student.wau.nl/~arjan/guest.htm ). Everything seems to work
> fine (a new entry is mailed to me etc) only the part in which the
> entry is written toi the guestbook and the entry-log doesn't work. It
> seems impossible to open a file on my server and write to it.
> Well, didn't make the very simple mistakes like wrong CHMOD, but
> still it does;nt work. Here's the loggin-the-entry part of the script:
>
> # Log The Entry
> if ($uselog eq '1') {
> open (LOG, ">>$guestlog");
> print LOG "$ENV{'REMOTE_HOST'} - [$shortdate]<br>\n";
> close (LOG);
> }
>
> Characters are defined of course, it should work, but it doesn't.....
> What can it be? Thank you in advance for yr answers.....
It's never a good idea to do an open and not check as to whether or
not it succeeded...
(You can also check your httpd error log for the exact error.)
--
Jim Anderson jander@jander.com
PGP Public Key Fingerprint: 0A 1C BB 0A 65 E4 0F CD
4C 40 B1 0A 9A 32 68 44
------------------------------
Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Jan 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.
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 V7 Issue 939
*************************************