[6573] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 198 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 28 21:14:27 1997

Date: Fri, 28 Mar 97 18: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           Fri, 28 Mar 1997     Volume: 8 Number: 198

Today's topics:
     Adding REFRESH button to frameset.cgi <jc@hendel.mko.dec.com>
     Databases - advice wanted <simont@post.its.mcw.edu>
     filename completion, not word completion? (Rand Bamberg)
     Re: Functions and operators <tchrist@mox.perl.com>
     Re: global my() variable used in foreach() loop loses i (M.J.T. Guy)
     Re: How run Perl locally? (Nathan V. Patwardhan)
     Re: How to concat many digits to be one string? (Jeff Vannest)
     Re: In need of a Perl script <eric@nettown.com>
     Need Help Troubleshooting Script (Keven D. Ficken)
     Re: Opening file for reading and writing simultaneously <tchrist@mox.perl.com>
     Re: Perl hourly fees? (Nathan V. Patwardhan)
     Perl Mail Parser Question (Luigi Mattera)
     Re: Perl mishandles some multidimensional array referen (Chris Russo)
     Re: Q: sorting by date <eric@nettown.com>
     Re: s/// fails because of embedded ()'s <rmcvay@acm.org>
     Re: Unix and ease of use  (WAS: Who makes more ...) <exec@softdisk.com>
     Re: Vanishing string terminators and premature end of s (Jeff Vannest)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 28 Mar 1997 13:52:21 -0500
From: John M Chambers <jc@hendel.mko.dec.com>
Subject: Adding REFRESH button to frameset.cgi
Message-Id: <333C1365.41C6@hendel.mko.dec.com>

Digging around in the CGI module's docs, and in various books on
web authoring didn't turn up an answer, so maybe the experts here
will have some ideas ...

After using the sample/frameset.cgi program successfully to put up a 
page with a few frames, the problem came up:  After the user pushed 
a button in one of the frames, the result was an action which made
one of the other frames's contents obsolete.  So, how can we handle
this?

One thought, of course, was to have the form do something that causes
one of the other frames to be updated.  This was a brick wall; as near
as we can tell, it ain't possible.  (But if someone knows how to make
the print_response routine update both frames, I'd like to hear about
it.  Calling &print_query didn't work; that put a copy of the query
form in the response frame.!)

The other idea was to include a REFRESH button in the request frame,
next to the SUBMIT button.  This was easy enough, and it did redraw
the query form -- in the response frame.  Gack!  It seems that the
output from the query always goes to the response frame, no matter
where you want it.

Does anyone know how to do this right?  Is it even doable?  The idea
is to, in this example, make the SUBMIT button fill the response frame,
and also have the query frame redrawn.  Automatically would be nice,
but a REFRESH button in the query frame would also be nice.

(Yes, I know that in frameset.cgi this would be pointless.  In my
page, the query frame includes a <select> list of names.  I'd like 
the response frame to add the user's name to the list of names in 
that list.  And in real life, I'm interested in having N frames,
with operations in any of them possibly triggering updates in various
subsets of the frames.)

-- 
Geek Code (V3.0):
GCC/CM/CS/E/IT/MU/O/PA/S d+ s+ a++ C++ P+++ L+++ E--- W++ N++ K+++ w O-
M V- PS++ PE- Y+ PGP+ t- 5 X- R tv-- b++ DI++++ D- G- e+++ h--- r+++
y++++


------------------------------

Date: Fri, 28 Mar 1997 13:05:29 -0600
From: Simon Twigger <simont@post.its.mcw.edu>
Subject: Databases - advice wanted
Message-Id: <333C1673.2EC8@post.its.mcw.edu>

Hi there,

We are thinking of setting up a web site which will present information
such as employee's CVs, projects they are working on, who's funding the
projects etc. The site needs to be searchable so that users can look for
people, projects, funding and other information. It will also have to be
editable so that authorised users can updata the information as
required.

Some of this data will have to be stored in some form of database as a
reference from which the other information can be extracted/found. I
have set up small databases using perl before, but just used normal text
files to store the relevant information etc, similar to password
databases and that sort of thing. I then use that information to link to
the appropriate personal files and present them to the user as required.

I can probably use the same approach to this new project, however, I am
trying to find out if there is a more sensible way to do it, such as
using more advanced database functions/modules. Can anyone give me a few
pointers as to what I might gain from using a specific database system
(ive been looking at the Berkeley DB) over a plain text file type of
approach (speed, flexibility?). Also, any advice or suggestions on what
modules (Sprite, DB_... etc. might suit my application would be most
appreciated.

Many thanks for any help you can give. :)

	Simon.

Medical College of Wisconsin, Milwaukee
simont@post.its.mcw.edu


------------------------------

Date: 28 Mar 1997 18:52:06 GMT
From: bamberg@dvorak.amd.com (Rand Bamberg)
Subject: filename completion, not word completion?
Message-Id: <5hh40m$qrt$1@amdint2.amd.com>

Hi all,

I'm interested in using perl to do filename completion for
an interactive script.  Term::Complete seems like the
answer for *word* completion, but not for filename
completion.  I found a script posted by Yuri Romanenko
almost 2 years ago called "FinishFile" which was a rewrite
of Term::Complete to query a file system... has anyone 
written a more recent version?

TIA,
Rand.

--
------------------------------------------------------------------------
rand.bamberg@amd.com          "That's no moon."           AMD|TMD|K7|CAD       


------------------------------

Date: 28 Mar 1997 18:25:41 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Functions and operators
Message-Id: <5hh2f5$7ic$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author +p5p via email]

 [P5P: what do you think of some more docs to scalar()? ]

In comp.lang.perl.misc, Tom Phoenix <rootbeer@teleport.com> writes:

:Nevertheless, some things just don't seem to be functions to me. I
:remember learning somewhere that a function returns a value. That's not
:necessarily relevant, but it affects me when I try to refer to some things
:as "functions".

You could call them subroutines. A function that doesn't return
a value people think of as a subroutine.

:The first group are functions, I suppose, but you hardly ever see their
:return values used (or even documented). Some of those are push, srand,
:study, and binmode. But I can accept those as functions, and I might as
:well include print as well, since I'm feeling generous. :-) 

Yes, those are functions.

:The next group includes last, next, redo, exec, die, dump, goto, exit, and
:return. These could be called control structures, but I'm more likely to
:call them operators.

An operator returns a value.  Can you think of one that does not
return a value?  What do those return?  I see no reason to use 
a different word for these than you would for if and while.  Yes, 
I know that you can say 

    $i++, next whatever if something();

But you shouldn't :-), and calling next an operator is just
going to confuse people.  Does C call break an operator?  What
about goto?

Actually, exit, die, and warn are obviously functions that don't return.
Look at their syntax.

:Then there are substr, pos, and vec, which may well be functions. But when
:they're used as lvalues I don't know what to call them, but it ain't
:"functions"! :-)

They're just lvaluable functions, as now is keys.

:Finally, there is scalar, which has the syntax of a function, but it's
:certainly not a function. I call it an operator, but I don't know whether
:that's right. No matter how you slice it, it's a special case.

Scalar is a real problem.  If you tell people it's a function or
an operator, they'll think it takes a value and returns one. 
Nothing could be further from the truth!  It's like a cast 
or a coercion, but even that is wrong.  

You wouldn't believe the number of people who think that scalar()
just counts its elements, or that functions in general in scalar
contexts return the count of their list returns.

Perhaps adding something like this to L<perlfunc/scalar> might help,
or maybe in the preamble to perlfunc:

    The use of function(args) in perl is really more like two entirely
    different function calls, depending on scalar or list context.
    It might help to think of this function(args) call as two similarly
    named functions as function_scalar(args) and function_list(args),
    or perhaps instead function(scalar,args) and function(list,args).
    (This is just a model; it doesn't really work this way.)  Which one
    of those you end up calling depends on the context.  The context is
    explicit, unless you give it the context hint scalar().

    Thus scalar(function(args)) isn't really calling function(args)
    and then computing its scalar nature.  Instead, it's calling
    function_scalar(args) or function(scalar,args), depending on whether
    your model is that it's a whole nother function or whether it's
    the same function with an implicit parameter.

Functions can take 0, 1, or many arguments--or even specific types
of arguments.  Functions that have been prototyped to take a scalar
argument cause an implicit coercion, as do scalar operators.

Not using parens means you rely on the reader to know how things
are prototyped to figure out how much was gobbled.  For example:

    $a = time+3;   print "$a\n";   # takes no args
    $a = int+3;    print "$a\n";   # takes one scalar arg; gens warning
    $a = unlink+3; print "$a\n";   # takes a list of args

or this

    @a = ('a'..'z');
    $a = time @a;   print "$a\n";   # takes no args, hence compiler error
    $a = int @a;    print "$a\n";   # takes one scalar arg
    $a = unlink @a; print "$a\n";   # takes a list of args

But parens won't be enough to tell people what's happening.  
Consider the socket() function that takes 4 arguments, all of
which are scalars.  You can't just do this:

    ($name,$aliases,$proto) = getprotobyname('tcp');
    @sockargs = ('SockHandle', PF_INET, SOCK_STREAM, $proto);
    socket(@sockargs);

Because socket is picky.  Heck you can't even do this:

    socket(@sockargs[0..3]);

You have to put them in as literals.  

    socket(SockHandle, PF_INET, SOCK_STREAM, $proto);

Actually, you can do more than that.  Since getprotobyname()
has a scalar return value, you can say 

    $proto = getprotobyname('tcp');
    socket(SockHandle, PF_INET, SOCK_STREAM, $proto);

And furthermore, since socket() is prototyped to take a scalar 
in the fourth slot, you don't even have to write:

    socket(SockHandle, PF_INET, SOCK_STREAM, scalar(getprotobyname('tcp')));

but rather just this, employing a bit of cryptocoercion:

    socket(SockHandle, PF_INET, SOCK_STREAM, getprotobyname('tcp'));

So what about scalar()?  It's just the tip of the iceberg of the whole
hidden context fiasco.  I think perhaps if you write it without parens
it might be better perceived as something other than a real function,
but I'm not dead-set on this matter. 

And as Larry says, you can say

    print reverse sort keys %map;
    print reverse sort keys(%map);
    print reverse sort(keys(%map));
    print reverse(sort(keys(%map)));
    print(reverse(sort(keys(%map))));

depending on what you are into.  Certianly the last is a bit annoying.

I don't generally advocate teaching beginners the sans-paren version 
just because they're expecting parens on their functions.

On the other hand, in C, sizeof really is an operator.  You can say

    n = sizeof a[i];

just fine, which would seem to show it's an operator not a function.
However, you can't say

    n = sizeof int;

but have to say

    n = sizeof(int);

instead, which is really quite strange.

What I hate explaining is why

    print reverse("vice", "versa");

is versavice, but 

    print reverse("vice");

is still just vice, and not eciv.  That functions overload their return
values by implicit context is many programmers worst nightmare.

Ok, I've rambled enough.  The summary is 

    1) It seems least shocking to call the things people expect to be
       functions "functions", and those they expect to be operators
       "operators".

    2) Just what scalar() is and does is actually a bit strange when
       you get right down to it, and could use some more clue-inducing
       docs, kinda like what I have in the indented bits above.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
"I have never understood why it should be neccessary to become irrational in
 order to prove that you care. Or indeed why it should be neccessary to prove
 it at all."  --Avon (_Blakes 7_, "The Duel")


------------------------------

Date: 28 Mar 1997 18:35:32 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: global my() variable used in foreach() loop loses its value
Message-Id: <5hh31k$4ka@lyra.csx.cam.ac.uk>

Russ Allbery  <rra@stanford.edu> wrote:
>
>(I'm not very clear on why someone would consider this a FAQ -- it's
>actually a fairly subtle point.)

Indeed, I always refer to it as a bug.   It's a piece of false optimisation.
Fortunately, in modern perls you can write

       foreach my $topic (@topics) {

which doesn't suffer from the problem.


Mike Guy


------------------------------

Date: 28 Mar 1997 18:18:08 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: How run Perl locally?
Message-Id: <5hh210$9ep@fridge-nf0.shore.net>

Kjetil Palmquist (kjetilpa@a.sol.no) wrote:

: When the script is placed on the web-server, I understand that the line
: i.e #!/local/perl is included in the script.

No.  This is a Unix "thing."  You MUST read the documentation with your
Perl distribution!  You should also associate .pl extensions with perl.exe
(do this in your file manager).  You *must* have a registry entry which maps
 .pl to perl.exe %s (I think it's %s - check the docs).  You might read the
docs/FAQ about wrapping your Perl scripts in a batch file.

In terms of your webserver question, we can't answer it here.  This is
NOT a webserver newsgroup; you might try comp.infosystems.www.servers.misc.

HTH!

--
Nathan V. Patwardhan
nvp@shore.net



------------------------------

Date: Fri, 28 Mar 1997 19:16:47 GMT
From: jefflv@tir.com (Jeff Vannest)
Subject: Re: How to concat many digits to be one string?
Message-Id: <333c1830.320546601@news.tir.com>

On Fri, 21 Mar 1997 20:08:21 +0700, Joruno Jobana
<b39jrj@nontri.ku.ac.th> wrote:
>Dear,
>	I write program for randomming 8 digits.
>
>#/usr/bin/perl
>srand(time|$$);
>for($i=0;$i<8;$i++) {
>  $ID[$i]=int(rand(10));
>}
>
>	I want to concat all 8 digits to be one string;
>
>e.g.
>The random result is
>$ID[0] = 2	$ID[1] = 4	$ID[2] = 6	$ID[3] = 8
>$ID[4] = 1	$ID[5] = 3	$ID[6] = 5	$ID[7] = 7
>I want this output
>$ST = "24681357"
>
>Sincerely.


Try this:  

#/usr/bin/perl -w
# init vars
my $ST;
my $x=0;
                                  
# (time) is assumed in the srand funct.-- for some reason
# the '|$$ is NOTreturning random numbers.  Test it and see.
srand; 
while ($x<8) {
       $ST .= int(rand(10));
       $x++;
}
print "ST = $ST";




Good Luck,
Jeff
========================================
 Jeff Vannest, Web Technician
 Infotrack Internet Presence Provider
 http://www.infotrack.com
 jefflv@tir.com


------------------------------

Date: Fri, 28 Mar 1997 13:15:21 +0000
From: Eric Poindexter <eric@nettown.com>
To: Jim Reese <jimreese@voicehouse.com>
Subject: Re: In need of a Perl script
Message-Id: <333BC469.5082BC5A@nettown.com>

Jim Reese wrote:
> 
> Please forgive me if this is an inappropriate request in this newsgroup.
> 
> My name is Jim Reese.  I am Sales Manager for a small memory module
> manafacturer.  Memory prices flucuate on a daily basis and we receive a
> lot of calls every day from customers regarding the current prices.
> 
> About half of our customer list is available through e-mail.  I can save
> a lot of man-hours just by being able to e-mail our price lists late each
> afternoon after tomorrow's prices are determined.
> 
> My employer does not have access to the internet.  I, personally, have a
> dial-up Unix shell account with a local provider who operates basically
> as a hobby.  When I inquired as to how I might accomplish what I wanted
> to do the response was something like "you need someone to write you a
> perl script".  To say there was no interest in giving me any further help
> would qualify as an understatement.
> 
> I would like to be able to upload a plain ASCII price list to my home
> directory and send it out to the several hundred clients with e-mail
> addresses.
> 
> If anyone is interested in helping me, please contact me by e-mail at
> jimreese@voicehouse.com
> 
> I do not frequent this newsgroup and will not see any replies posted here.
> 
> I thank you in advance for any help you can provide.
> 
> Jim Reese

> Sarasota, FL

[posted and emailed.]

IMPORTANT! you must find out from your ISP if they have the "sendmail"
program running (type "sendmail" on the command line). If not then find
out the mail host name and the port. These should be "mailhost" and
"25". And any other mail related info. [Please just mail me this
information.]

If you have send mail you can adapt what's below, or keep checking
http://nettown.com/perl/eg/dev.bulkmail.pl
it will change to 
http://nettown.com/perl/eg/bulkmail.pl when done.

A module for port type mailings will be on-line soon (today)
http://nettown.com/perl/site_perl/alans_EMailSend.pm

End of main message.

#!/usr/bin/perl
# this is http://nettown.com/perl/site_perl/alans_EMailSend.pl
# by a poindexter
# from mark "the mayor of www.nettown.com" abrams.
# c. fall 96, 97

#------addresses----------------
$to 'eric@nettown.com';
$nickname = 'phantom';
$replyto = 'A@nettown.com';

#------body------------------
$head =<<HEAD;
                       from the Virtual Desk of A
==============================================================================
HEAD

$subject =<<SUBJECT;
my email addr
SUBJECT

$body =<<'BODY';
well now u have my email addr, and it is working, just got it workin on 
tues this week

c ya
BODY

$tail =<<TAIL;
==============================================================================
  -  -                      A\@nettown.com
   -                     http://NetTown.com/A
  ---                       
==============================================================================
                         -Have 1 Great Day!-
TAIL

# ----send-----
$mailprog = "/usr/bin/sendmail $to";
open MAIL,"|$mailprog" or die "Can't open $mailprog: $!\n";

print MAIL <<MSG;
From: $nickname
Reply-to: $replyto ($nickname)
Subject: $subject
$head
$body
$tail
MSG
close MAIL;

#------report to user----------------
print <<USERMSG;
$subject mailed to...$to.
USERMSG

#--a,a,a,a

End of script.

--
Eric
<mailto:eric@nettown.com>
[http://nettown.com/perl/]
have a good day!


------------------------------

Date: Fri, 28 Mar 1997 19:28:03 GMT
From: ficken@mobot.org (Keven D. Ficken)
Subject: Need Help Troubleshooting Script
Message-Id: <5hh6f1$5ih$1@newsin-1.starnet.net>

I need help with the following script. I can not figure out what is
wrong with it. It seems to work fine from the command line, but  when
I try to submit the form to which it is tied using a web browser, I
get a "Document contains no Data" error. Can someone please help me? 

#!/opt/gnu/bin/perl
require "cgi-lib.pl";
&ReadParse;  		#Read in Variables from Forms

@TIME = split(  "\0", $in{'time'} );			#These
@TAXA = split(  "\0", $in{'taxa'} );			#Are
@GEOGRAPHY = split(  "\0", $in{'geography'} );		#Arrays

#Now let's count This Submission

open(COUNTER, "+< /home/WWW/ical/collections/counter.submit");
flock (COUNTER, 2);
$COUNT= <COUNTER>;      #Read the Current Value
$COUNT++;               #Increment Count
seek(COUNTER, 0 , 0);   #Rewind the file
print COUNTER $COUNT;   #Write the Incremented COUNT to file
flock (COUNTER, 8);
close COUNTER;

#Now let's Notify People That Someone Has Made An Addition

open (MAIL, "| /usr/lib/sendmail -oi -t" );
print MAIL <<NOTIFY;
To: ficken\@mobot.org
From:ICALposting\n

	This is a message from ICAL-Botany.
        $in{'name'} has made ICAL Submission #$COUNT for an
$in{'type'} collection.
	You can view detailed information on the new collection at:

http://www.mobot.org/ical/collections/$in{'title'}$in{'type'}$COUNT.html

	This collection covers:
	Time Periods: @TIME
	Taxa: @TAXA
	Geography: @GEOGRAPHY

	Hope you find it interesting!
NOTIFY
close MAIL;

#Let's Put some of this data in a file

open (DATAFILE, ">>
/home/WWW/ical/collections/$in{'title'}$in{'type'}$COUNT.html");
flock (DATAFILE, 2);
print DATAFILE <<LIST_TOP;
	<html>
	<head><title>ICAL Submission #$COUNT, $in{'title'}</title></head>
	<body text=#12123F link=#cc6633 vlink=#12123F 
		background="http://www.ucmp.berkeley.edu/ICAL/orphback2.gif"> 
	<h2>Submission #$COUNT, $in{'title'}, is for an $in{'type'} collection
and
		comes from $in{'name'}</h2> 
	<hr size=3 width=70%>
	<center><font size="+2"><b>Contact Information:</b></font>
	<hr size=3 width=94%>
	<table width=60% border=0>
	<tr><td valign=top align=right>Name:</td>
	<td valign=top><b>$in{'name'}</b></td></tr>
	<tr><td valign=top align=right>Institution:</td>
	<td valign=top><b>$in{'institution'}</b></td></tr>
	<tr><td nowrap valign=top align=right>Postal Address:</td>
	<td valign=top><b>$in{'address'}</b></td></tr>
	<tr><td nowrap valign=top align=right>Phone Number:</td>
	<td valign=top><b>$in{'phone'}</b></td></tr>
	<tr><td nowrap valign=top align=right>Facsimile Number:</td>
	<td valign=top><b>$in{'fax'}</b></td></tr>
	<tr><td nowrap valign=top align=right>Email Address:</td>
	<td valign=top><b><a
href=mailto:$in{'email'}>$in{'email'}</a></b></td></tr>
	</table>
	<br>
	<hr size=3 width=70%>
	<table width=94% border=3>
	<tr colspan=3><font size="+2"><b>General Collection
        	Attributes:</b></font></tr>
	<tr><td align=center><b>Geologic Age:</b></td>
	<td align=center><b>Taxonomic Coverage:</b></td>
	<td align=center><b>Geographic Range:</b></td></tr>
LIST_TOP

print DATAFILE "<tr><td valign=top>";
foreach $TIME (@TIME) { print DATAFILE "<li>$TIME \n"; }
print DATAFILE "</td>";

print DATAFILE "<td valign=top>";
foreach $TAXA (@TAXA) { print DATAFILE "<li>$TAXA \n"; }
print DATAFILE "</td>";

print DATAFILE "<td valign=top>";
foreach $GEOGRAPHY (@GEOGRAPHY) { print DATAFILE "<li>$GEOGRAPHY \n";
}
print DATAFILE "</td></tr>";

print DATAFILE <<LIST_BOTTOM;
       </table><P>
        <hr width=70% size=3>
        <font size="+2"><B>Specific Collection Attributes</b></font>
        <hr width=94% size=3>
        <table width=94% border=0>

        <tr><td align=right valign=top><b>Collector(s):</b></td>
        <td>$in{'collector'}</td></tr>

        <tr><td align=right valign=top><b>Date(s) Collected:</b></td>
        <td>$in{'date'}</td></tr>

        <tr><td nowrap align=right valign=top><b>Samples in
Collection:</b></td>
        <td>$in{'samples'}</td></tr>

        <tr><td nowrap align=right valign=top><b>Volume of
Collection:</b></td>
        <td>$in{'volume'}</td></tr>

        <tr><td nowrap align=right valign=top><b>Curatorial
Status:</b></td>
        <td>$in{'curatorial'}</td></tr>

        <tr><td nowrap align=right valign=top><b>Geologic
Formations:</b></td>
        <td>$in{'geolspecific'}</td></tr>

        <tr><td align=right valign=top><b>Specific Taxa:</b><br></td>
        <td>$in{'taxaspecific'}</td></tr>

        <tr><td nowrap align=right valign=top><b>Specific
Localities:</b></td>
        <td>$in{'geogspecific'}</td></tr>

        <tr><td align=right valign=top><b>Other Notes:</b></td>
        <td>$in{'notes'}</td></tr>

        </table>
        </center><P>

	<hr width=70% size=3>
	<center><a href="http://www.ucmp.berkeley.edu/ICAL/"><== Orphan
Home</a></center><br>

        <A HREF=http://www.ucmp.berkeley.edu/ICAL/auICAL.html>
        <IMG align=right
SRC=http://www.ucmp.berkeley.edu/images/authors.gif
        WIDTH=68 HEIGHT=21></A>
        <A HREF=http://www.ucmp.berkeley.edu/copyright.html>
        <IMG align=right
SRC=http://www.ucmp.berkeley.edu/images/copyright.gif
        WIDTH=21 HEIGHT=21></A>
        </body></html>
LIST_BOTTOM
flock (DATAFILE, 8);
close DATAFILE;

#Okay, now let's print out a nice web page for the person who
#just sent in some information on an available list



print "Content-type: text/html\n\n";

print <<TOP;
<html>
<head>
<title>Thank You for submitting $in{'title'} to ICAL</title></head>
<body text=#12123F link=#cc6633 vlink=#12123F
        background="http://www.ucmp.berkeley.edu/ICAL/orphback2.gif">
<center>
<font size="+2"><b>Thank You for Making Submission 
	Number $COUNT, $in{'title'}, an $in{'type'} collection 
	to<br>ICAL -- Paleontology</b></font>

<hr size=3 width=70%>
<font size="+2"><b>Your Contact Information:</b></font>
<hr size=3 width=94%>

<table width=60% border=0>

<tr><td valign=top align=right>Name:</td>
<td valign=top><b>$in{'name'}</b></td></tr>

<tr><td valign=top align=right>Institution:</td>
<td valign=top><b>$in{'institution'}</b></td></tr>

<tr><td nowrap valign=top align=right>Postal Address:</td>
<td valign=top><b>$in{'address'}</b></td></tr>

<tr><td nowrap valign=top align=right>Phone Number:</td>
<td valign=top><b>$in{'phone'}</b></td></tr>

<tr><td nowrap valign=top align=right>Facsimile Number:</td>
<td valign=top><b>$in{'fax'}</b></td></tr>

<tr><td nowrap valign=top align=right>Email Address:</td>
<td valign=top><b>$in{'email'}</b></td></tr>

</table>
<br>
<hr size=3 width=70%>

<table width=94% border=3>
<tr colspan=3><font size="+2"><b>General Collection 
	Attributes:</b></font></tr>
<tr><td align=center><b>Geologic Age:</b></td>
<td align=center><b>Taxonomic Coverage:</b></td>
<td align=center><b>Geographic Range:</b></td></tr>

TOP

print "<tr><td valign=top>";
foreach $TIME (@TIME) { print "<li>$TIME \n"; }
print "</td>";

print "<td valign=top>";
foreach $TAXA (@TAXA) { print "<li>$TAXA \n"; }
print "</td>";

print "<td valign=top>"; 
foreach $GEOGRAPHY (@GEOGRAPHY) { print "<li>$GEOGRAPHY \n"; }
print "</td></tr>";

print <<FOOTER;

</table><P>
<hr width=70% size=3>
<font size="+2"><B>Specific Collection Attributes</b></font>
<hr width=94% size=3>
<table width=94% border=0>

<tr><td align=right valign=top><b>Collector(s):</b></td>
<td>$in{'collector'}</td></tr>

<tr><td align=right valign=top><b>Date(s) Collected:</b></td>
<td>$in{'date'}</td></tr>

<tr><td align=right valign=top><b>Samples in Collection:</b></td>
<td>$in{'samples'}</td></tr>

<tr><td align=right valign=top><b>Volume of Collection:</b></td>
<td>$in{'volume'}</td></tr>
 
<tr><td align=right valign=top><b>Curatorial Status:</b></td>
<td>$in{'curatorial'}</td></tr>
 
<tr><td align=right valign=top><b>Geologic Formations:</b></td>
<td>$in{'geolspecific'}</td></tr>

<tr><td align=right valign=top><b>Specific Taxa:</b><br></td>
<td>$in{'taxaspecific'}</td></tr>

<tr><td align=right valign=top><b>Specific Localities:</b></td>
<td>$in{'geogspecific'}</td></tr>

<tr><td align=right valign=top><b>Other Notes:</b></td>
<td>$in{'notes'}</td></tr>

</table>
</center><P>

<hr width=70% size=5>
<center><a href="http://www.ucmp.berkeley.edu/ICAL/"><== Orphan
Home</a></center><br>

<A HREF=http://www.ucmp.berkeley.edu/ICAL/auICAL.html>
<IMG align=right SRC=http://www.ucmp.berkeley.edu/images/authors.gif  
WIDTH=68 HEIGHT=21></A>
<A HREF=http://www.ucmp.berkeley.edu/copyright.html>
<IMG align=right SRC=http://www.ucmp.berkeley.edu/images/copyright.gif

WIDTH=21 HEIGHT=21></A>
</body></html>
FOOTER

exit;





------------------------------

Date: 28 Mar 1997 19:40:34 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Opening file for reading and writing simultaneously under perl?
Message-Id: <5hh6ri$bc1$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    markus@gsmag.com writes:
:AFAIK the open() function under perl only permits me to read XOR write
:to a file. 

That's not what the documentation says.  See the description
of the open function in the perlfunc man page.

:My question is whether there is a possibility to open a
:file for readwrite simultaneously.

While I'm on the subject, it appears you didn't check
the FAQ at http://www.perl.com/perl/faq/index.html, which 
contains this:

  How come when I open the file read-write it wipes it out?

    Because you're using something like this, which truncates the
    file and *then* gives you read-write access:

	open(FH, "+> /path/name");  # WRONG

    Whoops. You should instead use this, which will fail if the file
    doesn't exist.

	open(FH, "+< /path/name");  # open for update

    If this is an issue, try:

	sysopen(FH, "/path/name", O_RDWR|O_CREAT, 0644);

    Error checking is left as an exercise for the reader.


--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
Lazy people never bother to actually read the manual.  Instead they (like
kids) pick something with big, colorful buttons.
	-- Eugene Tyurin <gene@insti.physics.sunysb.edu> 


------------------------------

Date: 28 Mar 1997 18:20:55 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Perl hourly fees?
Message-Id: <5hh267$9ep@fridge-nf0.shore.net>

Patrick Poon (poon@sgi.com) wrote:

: I was just wondering...what's the going rate for a Perl programmer
: nowadays?  

It depends on the project, the person's experience, how much time they
think the project will take (per your spec), and how much they are aware
of their worth.  Count on paying in the hundreds per hour for large-scale
projects completed by an experienced, contracted programmer.

--
Nathan V. Patwardhan
nvp@shore.net



------------------------------

Date: 28 Mar 1997 20:37:36 GMT
From: mattera@ssga.ssb.com (Luigi Mattera)
Subject: Perl Mail Parser Question
Message-Id: <5hha6g$p1a@svna0001.clipper.ssb.com>

  I've been trying write a mail parser for Perl on a unix system.  It
simply has to filter out the subject and body of the message.  I can
get the subject using a simple /Subject: / search.  I can possibly
catch the body for a single message, but how to do it over multiple
messages has me stumped beyond belief.

  Programming Perl only uses a while(<>) to loop through a
filehandle.  I can feed through it manually with $var = <NAME>, but I
can not differentiate the end of the message.

  Anyone know how to do this easily?  I've read through the modules,
and I can't find anything simple enough for what I need.


------------------------------

Date: Fri, 28 Mar 1997 10:00:35 -0800
From: crusso@alink.net (Chris Russo)
Subject: Re: Perl mishandles some multidimensional array references???
Message-Id: <crusso-2803971000350001@buzz.alink.net>

In article <333b60e6.83659863@news.airmail.net>, pduff@airmail.net
(Patrick Duff) wrote:

>I am really having trouble with multidimensional arrays and hashes.  I
>understand them, I use them a lot!
[...]
>message.  I could give you more examples using curly braces in various
>ways to try to get Perl to properly parse various references to
>@Title, but none of the obvious ones work.

A rather subjective viewpoint :) .  You should probably sit down and
reread the relevant man pages & Schwartz articles dealing with references.

It seems that the difficulty you're having is with determining the way
that the various expressions bind.

Here's a version of your program with "obvious" braces that seems to do
the trick for me.

@{$Title[0]} = ('A1','A2','A3','A4');
@{$Title[1]} = ('B1','B2','B3','B4');

for $Y (0 .. $#{$Title[$X]}) {
   for $X (0 .. $#Title) {
      print("  $Title[$X][$Y]");
   }
}
print("\n");


Maybe you should try to be more explicit in your coding to avoid
confusion.  Instead of:

@{$Title[0]} = ('A1','A2','A3','A4');

Write

$Title[0] = ['A1','A2','A3','A4'];

That way, you can keep in mind that the value of $Title[0] is really just
a reference to an array, not an actual array.

Regards,

Chris Russo

----------------------------------------------------------------------
Chris Russo                          A-Link Network Services, Inc.
crusso@alink.net                     Bolo me
http://www.alink.net/~crusso


------------------------------

Date: Fri, 28 Mar 1997 13:45:38 +0000
From: Eric Poindexter <eric@nettown.com>
To: r27975@email.sps.mot.com
Subject: Re: Q: sorting by date
Message-Id: <333BCB82.7F7B93D0@nettown.com>

Brad Bosley wrote:
> 
> I have an associative array with the date (mm/dd/yy) as the keys.
> When I do a sort(keys(%ARRAY)), it will of course sort by
> month/day/year.  What I really need is year/month/day.  I was looking
> for a slick way to do this sort, without having build a 2nd array keyed
> with (yy/mm/dd).
> 
> Any Suggestions?
> 
> Thanks,
> Brad Bosley
> Motorola SPS


Use the subroutine option of sort.
See "sort" in http://nettown.com/perl/src/pod/perlfunc.html
e.g.

#!/usr/bin/perl

$dates{'01/23/45'}=1;
$dates{'5/02/46'}=1;
$dates{'4/14/43'}=1;
$dates{'11/21/12'}=1;
$dates{'1/23/45'}=1;
$dates{'1/2/45'}=1;
$dates{'1/11/45'}=1;
$dates{'01/23/99'}=1;

for $k (sort dateSort keys %dates) {
  print "$k\n";
}

sub dateSort {
  my ($aMM, $aDD, $aYY) = split m!/!, $a;
  my ($bMM, $bDD, $bYY) = split m!/!, $b;

  $y = $aYY <=> $bYY;
  return $y if $y; 

  $m =  $aMM <=> $bMM;
  return $m if $m;

  return $aDD <=> $bDD;
}

program output...

11/21/12
4/14/43
1/2/45
1/11/45
1/23/45
01/23/45
5/02/46
01/23/99  

--
Eric
<mailto:eric@nettown.com>
[http://nettown.com/perl/]
have a good day!


------------------------------

Date: Fri, 28 Mar 1997 12:15:54 -0600
From: Ray McVay <rmcvay@acm.org>
Subject: Re: s/// fails because of embedded ()'s
Message-Id: <333C0ADA.3F18@acm.org>

Robert Goff wrote:

> It turns out that $LINK{$url} contained embedded parens.  When I escaped
> the parens, the substitution succeeded.  I haven't seen anything in the
> man pages or the Camel book to explain this - can someone tell me why,
> and what else I have to escape?
> 
> Is it because the parens are grouping operators?  Will I also have to
> escape []?

That bit of the sub is taken to be an RE so you need to escape
everything that is meaningful in that context.


------------------------------

Date: Fri, 28 Mar 1997 13:57:08 +0000
From: "Eric L. Green" <exec@softdisk.com>
Subject: Re: Unix and ease of use  (WAS: Who makes more ...)
Message-Id: <333BCE34.939E5E8@softdisk.com>

Chen Ofek wrote:
> Stephane Plattner wrote:
> > IMHO this answer contradicts to the basics of economics. Openess means
> > to a great extent equality and equality prohibits competition.
> > (communism). Competition rises only when differences exists and it's
> > the market (or the environment), who dictates which product is better.

> Wrong!!!
> Openess means more competition.

I have to agree with Chen here. There is ONE vendor of Windows 95
compatible systems (i.e., NO competition). There are currently at least
FIVE vendors of Linux distributions, all competing based on different
criterion (e.g. Caldera says they're a "standardized commercial
distribution with support", Red Hat trumpets their package management
system and excellent response to security alerts, Debian trumpets  how
many volunteers they have  maintaining their packages and their ability
to swiftly keep up with changing Linux software, ...). 

-- 
Eric Lee Green   exec@softdisk.com          Executive Consultants
Systems Specialist                    Educational Administration
Solutions


------------------------------

Date: Fri, 28 Mar 1997 19:28:24 GMT
From: jefflv@tir.com (Jeff Vannest)
Subject: Re: Vanishing string terminators and premature end of script headers
Message-Id: <333d1b2b.321309714@news.tir.com>

On Fri, 21 Mar 1997 15:07:02 -0800, Matt Riggsby <mriggsby@sybex.com>
wrote:
>Well, I'm fresh out of ideas on this one.  I have a perl script that is
>supposed to generate an HTML page.  But, of course, it doesn't. 
>Checking my error logs, I see two error messages. First:
>
>Can't find string terminator "NXRheader" anywhere before EOF at
>(arglebargle including line number).
>


There is either a space or binary character after the terminating
'NXRheader'.

Do this: Erase the terminating 'NXRheader' and hit delete up onto the
previous line.  Hit return.  type NXRheader and hit return.

This way, you're sure the terminating string terminator reads:

*NXRheader*

NOT

*NXRheader *       # contains a trailing space

OR

*NXRheader	*    #contains a trailing tab.



Good Luck,

Jeff
========================================
 Jeff Vannest, Web Technician
 Infotrack Internet Presence Provider
 http://www.infotrack.com
 jefflv@tir.com


------------------------------

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 198
*************************************

home help back first fref pref prev next nref lref last post