[8331] in Perl-Users-Digest
Perl-Users Digest, Issue: 1948 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 21 23:07:27 1998
Date: Sat, 21 Feb 98 20: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 Sat, 21 Feb 1998 Volume: 8 Number: 1948
Today's topics:
Re: 5.004 bug? invisible object dereferencing <rvermillion@cyberdialogue.com>
[Fwd: A Few Questions about Form Handling] <ldn123NOSPAM@pobox.com>
Re: An easy question or two (Laurel Shimer)
Re: Bug using pod2html with --podroot switch (Jonathan Stowe)
Re: Can I write sockets apps with Perl + Win 95? <jason.holland@dial.pipex.com>
Re: Collon-seperated files? <jason.holland@dial.pipex.com>
Database Recommendation Anyone? <neiled@enteract.com>
Re: do I need file locking? <jwaustin@sympatico.ca>
Help please: Conversion problems from numeric to ascii <brent@sympatico.ca>
Home Page Click. <raymond@sj.bigger.net>
Re: IIS3 : Problem with system command DIR in cgi-scrip (Jonathan Stowe)
Re: My first perl program, yippee! (Jonathan Stowe)
Re: My first perl program, yippee! (Plastic Nuclear Ferret)
Re: Newbie question: Displaying contents from a file. (Laurel Shimer)
SEND E-MAIL , HELP! <techsoft@abcpages.com>
Sorting dbm files (and hashes) (Laurel Shimer)
Re: Using HTML Tags in forms (Content Type) (Laurel Shimer)
Re: Year 2000 Compliance: Lawyers, Liars, and Perl <clfranck@worldnet.att.net>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 21 Feb 1998 15:33:23 -0500
From: "Richard Vermillion" <rvermillion@cyberdialogue.com>
Subject: Re: 5.004 bug? invisible object dereferencing
Message-Id: <6cndai$cuv$1@news.mxol.com>
Zenin wrote in message <888050309.513030@thrush.omix.com>...
> I think the perlguts page needs more concise information about the
> exact stucture and layout of the data types. I got almost nothing
> useful out of it as far as type stucture is concerned, and diving
> into the source didn't help too much as it's littered for days with
> macros that hide much of the deep internals. Not that they are bad,
> I'm sure they make working on the perl source much easier, but they
> sure don't help understanding it IMH0. -Which is why I'd like to
> see more info in the guts page. Devel::Peek looks like a good tool
You should check out Gisle Aas's "PerlGuts Illustrated" page at
http://home.sol.no/~aas/perl/guts/ which has just the kind of explanation
you're asking for. It's still under construction but I've found it
incredibly useful so far (both for confirming what I thought I knew from
looking at the source code and for clearing up things I had misunderstood).
It's at version 0.04 now but I check back regularly to see if it's been
updated because he's almost finished with all of the SV types and hopefully
will start getting into things I KNOW I don't understand the guts of: OPs,
REGEXP, etc.
-rv
Richard Vermillion rvermillion@cyberdialogue.com
Cyber Dialogue Inc. http://www.cyberdialogue.com/
------------------------------
Date: Sat, 21 Feb 1998 13:25:43 -0500
From: Lee Nelson <ldn123NOSPAM@pobox.com>
Subject: [Fwd: A Few Questions about Form Handling]
Message-Id: <34EF1C26.3F96D7AC@pobox.com>
This is a multi-part message in MIME format.
--------------61E0D6EF59A0076E24104F5E
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Oops. Sent this via email instead of posting to group. Still getting
the
hang of using netscape for news :-).
--------------61E0D6EF59A0076E24104F5E
Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-ID: <34EE65F7.AA3E5A98@pobox.com>
Date: Sat, 21 Feb 1998 00:28:23 -0500
From: Remove NOSPAM to reply <ldn123NOSPAM@pobox.com>
Organization: Sunspot Design
X-Mailer: Mozilla 4.04 [en] (WinNT; I)
MIME-Version: 1.0
To: Katy Jackson <katyjack@mindspring.com>
Subject: Re: A Few Questions about Form Handling
References: <34eef69c.11331179@news>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I'm a Perl beginner, but I'm going to take a stab at this one...
I think that the fields arrive in order in the input stream. If
that is the case, then you can simply build your output string
while you are parsing the input initially, as shown in the
modified routine below. Note that $output is initialized.
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
my $output = "";
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/~!/ ~!/g;
$FORM{$name} = $value;
$output .= "$key = $value\n";
}
If you really want to preserve the order inside the hash, then
you might try some really ugly hack like prepending the
value number to the actual value. This won't order the
values in the hash, but it will make it possible to recover
the order later. This will be slower and uglier than
the solution above for short scripts.
As for your second question, the code you want is:
$recipient = firstemail@server.com . " , " . secemail@server.com;
I tested this format manually using sendmail, and it send to both
locations.
Hope this helps,
Lee Nelson
--------------61E0D6EF59A0076E24104F5E--
------------------------------
Date: 21 Feb 1998 20:59:59 GMT
From: autopen@autopen.com (Laurel Shimer)
Subject: Re: An easy question or two
Message-Id: <autopen-2102981301040001@dynamic7.pm04.mv.best.com>
As far as Perl is concerned it is just outputing text. So it doesn't
interact with the browser in any special way other than to send data
(text) to it.
If the browser sends information back,(via a SUBMIT button for example)
then Perl can react to information sent and output some more text - which
hopefully the browser can interact with logically to product more output
text.
I think you want to use JavaScript. It can interact with what is currently
displayed on your browser page.
Laurel
> Sorry for the newbie questions; I'm still learning all the intricacies
> of Perl.
>
> 1) Is there any way for Perl to modify an already existing form that is
> being displayed on a web browser? (without rewriting the whole page)
> ie. a form field says "John" and you want Perl to change it to "Jane"
> without just a complete rewrite of the file.
>
> 2) Is there any way for Perl to pass variables to Javascript? On the
> same token, how does Perl set or change cookies?
>
> Thanx for all the help in advance
> Amy
--
The Reader's Corner: Mystery, Romance, Fantasy
http://www.autopen.com/index.shtml
Subscribe to our free StoryBytes publication
Did you miss? The Pigeon, A St.John Bathshirker Mystery
http://www.autopen.com/pigeon.shtml
------------------------------
Date: Sat, 21 Feb 1998 00:33:15 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Bug using pod2html with --podroot switch
Message-Id: <34ede3e3.151167276@news.btinternet.com>
On Wed, 18 Feb 1998 21:51:07 -0500, the newsreader of "Alfred P.
Bartholomai" <apb.freddyb@mailexcite.com> wrote:
>This is a multi-part message in MIME format.
>--------------5D13D79790D157967D131634
>Content-Type: text/plain; charset=us-ascii
>Content-Transfer-Encoding: 7bit
>
>Please see attached file
>
>--------------5D13D79790D157967D131634
>Content-Type: text/plain; charset=us-ascii; name="BUG_2_18.98"
>Content-Transfer-Encoding: 7bit
>Content-Disposition: inline; filename="BUG_2_18.98"
>
>Subject: Bug using pod2html with --podroot switch
>
Please, please,please do not do use MIME in newsgroup postings. I am
certainly not alone in having a reader which cannot deal with it.
On the whole you will find that most people will ignore MIME postings.
>I am running : perl, version 5.004_04 built for sun4-solaris
>
>I am using the pod2html utility to create html pages for all the available
>perl man pages so that I can use them with my web browser to take
>advantage of the cross-reference links that pod2html supposedly can give me.
>
<snip>
You migh take a look at the installhtml script that should be in the
directory in which you built perl or the Makefile.
/J\
------------------------------
Date: Sat, 21 Feb 1998 17:24:18 +0000
From: Jason Holland <jason.holland@dial.pipex.com>
To: chris@surewould.com
Subject: Re: Can I write sockets apps with Perl + Win 95?
Message-Id: <34EF0DC2.32B4B8E@dial.pipex.com>
Chris wrote:
>
> About 4 years ago (pre-Win95) I got into writing Winsock apps. That was
> about the same time I first used Perl, and remember hoping that it would
> be as easy to write sockets code with Perl under Windows 3.1 as under
> Unix. But of course it wasn't.
>
> It's much later now, and I'd like to revisit this concept. I'm doing
> some sockets stuff now under Win95 and it's all in Java, which (although
> much better than C/C++) is becoming cumbersome. Can today's Perl tackle
> this?
>
> Thanks,
> Chris
Yes, you can use sockets under Win95, or at least I have done. I
recently wrote a small custom server that could run on Mac, Win95 and
Linux without modification. The server used only TCP/IP sockets.
However, you will need to bear in mind when writing a server application
that it may not be possible to handle multiple simultaneous connections.
When writing my own application I used the fork() function under Linux
to spawn off a new server for each connection, however this facility
could not be used under MacOS or Win95. I don't know if or when it may
be included.
--
jason.holland@dial.pipex.com
Jay's Place is at
http://dspace.dial.pipex.com/jason.holland/
------------------------------
Date: Sat, 21 Feb 1998 17:12:04 +0000
From: Jason Holland <jason.holland@dial.pipex.com>
To: "(Al)Fred Heller" <ajh@ibe.dtu.dk>
Subject: Re: Collon-seperated files?
Message-Id: <34EF0AE4.607F373E@dial.pipex.com>
(Al)Fred Heller wrote:
>
> Hej...
> How can I seperate collonseperated files (or semi-collon ...)?
>
> Fred
> ajh@ibe.dtu.dk
What exactly do you mean? Can you extrapolate?
Do you mean something like this...
while( $data = <STDIN> ) {
@array = split( ":", $data );
}
This will read each line from standard input and split each line into an
array.
--
jason.holland@dial.pipex.com
Jay's Place is at
http://dspace.dial.pipex.com/jason.holland/
------------------------------
Date: Sat, 21 Feb 1998 14:16:24 -0000
From: "Neil Edmondson" <neiled@enteract.com>
Subject: Database Recommendation Anyone?
Message-Id: <6cnd10$dp0@eve.enteract.com>
I develop perl scripts for my web site on Windows95, and use OmniHttp as a
web server. When I'm happy with the stuff I upload to my UNIX ISP -
retest - and turn on. This works really well. I can do 90% of my
development on airplanes, etc.
Up 'til now I have survived without using a database. However, I now have a
flat file of about 3000 records that really ought to be turned into a
database. Being cheap, I would like to use DB_File.
Is there such a thing as a precompiled, install ready version of DB_File for
Win95? Where can I get it? Or are there any other suggestions as to how I
can continue to develop "off-line" with a(ny) database other than to install
UNIX on my laptop?
TIA, Neil Edmondson
neiled@enteract.com
------------------------------
Date: Sat, 21 Feb 1998 13:07:46 -0500
From: John W Austin <jwaustin@sympatico.ca>
To: Tom <boson@earthlink.net>
Subject: Re: do I need file locking?
Message-Id: <34EF17F2.29B4@sympatico.ca>
Tom wrote:
> open FILE
> [ do stuff here]
> close FILE
>
> [some code inbetween]
>
> open FILE
> [ do more stuff here]
> close FILE
>
> This program will never be used more than once at the same time. Will
> the program proceed to the second open FILE statement before the first
> one is finished, and file locking is needed?
The simple answer, to the example you quote, is no. Your program
executes one statement at a time.
Following well-established precedent I have to add ...
BUT
If more than one copy of the program is ever started, or if another
program can possibly update the file while yours is running, you WILL
NEED file locking.
------------------------------
Date: Sat, 21 Feb 1998 13:10:55 -0500
From: Brent <brent@sympatico.ca>
Subject: Help please: Conversion problems from numeric to ascii
Message-Id: <34EF18AF.33AE@sympatico.ca>
Hi there
I'm trying to convert a number to a letter based upon the ascii
table (e.g. 65=A, 97=a) The reason for this is that I'm randomly
generating user id's for account creation. I'm currently using a Novell
Web Server and their Perl server however after coding I must port it
over to a UNIX server. Does anyone know the syntax I can use to perform
these two tasks?
I have tried using the $userid[$i]=chr($randomnum) within a loop
however from extensive testing, the chr() function doesn't seem to be
returning anything. I tested this by performing a dump of the variable
contents prior and after conversion attempt.
Any and all help is appreciated gratefully.
Regards,
Brent
brent@sympatico.ca
--
Brent G. Mondoux
brent@sympatico.ca
http://www3.sympatico.ca/brent
------------------------------
Date: Sat, 21 Feb 1998 10:34:26 -0800
From: Ray <raymond@sj.bigger.net>
Subject: Home Page Click.
Message-Id: <34EF1E31.234AC19D@sj.bigger.net>
Does anyone know how to add an element to a page so that when the user
clicks on it, it becomes their home page?
Thanks.
------------------------------
Date: Sat, 21 Feb 1998 00:33:10 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: IIS3 : Problem with system command DIR in cgi-script
Message-Id: <34ebb116.7485453@news.btinternet.com>
On Mon, 16 Feb 1998 12:45:37 +0100, "Marion Gravel"
<marion.gravel@pcm.bosch.de> wrote:
>Hello
>
<snip gory installation details>
>print "Content-type: text/html\n\n";
>$server_dir="F:\\inetpub\\ibsftp\\tk\\ibs\\infos\\*.*";
>print $server_dir;
>@dateien = `dir $server_dir`;
>print @dateien;
>
>The script works fine, but the array @dateien is empty,
>but the $server_dir isn't empty.
>
>Does anyone know about that problems with system
>commands and can help to solve it ?
>
Firstly I think that "dir" is a command interpreter builtin as it is
in the 16 bit command.com.
you might try
@dateien = `cmd /c dir $server_dir`;
however I would eschew the use of an external command when there is an
internal option - something like this might do the job:
print "Content-type: text/html\n\n";
$server_dir="F:\\inetpub\\ibsftp\\tk\\ibs\\infos\\*.*";
print $server_dir;
opendir(CURDIR, $server_dir) or die "Cant open directory $server_dir:
",$!;
while ( defined($filename = readdir CURDIR))
{
push(@dateien,$filename);
}
#etc ...
closedir(CURDIR);
you probably want to filter the filenames with a regular expression
before pushing them into the array.
/J\
------------------------------
Date: Sat, 21 Feb 1998 00:33:13 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: My first perl program, yippee!
Message-Id: <34ede1f9.150677784@news.btinternet.com>
On Thu, 19 Feb 1998 00:31:00 +0000, Matthew Pryor
<matt.pryor@dial.pipex.com> wrote:
>This is a multi-part message in MIME format.
>--------------063564B175503085F8FE11B7
>Content-Type: text/plain; charset=us-ascii
>Content-Transfer-Encoding: 7bit
>
Wrong.
>Hi all,
>
>I've just finished my first full perl
>script, and would now like to
>show it off, coz I'm proud of my
>little efforts. Its only a very simple
>database search program that displays
>the results in HTML in a table format.
>The table can be defined when
>calling the script using environment
>variables such as pad, spacing,
>colour (sic - this is from England!),
>and border. Its all quite self
>explanatory...
>
>I've tested it quite a bit, but if anyone
>can see any glaring errors which I've
>missed I'd be eternally grateful if they
>can point them out.
~> perl -w search.cgi
Argument "DQo8SEVBRD48VElUTEU" isn't numeric in add at search.cgi line
8.
Argument "KTsNCg0KcHJpbnQgPDxFbmRfT2ZfSGVhZGVyOw0KPEhUTUw" isn't
numeric in add at search.cgi line 8.
Argument "DQo8SDM" isn't numeric in add at search.cgi line 10.
Argument "T05UIEZBQ0U9YXJpYWw" isn't numeric in add at search.cgi line
10.
Argument "WW91ciBTZWFyY2ggUmVzdWx0czwvSDM" isn't numeric in add at
search.cgi line 10.
Argument "JHtwZXJjZW50YWdlfSU8L0I" isn't numeric in add at search.cgi
line 66.
Argument "PEI" isn't numeric in add at search.cgi line 66.
Argument "PC9GT05UPjwvVEQ" isn't numeric in add at search.cgi line 66.
syntax error at search.cgi line 99, at EOF
Execution of search.cgi aborted due to compilation errors.
Or was I supposed to something with it first? ;-}
/J\
without facility to do anything with base64 encoded postings
------------------------------
Date: 21 Feb 1998 20:55:34 GMT
From: donut@bayarea.net (Plastic Nuclear Ferret)
Subject: Re: My first perl program, yippee!
Message-Id: <6cnf06$sgj$2@news.bayarea.net>
Jonathan Stowe (Gellyfish@btinternet.com) wrote:
:
: /J\
: without facility to do anything with base64 encoded postings
ever think of writing a perl script for it? 8^)
later-
shane
--
#############################################################################
# Shane Knapp # donut@bayarea.net # shane@investools.com #
# "I'd like to be Superman, but you're standing on my cape...." #
# http://www.bayarea.net/~donut #
#############################################################################
------------------------------
Date: 21 Feb 1998 20:38:22 GMT
From: autopen@autopen.com (Laurel Shimer)
Subject: Re: Newbie question: Displaying contents from a file.
Message-Id: <autopen-2102981239280001@dynamic7.pm04.mv.best.com>
Hope this is as simple a problem as I think it is. ....
If you simply want to read a line and display it to a web page, perhaps
you want to use your browser daily instead of logging onto your shell
Assuming that your iput file is named "log.file", This should work, though
I have not tested it.
Laurel
------------
#!/usr/local/bin/perl5
print "Content-type: text/html\n\n";
print "<html>";
open (RECENT, "log.file") || print ("Cannot open file: $!<br>\n");
while ($line = <RECENT>){
print "$line <br>";
}
print "</html>";
------------
In article <34EC5BE0.E32A3BC1@mathworks.com>, Craig Ciquera
<craig@mathworks.com> wrote:
> There is some information missing here -- like does the data in form.log
> look like, do you want to produce an html page or simply view the file in a
> web browser, etc...
>
> I would defer answering this question until you look at the following site:
>
> http://www-genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html
>
> It has some great information which I think you would find useful.
>
> Craig
>
> cia1@ix.netcom.com wrote:
>
> > I've got a Perl script (form.cgi) that takes the
> > form input and writes it to a file (form.log).
> > Can someone explain to this perl newbie
> > how display the contents of that file on a
> > web page?
> >
> > Thanks in advance!!
> > Dave
> >
> > -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> > http://www.dejanews.com/ Now offering spam-free web-based newsreading
>
>
>
> --
> Craig Ciquera Tel: (508) 647-7547
> The Mathworks, Inc. FAX: (508) 647-7002
> 24 Prime Park Way, Natick MA 01760
> mailto:craig@mathworks.com Web: http://www.mathworks.com
--
The Reader's Corner: Mystery, Romance, Fantasy
http://www.autopen.com/index.shtml
Subscribe to our free StoryBytes publication
Did you miss? The Pigeon, A St.John Bathshirker Mystery
http://www.autopen.com/pigeon.shtml
------------------------------
Date: Sat, 21 Feb 1998 13:36:03 -0800
From: Alexander Kovalenko <techsoft@abcpages.com>
Subject: SEND E-MAIL , HELP!
Message-Id: <34EF48C3.D8650857@abcpages.com>
hey , how is it going?
I have a problem with following procedure...
sub send_mail
{
local($addressee, $subject, $message) = @_;
local($sendmail) = "/usr/sbin/sendmail";
open(SENDMAIL, "| $sendmail -t");
print SENDMAIL "To: ", $addressee, "\n";
print SENDMAIL "Subject: ", $subject, "\n\n",
print SENDMAIL "$message\n";
close(SENDMAIL);
}
it sends e-mail , ok... but it does not use a subject , so it just leave
it blank...
what's wrong am I doing ? thanks in advance!
--
With best wishes,
Alex.
------------------
To purchase your own www.yourcompany.com,
please, click here: http://www.philex.net/agents/0053/
The Best Prices on the Net!!!
19.95$ for 250Mb per month
+
many additional options.
------------------------------
Date: 21 Feb 1998 20:28:24 GMT
From: autopen@autopen.com (Laurel Shimer)
Subject: Sorting dbm files (and hashes)
Message-Id: <autopen-2102981229270001@dynamic7.pm04.mv.best.com>
This question has to do with sorting data stored in a dbm file. I have
included all the sample code that I created while trying to figure this
task out.
I have layed out my questions and assumptions ahead of time, and have
marked the questions where they occur following my sample code pieces.
I'm now heading out to answer any newbie questions within my capabilities.
Thank you!
Laurel
THE PROBLEM
-----------
I have a dbm file that I need to sort. Actually I need to selectively
choose rows/instances from that file and then output them in various sort
orders.
I have been trying to figure out the right way to do this by reading about
sort in the Camel book and experimenting. I have gotten rather tangled up
in trying to do this over the last few days, and am wondering if I am even
approaching the problem correctly.
BACKGROUND
----------
I realize that dbm files are not the best way to store this data. As soon
as I deal with this problem, my next project is to figure out how to use
MySQL and convert this data and write new procedures for working with it.
However I need to get the sort problem working now, so that others can use
and add to this information in the short-term.
Besides, I'll be so much smarter once I understand some of these things!
MY ASSUMPTIONS
---------------------
Because I have beeen working with the dbm file like an array, I assume
that to sort output from that file, that I have to either sort that array
or sort a hash that represents the data in that array. And since
individual fields that I need to sort on are contained within one of the
values in that two-dimensional array, I assume that I neeed to do more
than just say 'sort'.
My current plan has been to fill a hash with data from my array and then
sort by whichever field I currently want to sort on.
Assumption 1: I need to fill up a hash from my one dimensional array.
Assumption 2: I need to sort the hash.
QUESTIONS
----------------
1) What am I doing wrong when I attempt to fill my hash from my dbm file array
(marked below as "*QUESTION 1" following my simple sample code and sample runs)
2) Do I have the right take on passing/not passing parameters to the sort
routines correctly, once I manage to fill that hash? (based on samples in
the Camel book)
(marked below as "*QUESTION 2" following my simple sample code and sample runs)
3) Are my assumptions about how to do this task correct? I found a
reference to sorting hashes in the Camel book, but it seems to refer to
another file type that I'm not using.
Or perhaps there is some much simpler use of the sort function which escapes me?
TRIED TO DATE
---------------------
I have been experimenting with a sample file, which has names similar to
those used at various places in the Camel book.
*TRIED TO FILL HASH
1) I created a dbm file similar to the one I really use. It is called
"sort.test". Here is the code that displays the data I put into
"sort.test". This is pretty much the way that I am currently working with
the data in the dbm file I have been using.
----------- This is the sample routine "hash2.cgi" ------------
#!/usr/local/bin/perl5
#SAMPLE ROUTINE hash2.cgi
$mydata="sort.test";
$delim="&";
# Just Print the Array in current order
dbmopen (%mydata, $mydata, 0444) || die "$!\n";
while ( ($key,$val) = each %mydata) {
print "The key is $key, The value is $val\n";
}
dbmclose (%mydata);
#Now Sort the Array, What order is it in?
#Next display age, height and last name
dbmopen (%mydata, $mydata, 0444) || die "$!\n";
while ( ($key,$val) = each %mydata) {
($age,$height,$lastname)=split(/$delim/,$val);
print "$lastname is $age years old and $height feet tall\n";
}
dbmclose (%mydata);
----------- Here is the output from 'hash2.cgi"
shell% perl5 hash2.cgi
The key is 9, The value is 51&13&Manuel
The key is 8, The value is 52&12&Horatio
The key is 7, The value is 53&11&Elmer
The key is 6, The value is 54&10&Varun
The key is 5, The value is 55&9&Ted
The key is 4, The value is 56&8&Jo
The key is 3, The value is 57&7&Teresa
The key is 2, The value is 58&6&Elena
The key is 1, The value is 59&5&Maria
Manuel is 51 years old and 13 feet tall
Horatio is 52 years old and 12 feet tall
Elmer is 53 years old and 11 feet tall
Varun is 54 years old and 10 feet tall
Ted is 55 years old and 9 feet tall
Jo is 56 years old and 8 feet tall
Teresa is 57 years old and 7 feet tall
Elena is 58 years old and 6 feet tall
Maria is 59 years old and 5 feet tall
shell%
-----------
2) Next I attempted to fill a hash with data from this dbm file - Here
begins my dependence on my first assumption about the correct way to do
this task
a) I found a working sample that created an associative array from
hardcoded data. It works.
-----------------
#!/usr/local/bin/perl5
#SAMPLE ROUTINE make.sample.hash.cgi
%emps =(
emp1 => {name => "Jane", sal=>'100'},
emp2 => {name => "Ted", sal => '50'}
);
print "emp 1 data \n";
print "$emps{emp1}{name}\n";
print "$emps{emp1}{sal}\n";
print "emp 2 data \n";
print "$emps{emp2}{name}\n";
print "$emps{emp2}{sal}\n";
-----------
shell% perl5 make.sample.hash.cgi
emp 1 data
Jane
100
emp 2 data
Ted
50
shell%
-----------
* Using similar logic (or so I thought) I attempted to fill up my hash
from my dbm file array
b)I tried to extract data from my dbm file array and stick it into a hash
*QUESTION 1
-------- I cannot figure out how to get the data into a hash from the dbm file
#!/usr/local/bin/perl5
#Sample Routine make.hash.cgi
$mydata="sort.test";
$delim="&";
dbmopen (%mydata, $mydata, 0444) || die "$!\n";
print "First we push it in\n";
while ( ($key,$val) = each %mydata) {
($age,$height,$lastname)=split(/$delim/,$val);
print "$lastname is $age years old and $height feet tall\n";
$NextHashRow=$lastname=>{age => $age, height=>$height};
push %people, $NextHashRow;
}
print "Then we hash it on out \n";
foreach $value (@people) {
print "$value is $people{$value} {age} years old and
$people{$height} inches tall \n";
}
dbmclose (%mydata);
--------
shell% perl5 make.hash.cgi
Type of arg 1 to push must be array (not hash deref) at make.hash.cgi line 14, n
ear "$NextHashRow;"
Execution of make.hash.cgi aborted due to compilation errors.
shell%
................
I see that I have the wrong idea about how to do this, so I try to substitute
#$NextHashRow=$lastname=>{age => $age, height=>$height};
#push %people, $NextHashRow;
%people=($lastname =>{age => $age, height=>$height});
......
However, I simply end up with an empty hash at the end.
????? Obviously I don't know how to do this - and am drawing a blank as to
what to try next????
END OF CODE FOR *QUESTION 1
**************************************************
IDEA ON HOW I SHOULD SORT (based on Camel book, second edition, page 218)
--------------------------------------------------------------------------------
Once I can view data in %people, I THINK I should be able to sort like the
examples shown in the Camel books description of the sort function on page
218 (second version)
* QUESTION 2 Parameter Passing in CAMEL BOOK SORT
----------------------------------------------------
When the Camel book calls the sort routine, it says 'sort byage @class'
and then the subroutine does not pick up any subroutine parameters. I
think this should actually work, based on something I read about $a and $b
further up the page - except that I don't quite understand what it said
about $a and $b and I don't find them listed in the index as special
variables . Do I understand this correctly, or should I be picking up an
array as a paramater, if so, do you do something different when you pickup
a whole array than you do when you pick up a scalar?
........ My code would be something like this .........
dbmopen (%mydata, $mydata, 0444) || die "$!\n";
hashit();
#If I knew I wanted a simple by age report
@sortedpeople = sortbyage @people;
#And If I wanted a more complex by lastname, by age, by height report, I
might be able to do that with the idea further down the page like this
@sortedpeople = sortcomplex @people;
sub hashit {
This would be a working version of 'make.hash.cgi'
Results are placed in array @people (Assume I can return @people like I
return a scalar , though I'm not sure..)
}
sub byage {
$age{$a} <=> $age{$b};
}
sub byheight {
$height{$a} <=> $height{$b};
}
sub bylast{
$lastname{$a} <=> $lastname{$b};
}
sub sortcomplex {
$lastname{$a} <=> $lastname{$b}
or
$age{$a} <=> $age{$b}
or
$height{$a} <=> $height{$b}
}
--
The Reader's Corner: Mystery, Romance, Fantasy
http://www.autopen.com/index.shtml
Subscribe to our free StoryBytes publication
Did you miss? The Pigeon, A St.John Bathshirker Mystery
http://www.autopen.com/pigeon.shtml
------------------------------
Date: 21 Feb 1998 20:53:17 GMT
From: autopen@autopen.com (Laurel Shimer)
Subject: Re: Using HTML Tags in forms (Content Type)
Message-Id: <autopen-2102981254230001@dynamic7.pm04.mv.best.com>
I cannot find the original message from Jesus, but mebbe he means that his
users disply their email as html formatted docky'ments. Can't you set a
preference for that in N'Scape mail? (I'm not sure, as I'm a Eudora fan
myself).
But anyway, I guess this isn't a pure Perl question anyway... Laurel
In article <34ed20de.26063786@news.omen.net.au>, nospam_synic@omen.net.au
(peter caffin) wrote:
> JesusDLG did cunningly address to comp.lang.perl.misc..
> :I need that my users receive an email like a WebPage. Something like a I
> :fill a field named message with some HTML code and my user receive an email
> :in HTML format.
>
> However, your users will hate you for doing it to them.
>
> Email = Text.
> Usenet = text.
> WWW = HTML.
>
> The twain don't meet without heaps of flames [1]
>
> --
> [1] Okay, yes, you _can_ have text on the WWW ;).
>
> --: _ ___ _ _ _
> _oo__ |_|_ |__ _ | | _ |_|_' _ mailto:synic@omen.net.au
> //`'\_ | (/_|(/_| .|. |_(_|| | || | http://www.omen.net.au/~synic
> /
--
The Reader's Corner: Mystery, Romance, Fantasy
http://www.autopen.com/index.shtml
Subscribe to our free StoryBytes publication
Did you miss? The Pigeon, A St.John Bathshirker Mystery
http://www.autopen.com/pigeon.shtml
------------------------------
Date: 21 Feb 1998 19:06:10 GMT
From: Craig Franck <clfranck@worldnet.att.net>
Subject: Re: Year 2000 Compliance: Lawyers, Liars, and Perl
Message-Id: <6cn8j2$jtt@bgtnsc02.worldnet.att.net>
dpbsmith@world.std.com (Daniel P. B. Smith) wrote:
>In article <34EDBD17.16475955@medit3d.com>,
>Colin Dooley <colin@medit3d.com> wrote:
>>Steve Dover wrote:
>>>
>>> Time marches on, but by design, a given date or timestamp datam
>>> will only be allocated so many bits. At some point in time,
>>> more bits will need to be allocated. There's no way around it.
>>
>>In a billion years the Sun will explode and you won't need to
>>worry about it any more. This suggests that a 64 bit time_t
>>ought to be enough...
>
>How can you tell?
It's almost entirely a function of the sun's mass. The sun is a
main sequence star which is about halfway through it's life cycle.
It has about 5 billion more years to go before it starts to change
rather rapidly.
>Sometime between the fifties and the eighties, the continents cut loose
>from their mooring and began to drift.
Must have been all those underground nuclear tests. (Does Al Gore
know about this?)
>And I've lost track of what the Universe does--we've gone through so many
>cycles of it's-continuous-creation, no-it's-a-big-bang,
>no-it-explodes-then-collapses, does to, does not, 'tis to, 'tis not...
>
>No, I wouldn't want to gamble on 64 bits being enough.
The code won't break until after your long gone, so who cares? :-)
--
Craig
clfranck@worldnet.att.net
Manchester, NH
We're drowning in information and starving
for knowledge. -- Rutherford D. Rogers
------------------------------
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 1948
**************************************