[6304] in Perl-Users-Digest
Perl-Users Digest, Issue: 926 Volume: 7
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 11 11:27:28 1997
Date: Tue, 11 Feb 97 08:00:27 -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 Tue, 11 Feb 1997 Volume: 7 Number: 926
Today's topics:
Re: Calling a .html page from perl script <e8726057@student.tuwien.ac.at>
Re: Calling a .html page from perl script (Jonathan Peterson)
Re: Calling a .html page from perl script (Tad McClellan)
Capturing system output bfb@worldnet.att.net
Re: Capturing system output (Nathan V. Patwardhan)
Re: Cookies and Website 1.1 <nmljn@wombat.staff.ichange.com>
Re: File Tests for Directory not working under NT4.0 <merlyn@stonehenge.com>
Re: File Tests for Directory not working under NT4.0 (Kevin Smith)
Re: Get filename from variable-length path? <nmljn@wombat.staff.ichange.com>
Re: Help is anyone any good with sockets (Lack Mr G M)
Re: HELP: Problems with open(),time() <nmljn@wombat.staff.ichange.com>
Re: How can I call a perl CGI from a C cgi ? (Tony Mione)
Re: How to check an environmental variable <jander@jander.com>
Re: Increasing variable names (ie - $line1,$line2, etc) (Lack Mr G M)
Re: Invoking Perl program (Jonathan Peterson)
Join our CGI List FREE! inforch@cris.com
Re: Loops in perl (I R A Aggie)
Re: Loops in perl <ajohnson@gpu.srv.ualberta.ca>
Re: multiple selects <nmljn@wombat.staff.ichange.com>
Re: Need a way to calculate a random number between 1 a (Erik Braun)
Re: on the fly graphs <jander@jander.com>
Re: on the fly graphs (Andrew Henry)
Re: on the fly graphs <mike@soft-tek.com>
Re: Perl rand() function on solaris SPARC (Mr Simon Lee)
Perl5 and DBD-Oracle under Oracle 7.3.2.3 and HP-UX 10. (Yan Lau)
PerlIS problem reading network drive (Kevin Smith)
Re: problem sending mail from perl using cron (Nathan V. Patwardhan)
Re: Question about using "system" command (Tim Goodwin)
Saving complex data structures to disk, how best? ryanmd@mms.sbphrd.com
SORT: trying to sort files on date. AND connecting syst (Dr. Wolfgang Reimann)
suitable typemap <bjtong@cse.unsw.EDU.AU>
Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 11 Feb 1997 11:27:56 +0100
From: Klaus Johannes Rusch <e8726057@student.tuwien.ac.at>
Subject: Re: Calling a .html page from perl script
Message-Id: <330049AC.A88@student.tuwien.ac.at>
Charles Norton wrote:
> The only way I have found so far, is to open the .html file, read it a
> character at a time and print out the characters which results in the
> .html page being displayed.
If the page is static redirect the client to it:
print <<EOF;
Status: 302 Moved temporarily
Location: http://whatever/yourpage.html
EOF
Klaus Johannes Rusch
--
e8726057@student.tuwien.ac.at, KlausRusch@atmedia.net
http://www.atmedia.net/KlausRusch/
------------------------------
Date: 11 Feb 1997 10:47:47 GMT
From: jon@amxdigital.com (Jonathan Peterson)
Subject: Re: Calling a .html page from perl script
Message-Id: <jon-1102971044440001@amx11.amxdigital.com>
In article <lmaYVBAxTDAzEwiX@hnnet.demon.co.uk>, Charles Norton
<Charles@hnnet.demon.co.uk> wrote:
> Can anyone tell me how to call an html page from a perl script used on a
> web page.
>
> I have been told there is a way to use the print command, but I can't
> see how.
>
> The only way I have found so far, is to open the .html file, read it a
> character at a time and print out the characters which results in the
> .html page being displayed.
Two things.
1. What you have read about is the 'Location:' header, which can be used
to redirect a page.
Instead of printing "Content-type: text/html\n\n" just print the line
"Location: http://www.machine.domain.com/pathname\n\n" which will redirect
the browser to said URL (full urls only, not relative ones)
2. How do you read a file a character at a time??? I've only ever read
them a line at a time, which is all I've ever wanted to do, fortunately :)
------------------
Opinions expressed above are not necessarily those of AMXdigital ltd.
Jonathan Peterson || jon@amxdigital.com || (+44) 0171 613 5300
"You wouldn't believe the things I've seen with your eyes."
------------------------------
Date: Tue, 11 Feb 1997 05:52:52 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Calling a .html page from perl script
Message-Id: <kimpd5.qk.ln@localhost>
Jonathan Peterson (jon@amxdigital.com) wrote:
: 2. How do you read a file a character at a time??? I've only ever read
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: them a line at a time, which is all I've ever wanted to do, fortunately :)
getc() (see the perlfunc man page)
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Tue, 11 Feb 1997 13:52:42 GMT
From: bfb@worldnet.att.net
Subject: Capturing system output
Message-Id: <3301790c.3931432@netnews.worldnet.att.net>
How can I capture the output of a system call
to an array?
Something like:
@arry = system('cat myfile');
-Thanks
------------------------------
Date: 11 Feb 1997 14:52:22 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Capturing system output
Message-Id: <5dq136$eit@fridge-nf0.shore.net>
bfb@worldnet.att.net wrote:
: How can I capture the output of a system call
: to an array?
The FAQ definitely answers this question. Get it.
http://www.perl.com/perl, or check the comp.lang.perl.misc
archives at www.dejanews.com
--
Nathan V. Patwardhan
nvp@shore.net
"send me mail"
--Jamie Zawinski
------------------------------
Date: 11 Feb 1997 09:16:18 -0500
From: nelson <nmljn@wombat.staff.ichange.com>
Subject: Re: Cookies and Website 1.1
Message-Id: <w104tfjjuml.fsf@wombat.staff.ichange.com>
Ross Lloyd <ross@tdrl.demon.co.uk> writes:
> Can anyone help me, I am trying to use access the HTTP_COOKIE
> environment variable using website 1.1e. As this is a initial local
> development area for a linux server, I am attempting to maintain
> complience, is it me or is it Website but this environment variable
> does not appear to be set properly (Netscape is fine if I do not
> name the cookie, Explorer fails whatever.
This question is actually a Common Gateway Interface question, and not
a perl language question. You will most likely meet with a better
response in news:comp.infosystems.www.authoring.cgi, which is the
appropriate group for such questions.
Remember that CGI-compliant programs need not be written in perl. All
the CGI does is specify the means of exposing certain environment
variables to a program, regardless of what language that program is
written in.
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: 11 Feb 1997 06:48:56 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: File Tests for Directory not working under NT4.0
Message-Id: <8cenena1x3.fsf@gadget.cscaper.com>
>>>>> "Nathan" == Nathan V Patwardhan <nvp@shore.net> writes:
Nathan> ### sorry for the sprintf abuse, but ...
Nathan> $full_entry = sprintf("%s%s", $sharename, $entry);
I'll say! Why not just:
$full_entry = "$sharename$entry";
Or if you want some explicit operator:
$full_entry = $sharename . $entry;
If you weren't aware of the "." operator, I can recommend a good book
(or two :-)....
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 567 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: 11 Feb 1997 14:01:40 GMT
From: kevin.smith@citicorp.com (Kevin Smith)
Subject: Re: File Tests for Directory not working under NT4.0
Message-Id: <5dpu44$56o@spruce.citicorp.com>
Nevermind.... A kind soul from SAS Institute, Inc. pointed out the error of
my ways, 5 minutes after posting. Gotta love newsgroups!
The answer was I was not full qualifying the $name.
The solution as given:
If you run this script under the perl debugger, you will see that "$name"
is just the bare file name, with no path. Hence it is probably not found
in the current directory, so the -d $name test fails.
The script works if you use
$fullname = $SHARENAME . "\\" . $name;
if (-d $fullname){
Interesting that I didn't have to do this under 95. I'm going to recheck
this to make sure.
------------------------------
Date: 11 Feb 1997 09:47:03 -0500
From: nelson <nmljn@wombat.staff.ichange.com>
Subject: Re: Get filename from variable-length path?
Message-Id: <w1020anjt7c.fsf@wombat.staff.ichange.com>
tadmc@flash.net (Tad McClellan) writes:
> Carl Payne (cpayne@xmission.xmission.com) wrote:
> : I have a situation where I'm given up to several hundred MB
> : of directory listings and I need to parse the filenames
> : (and ONLY the filenames) from those lists for a seperate routine.
> Naw. That's not a problem ;-)
> How about searching based on the last slash? (see below)
Carl might also try:
use File::Basename "basename";
...which would solve the problem without reinventing the wheel. :-)
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: 10 Feb 1997 13:35:58 GMT
From: gml4410@ggr.co.uk (Lack Mr G M)
Subject: Re: Help is anyone any good with sockets
Message-Id: <5dn87u$8si@ukwsv3.ggr.co.uk>
In article <5dkkhk$dkf@dunlop.cs.strath.ac.uk>, rdavidso@cs.strath.ac.uk (Ruth Ann Davidson CS93) writes:
|> I am trying to download a web page to a file through
|> a perl script, does anyone know how i can do this
|>
|> Please Help i am at my wits end
Try the LWP module from a CPAN site.
You will need the file libwww-perl-5.06.tar.gz.
--
----------- Gordon Lack ----------------- gml4410@ggr.co.uk ------------
The contents of this message *may* reflect my personal opinion. They are
*not* intended to reflect those of my employer, or anyone else.
------------------------------
Date: 11 Feb 1997 09:34:47 -0500
From: nelson <nmljn@wombat.staff.ichange.com>
Subject: Re: HELP: Problems with open(),time()
Message-Id: <w103ev3jtrs.fsf@wombat.staff.ichange.com>
Your subject line specified problems with open() and time(). Without
running your program, I can suggest two problems, which may or may not
turn out to be the culprits. I've snipped your code for conciseness
(concision?).
> sub cktime {
> open(IN,"$timefile") || die "no such file: $timefile\n";
Any time you do an open(), you should get into two habits:
1. (not a problem, just clarity of expression for your benefit and
others') Explicitly specify, in the second argument to open(), the
mode you want to open the file in, e.g.:
open(IN,"<$timefile"); #...etc...
2. (usually a problem, since not doing this can blow away a very
informative error message) Any time you use a function that has to
make a system call, make sure to put $! in the "...or die" clause:
open(IN,"<$timefile")
|| die "$0: Could not open time file $timefile for reading: $!";
The $! in a double quoted string is the text description of ERRNO. In
layman's terms, this will give you the reason why the given system
call failed. Note that it is only set if an error occurred; it is
never cleared. See perlvar(1) for details.
Note also that I've left off the "\n". Including a "\n" at the end of
a die message chops off the line number that the die occurred at.
When your program gets large enough, it's nice to have these line
numbers yelled back at you.
> $lasttime = <IN>;
> chop($lasttime);
chop() arbitrarily chops off the last character. Period. This is
good if the last character is a newline, which I assume it is in this
case. To ensure that you only chop off the last character if it's
equivalent to the current record separator (almost always newline),
use chomp(). See perlfunc(1) for details.
> close(IN);
> $curtime = time();
No problems here, although you might use localtime().
> sub ckmail {
> if (!$timeok) {
> print "/etc/.pwd.lock is there; noc has already been notified.\n";
> exit(0);
> } elsif ($fileok) {
> system ("/usr/lib/sendmail -v noc < $notification");
You should probably do:
my($status) = system("/usr/lib/sendmail -v noc < $notification");
$status /= 256; # or bit shift
if ($status) {
die "Oops; error with sendmail";
}
Aw, hell, I've probably got that all wrong. The basic gist is that
system() returns the error status that wait(2) would return. To get
the real exit value of the program your system() called, divide *that*
status by 256. What I'm not clear on without checking is whether $!
is set at this point.
> print "\nLockfile is there, sending mail to $mailto.\n";
> &savetime();
> }
> }
Hope this turns up a solution,
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: 10 Feb 1997 14:08:20 -0500
From: mione@hardees.rutgers.edu (Tony Mione)
Subject: Re: How can I call a perl CGI from a C cgi ?
Message-Id: <5dnrn4$e5b@hardees.rutgers.edu>
Russ Allbery <rra@cs.stanford.edu> writes:
>Thierry DELATTRE <th@euro-checkpoint.com> writes:
>> I'm using a CGI written in C and I would like to execute another CGI
>> from it, but this one is written in PERL. Is it possible to do and how
>> can I do ?
>What's a CGI? A CGI what? CGI is a protocol; you can't write CGI in C or
>Perl. You can write CGI *programs* in C or Perl.
>In any event, this depends on precisely what you want to do, and it's
>really a C question, not a Perl question. You can execute a Perl script
>from inside a C program the same way you can execute any other program
>from inside a C program.
>Chances are, what you want is the system(3) C library call.
>If that isn't enough help, try comp.infosystems.www.authoring.cgi or
>comp.lang.c.
>--
>Russ Allbery (rra@cs.stanford.edu) <URL:http://www.eyrie.org/~eagle/>
Actually, it depends. If you are running Perl5, there is a
mechanism to instantiate a Perl interpreter within a c program. I have not
yet done this myself but have read about it in the new edition of
'Programming Perl'. You construct a perl interpreter with:
PerlInterpreter *embededPerlInt;
embededPerlInt = perl_alloc();
perl_construct( embededPerlInt );
You then use perl_parse() to pass your script and arguments and
perl_run() to execute the script. The Perl interpreter can be released with
perl_destruct(), followed by perl_free().
The new 'Programming Perl' book by O'Reilly and Associates has a
good template for using embeded scripts. It is on page 370. They refer you
to the perlembed manpage. I assume that page gives details on what header
files are needed, etc.
--
Tony Mione, RUCS/NS, Rutgers University, Hill 055, Piscataway,NJ - 908-445-0650
mione@nbcs-ns.rutgers.edu W3: http://www-ns.rutgers.edu/~mione/
PGP Fingerprint : E2 25 2C CD 28 73 3C 5B 0B 91 8A 4E 22 BA FA 9F
Editorial Advisor for Digital Systems Report
------------------------------
Date: 11 Feb 1997 08:46:55 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: How to check an environmental variable
Message-Id: <d8u7mp4g.fsf@jander.com>
akench@cvimail.cv.com writes:
> Is there a way to check if a environmental variable
> exists or no. Checking this way
> "if ($ENV{'variable'}) "
> works only if that environmental variable has a value.
> How can I check if it is declared but has no value?
if (exists $ENV{'variable')) {...
--
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: 11 Feb 1997 10:46:48 GMT
From: gml4410@ggr.co.uk (Lack Mr G M)
Subject: Re: Increasing variable names (ie - $line1,$line2, etc)
Message-Id: <5dpimo$3u3@ukwsv3.ggr.co.uk>
In article <855607859.23313@dejanews.com>, basslerp@musu2.slu.edu writes:
|> Question: I have a situation where I there are to be a varied number of
|> lines to be read in, but then for each line to be split up and defined as
|> associative arrays ($line1{URL}, $line1{TITLE}, etc). The problem is
|> trying to define such initial variables names (like $line1, $line2). The
|> easiest way would be to simply create an array @line, and then just go
|> $line[1], $line[2], etc. However, as far as I know, you couldn't create
|> associative arrays out from these array values.
>>Sigh<< Did you think to actually *try* it before posting a query?
|> If possible, then
|> problem solved.
It is possible. It is simple. It is documented.
Look at the following:
$line[0]{'start1'} = 'start1-text';
$line[0]{'start2'} = 'start2-text';
$line[1]{'end'} = 'end-text';
for ($l = 0; $l <= $#line; $l++) {
foreach $k (keys %{$line[$l]}) {
print "\$line[$l]{$k} is $line[$l]{$k}\n";
}
}
--
----------- Gordon Lack ----------------- gml4410@ggr.co.uk ------------
The contents of this message *may* reflect my personal opinion. They are
*not* intended to reflect those of my employer, or anyone else.
------------------------------
Date: 11 Feb 1997 10:18:13 GMT
From: jon@amxdigital.com (Jonathan Peterson)
Subject: Re: Invoking Perl program
Message-Id: <jon-1102971015110001@amx11.amxdigital.com>
In article <5ctr73$hiu@newstand.syr.edu>, mpanfilo@mailbox.syr.edu wrote:
> Hi,
>
> I'm am new to Perl and tryed to invoke Perl program from Web browser. So,
> here is HTML file:
> From within Unix this Perl program runs. Tutorial says that when i click
> on a Perl's program link from a browser it should return appropriate
> information in correct HTML format directly to the browser. Unfortunately,
> after invoking the program via link I receive just a text of a program,
> not HTML formatted page. It should be noted that I made Perl's program
> executable.
>
> So, what did I do wrong? I will appreciate any comments.
>
The problem is with your http server's configuration. Usually, you can
only put cgi programs in a particular directory, most often called
cgi-bin. You need to put your script in this directory, set the execute
permissions on it (unix) and then call like this:
<a href=/cgi-bin/myscript.cgi>click me</a>
This will all be a bit different on windows NT. OK, totally different.
Consult your ISP for more details.
------------------
Opinions expressed above are not necessarily those of AMXdigital ltd.
Jonathan Peterson || jon@amxdigital.com || (+44) 0171 613 5300
"You wouldn't believe the things I've seen with your eyes."
------------------------------
Date: Tue, 11 Feb 1997 11:56:35 GMT
From: inforch@cris.com
Subject: Join our CGI List FREE!
Message-Id: <33005e6e.89665965@news.cris.com>
Join our CGI List FREE!
Sign-Up Form For email List Is At:
http://www.newslinx.com/lists/
CGI - Information, ideas, and new applications for the cgi guru and
those that want to be!
--
------------------------------
Date: Mon, 10 Feb 1997 14:21:55 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: Loops in perl
Message-Id: <fl_aggie-ya02408000R1002971421550001@news.fsu.edu>
In article <5dnl9t$okb@dismay.ucs.indiana.edu>, bdwheele@indiana.edu wrote:
+ seems alot easier to do:
+
+ #!/usr/bin/perl
+ for($i=1;$i<6;$i++) {
+ print "hello, world\n";
+ }
And, there's More Than One Way to Do Things:
foreach $i (1..6) {
print "hello, world\n";
}
+
+ than to do
[bogasity deleted]
OK, I understand what's going on, but oh my!
James
--
Consulting Minster for Consultants, DNRC
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: Mon, 10 Feb 1997 15:58:04 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Loops in perl
Message-Id: <32FF99EC.4467B723@gpu.srv.ualberta.ca>
In article <5dnf43$ktv$1@ftp.ampersand.com>,
jason@ampersand.com (Jason Brazile) writes:
!:In article <5dj1ls$1p4$1@newshound.csrv.uidaho.edu>,
!:Thomas Patrick Bailey <baile934@harrier.csrv.uidaho.edu> wrote:
!:> I am fairly new to perl, but I have been doing ok in it. What I
need to
!:> know is how to do a simple loop.
!:>
!:> A simple example would be very helpful.
!:
!:No problem. Loops are pretty simple in perl:
!
! Oh, for the love of God, are you a scheme programmer? :)
!
! seems alot easier to do:
!
! #!/usr/bin/perl
! for($i=1;$i<6;$i++) {
! print "hello, world\n";
! }
!
! than to do
!
gee, I thought it was an entry for some new
obfuscated "RTFM" contest...:)
!
!: #!/usr/bin/perl
!: use strict;
!: sub simple_loop
!: {
!: my ($lcv, $code) = @_;
!: ($lcv) && (&$code, &simple_loop($lcv - 1, $code));
!: }
!: sub main
!: {
!: # print "hello, world\n" 5 times
!: &simple_loop(5, sub {print "hello, world\n"});
!: }
!: &main;
!:---
------------------------------
Date: 11 Feb 1997 10:02:31 -0500
From: nelson <nmljn@wombat.staff.ichange.com>
Subject: Re: multiple selects
Message-Id: <w10zpxbidx4.fsf@wombat.staff.ichange.com>
"Adam M. Donahue" <donahue@acf2.NYU.EDU> writes:
> No, it's clearly a Perl question. I know perfectly well how to specify
> "multiple" in HTML; if you'd have read the subject line of my message,
> you would have seen that I put the proper HTML there. Should I scold you
> for not reading closely, hmm?
The question was how perl handles the result of multiple selections in
an HTML <SELECT> element. The answer is: In the same manner that
one would have C or C++ or COBOL or Fortran or sh or BASIC handle it.
The corollary to the answer is: form variables from an HTML page come
in as environment variables, according to the Common Gateway
Interface's specifications. The Interface does not dictate how any
language is to take it from there. Therefore, the question as phrased
is not a perl question, but a CGI question.
It would be a perl question if it were phrased thusly:
"What's a {good,idiomatic,fun,easy} way to
{parse,process,handle,store,whatever} multiple values from an
environment variable? I have an environment variable,
$ENV{'WHATEVER'}, that stores multiple values separated by a foobaz
character."
To which the answer would be:
There's More Than One Way To Do It.
1:
my($DELIMITER) = ","; # or whatever character you want
my(@values) = split(/$DELIMITER/,$ENV{'WHATEVER'});
for(@values) {
# process each iteration ($_) the way you want, i.e.:
print STDOUT "Whatever: $_\n";
}
2:
# Is this a CGI-compliant application? If so:
use CGI;
my($cgi) = new CGI;
my(@param_names) = $cgi->param();
for(@param_names) {
# For each parameter name, get its corresponding values.
# Even if that name has only one value, store said value as a
# one element array. Then anytime you need all the values
# from a parameter you can say @{ $FORM{"param_name"} },
# whether you know the number of values in advance or not. See
# perlref(1) for what @{ [ ] } means.
$FORM{$_} = @{ [ $cgi->param($_) ] };
}
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: 11 Feb 1997 13:48:44 GMT
From: erik@paxp01.mipool.uni-jena.de (Erik Braun)
Subject: Re: Need a way to calculate a random number between 1 and 20
Message-Id: <slrn45g0u6r.92q.erik@paxp01.mipool.uni-jena.de>
On Wed, 29 Jan 1997 10:43:42 GMT, David Cantrell <david@diablo.eimages.co.uk> wrote:
>So what's this perlfunc(1) you talk about? Doesn't exist on my
>system. Please remember that not everyone uses Unix, and that
>referring everyone to the manpages isn't very useful.
Many system managers built (or installed) a gateway between 'man' and the
WWW, as you can see in
http://www.minet.uni-jena.de/www/software/man_usrlocalmanman1.html
And I am really sure, you have such an online manual elsewhere (?)
in UK too. perlfunc(1), perlfunc(1) all around...
erik
--
erik@minet.uni-jena.de
------------------------------
Date: 11 Feb 1997 08:36:41 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: on the fly graphs
Message-Id: <enenmplh.fsf@jander.com>
"Richard S. Boswell" <sboswell@tamu.edu> writes:
> I'm trying to write a program that will generate gifs of graphs on the fly
> for web publishing. I need to generate simple graphs (line,bar,pie) for a
> simulation model. There is the possibility of thousands of graphs, so to
> conserve disk space, we only want to generate graphs that are needed by a
> certain user.
>
> I figured that I could strip data from text files with perl rather easily.
> My question is how to get graphs from that data. Is there an easy way to
> do this without spending a fortune on some COTS product? It will probably
> be running on an NT box (the simulation model runs on DOS/Windoze/NT), but
> if last comes to last I could run it on a UNIX box (but first I'd have to
> get the data from NT to the other machine...).
1. There's a perl5 extension called GD available on CPAN.
2. gnuplot, but it's not nicely integrated into perl.
Take a look at the O'Reilly book "CGI Programming on the World Wide
Web". It has lots of examples.
--
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: 11 Feb 1997 14:31:22 -0000
From: ahenry@tdc.dircon.co.uk (Andrew Henry)
Subject: Re: on the fly graphs
Message-Id: <5dpvrq$t3k@tdc.dircon.co.uk>
In article <5dokee$7le@fridge-nf0.shore.net>,
Nathan V. Patwardhan <nvp@shore.net> wrote:
>Richard S. Boswell (sboswell@tamu.edu) wrote:
>
>: I'm trying to write a program that will generate gifs of graphs on the fly
>: for web publishing. I need to generate simple graphs (line,bar,pie) for a
>: simulation model. There is the possibility of thousands of graphs, so to
>: conserve disk space, we only want to generate graphs that are needed by a
>: certain user.
>
>You might look at GD.pm, and pgplot from a CPAN near you!
>http://www.perl.com/perl/CPAN/
It would also be worth keeping an eye on Graph-It! from Matt Kruse.
It isn't "ready" yet, but the documentation looks good. See
http://www.netexpress.net/~mkruse/graphit/
--
Andrew Henry
ahenry@dircon.co.uk
------------------------------
Date: Mon, 10 Feb 1997 21:40:47 -0600
From: Mike Christensen <mike@soft-tek.com>
To: "Richard S. Boswell" <sboswell@tamu.edu>
Subject: Re: on the fly graphs
Message-Id: <32FFEA3F.1503@soft-tek.com>
Richard S. Boswell wrote:
>
> I'm trying to write a program that will generate gifs of graphs on the fly
> for web publishing. I need to generate simple graphs (line,bar,pie) for a
> simulation model. There is the possibility of thousands of graphs, so to
> conserve disk space, we only want to generate graphs that are needed by a
> certain user.
>
> I figured that I could strip data from text files with perl rather easily.
> My question is how to get graphs from that data. Is there an easy way to
> do this without spending a fortune on some COTS product? It will probably
> be running on an NT box (the simulation model runs on DOS/Windoze/NT), but
> if last comes to last I could run it on a UNIX box (but first I'd have to
> get the data from NT to the other machine...).
>
> thanks,
> sid.
I urge you to take a look at GRAFSMAN/WWW from Soft-tek International,
Inc. It is designed to generate graphs (in .gif format) on the fly.
You will find a live demonstration on our website:
http://www.soft-tek.com
In addition to creating the gif, GRAFSMAN/WWW will also automatically
generate an imagemap to go along with it, making your graphics and
interactive element of your web application.
GRAFSMAN/WWW is currently shipping on both NT and popular UNIX
platforms.
Please let me know if I can be of further assistance,
Mike Christensen
Soft-tek International, Inc.
1999 N. Amidon
Wichita, KS 67203
316 838 7200
316 838 3789 (fax)
mike@soft-tek.com
------------------------------
Date: 11 Feb 1997 14:33:48 GMT
From: silee@news.hk.super.net (Mr Simon Lee)
Subject: Re: Perl rand() function on solaris SPARC
Message-Id: <5dq00c$frg@tst.hk.super.net>
Thomas J. Forbes (tforbes@ix.netcom.com) wrote:
: I have the same problem - when I run:
: srand();
: $num = int(rand(7)); # Pick a Random Number
Actually I have the same problem on Solaris 2.x machine when I compiled Perl 5 and did make test. only this function failed.......
Simon :-(
: print "$num\n";
: I get back numbers like 56,798
: WHY IS THIS????????
: On Wed, 05 Feb 1997 15:36:28 -0800, Paul Austin <paustin@gw.ford.com>
: wrote:
: >Hi,
: >
: >I am trying to use the rand() function to obtain a random number between
: >0 and 39. This works fine on a HP UX system but when I run it on
: >solaris the numbers being returned are in the order of 100,000's
: >any ideas why this occurs?
: >
: >The command I am using is:
: >
: >$index = int(rand(39));
: >
: >regards,
: >paul
: >------------------------------------------------------------------
: >Paul Austin, Analyst, WPPS Supplier Data.
: >40/432, Trafford House, 8 Station Way, Basildon, Essex SS16 5XX
: >PROFS: PAUSTIN, INTERNET: paustin@gw.ford.com, UNI: pda1@ukc.ac.uk
: >Tel.44-1268-703016/718-3016 Fax.44-1268-703673/718-3673
------------------------------
Date: 11 Feb 1997 12:14:59 GMT
From: ylau@iworks.InterWorks.org (Yan Lau)
Subject: Perl5 and DBD-Oracle under Oracle 7.3.2.3 and HP-UX 10.20.
Message-Id: <5dpns3$c4e@server05.icaen.uiowa.edu>
We are having a problem porting some code from one system to another.
The system that works is running HP-UX 10.01, Oracle 7.2.2.4, DBI-0.73
DBD-Oracle-0.43 and Perl 5.003.
The new system is running HP-UX 10.20 and Oracle 7.3.2.3. After
recompiling the Perl source code and the DBI and DBD modules, the
DBD test program is failing with a bus error. I did have some
problems installing the C compiler because I had not gotten the
code word for the Nov. 1996 release which is what the system is
running. I had to install from an earlier 10.20 application CD.
However, Perl compiles and passes all tests. No matter what combination
of database, username /password is used, the error still occurs.
We are using the DBD-Oracle module for its Oraperl compatibility mode
only.
Does someone have a working version with this setup? Any suggestions
is most appreciated. Thanks for any advice.
/usr/bin/cc:
LINT A.10.32.03 CXREF A.10.32.03
HP92453-01 A.10.32.03 HP C Compiler
/usr/lib/libc: $Revision: 76.3 $
This is perl, version 5.003 with EMBED
built under hpux at Feb 10 1997 12:10:12
+ suidperl security patch
Yan.
ylau@iworks.interworks.org (guest)
------------------------------
Date: 11 Feb 1997 15:17:03 GMT
From: kevin.smith@citicorp.com (Kevin Smith)
Subject: PerlIS problem reading network drive
Message-Id: <5dq2hf$egu@spruce.citicorp.com>
I've got a simple script to read a directory. It doesn't seem to work when run
using PerlIs under MS IIS when trying to read a drive on a network that's
currently mapped. It works fine under my normal C drive.
This also works from the command line. I did the unthinkable - putting
perl.exe in the Scripts directory under IIS and trying it via a Web page like:
perl.exe?test.pl
This works fine as well.
So does PerlIS not have any knowledge of shared drives?
Here's my primitive code snippet:
------------------------------------------------------
# F Drive is a drive on a network shared for everyone.
$SHARENAME = "F:\\";
if (opendir(DD,$SHARENAME))
{
foreach $name (sort readdir(DD)) {
$fullname = $SHARENAME . "\\" . $name;
if (-d $fullname) {
print "$name was a directory\n";
} else {
print "$name was not a directory\n";
}
}
}
------------------------------------------------------
TIA
--
Kevin Smith
------------------------------
Date: 11 Feb 1997 14:45:18 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: problem sending mail from perl using cron
Message-Id: <5dq0lu$eit@fridge-nf0.shore.net>
Benjamin J Trott (btrott@scuacc.scu.edu) wrote:
: Thank you for your reply and your suggestions... they helped quite a bit
: (in that they made the script function as it should)... I am still a bit
: confused, though...
To follow-up your questions: There's nothing wrong with shorthand, but
when I have bugs in my code (where I might or might not get warnings
from perl -w), the first place I always look is for errors in (my)
shorthand notation. Were you using perl -w? What kind(s) of warnings
did it give you?
--
Nathan V. Patwardhan
nvp@shore.net
"send me mail"
--Jamie Zawinski
------------------------------
Date: 11 Feb 1997 13:31:32 GMT
From: tim@pipex.net (Tim Goodwin)
Subject: Re: Question about using "system" command
Message-Id: <5dpsbk$1fm@join.news.pipex.net>
In article <5dnl09$8lg@d2.tufts.edu>,
Premkumar Natarajan <pnataraj@emerald.tufts.edu> wrote:
>@args = ("awk","\'{print \$1;}\'",$filename,">",$another_filename);
>system(@args);
>
>I keep getting an error message that says,
>
>awk:syntax error near line 1
When you use
system $scalar;
then the scalar is interpreted by the shell for quoting, redirection,
and so on. (If Perl determines that the scalar contains no shell
metacharacters, it is bypassed, but that's just an optimization hack.)
On the other hand, when you use
system @array;
the shell is not involved at all. The arguments to the command are
exactly the elements of the array.
So awk is complaining because it is seeing the single quote marks in its
first argument. You can't simply remove these, because you need the
shell to interpret the redirection later on. So you should use this.
system "awk '{print $1}' $filename > $another_filename";
Tim.
--
Tim Goodwin | "A language needs both intestines and guts." -- Larry Wall
------------------------------
Date: Tue, 11 Feb 1997 09:21:32 -0600
From: ryanmd@mms.sbphrd.com
Subject: Saving complex data structures to disk, how best?
Message-Id: <855673711.2297@dejanews.com>
I have been trying to parse the various man pages and sites, I am really
just getting into perl. As I do this I need to establish a direction and
that will determine some of what I must learn, ergo I turn to the mighty
net for advice...
I need to build a more complex data structure than a simple hash. I have
seen a number of modules to manipulate them and I am reading the list of
lists pages etc. So far it seems that the only way to save the newer
structures that are possible in perl 5 is to use a couple of modules that
I have seen references to: Storable and Dumper.
I will dig (much) deeper if needed I suppose, but, would it be simpler to
try and recast the data structure into a collection of more simple hashs
in order to use dbm without having to learn OOP? (I have coded in C and a
struct makes sense to me). Should I dispense with dbm altogether and save
the data as a text table? Here follows a description of the data I need
to manipulate.
I need to build a data-definition table, to use for controlling the actual
data table. There will be many data tables. So for a given data table I
need to have a list of column headings, a table of general information,
and for each column I will need several further lists of text strings.
I want to use these lists of lists as keys to control presenting the data
table, i.e. if row[20] column[4] is '7' then color code row[20]
column[3] as red in an html table, and prepare a message that is
$table{"dataset1"}->$column[4]->$lastname{"7"}.
(ok, this syntax may be totally bogus, but I hope you get the idea)
I need to save the definitions and the table for frequent access. (I also
need to allow editing the definitions).
I would greatly appreciate some guidance on the best direction to
undertake. Do I bite the bullet and dive into OOP, or should (can) I
handle this with procedural perl4. This is not my main job... I need to
get something up in relatively short order, so there are tradeoffs.
Thanks for all follow ups to come (I hope).
--
M. Dominic Ryan (610)-270-6529 SmithKline Beecham Pharmaceuticals
ryanmd@mms.sbphrd.com King of Prussia, PA
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Tue, 11 Feb 1997 14:50:31 GMT
From: reimann@merck.de (Dr. Wolfgang Reimann)
Subject: SORT: trying to sort files on date. AND connecting system commands via pipe ????
Message-Id: <5dq13e$3lg@news.merck.de>
I'm trying to do the following:
reading a directory and sorting the files on a time stamp. The OS is
OpenVMS, perl 5.002_01. I'm trying this by using a VMS-function as i
could not find any intelligent sorting code to do this.
The time stamp on VMS-files looks like: "11-FEB-1997 15:32:44"
There's a VMS-function to convert it to: "1995-02-1115:32:44.63"
I'm filling an array with these data, converting time and writing out.
Besides my hope, there must be something else to do it, this is very,
very SLOW.
The next step is to sort the records on the new time stamp. This is
done again by a VMS-command, quick and dirty. I found no good
alternative. Anyway, if doing it this way, is there any method to
avoid writing temporary files for sorting? pipe()? Don't know how to
use it.
Here's the code, a good example of bad programming practice:
....
....
$Dir_Path = "any_file.dat"
$Dir_Str = "dir\/date\/col\:1\/width\=\(displ\=120,file\=80\) " ;
# directory command, produces 1 line per file and no wrap-around
$Sort_Str = "sort\/key\=\(pos\:80,siz\:30\) " ;
# Sort command VMS
open(INPUT,"$Dir_Str $Dir_Path |") ;
open(OUTPUT,">DIR.OUT") ;
@CMD = <INPUT>; # Into Array
close (INPUT) ;
chop(@CMD) ;
$Templ = "A80A40" ;
for ($i = 0; $i <= $#CMD ; $i++) {
($FName,$Time_in) = unpack($Templ,@CMD[$i]) ;
$Time_Out = `write sys\$output F\$CVTIME("$Time_in")` ;
# VMS function to convert time-stamp
$Time_Out =~ s/\s+//g ;
$FName =~ s/\s+//g ;
printf OUTPUT "%-80s %-30s\n",$FName,$Time_Out;
}
close (OUTPUT) ;
# now sorting...
$sort = `$Sort_Str DIR.OUT DIR.NEW` ;
print $sort ;
Thenks for any help. This might encourage VMS-people to join the perl
family...
Wolfgang Reimann
reimann@merck.de
------------------------------
Date: Tue, 11 Feb 1997 22:37:01 +1100
From: Banchong Harangsri <bjtong@cse.unsw.EDU.AU>
Subject: suitable typemap
Message-Id: <Pine.GSO.3.95.970211223400.15110A-100000@grieg.orchestra.cse.unsw.EDU.AU>
Hi,
i have a problem of finding a suitable typemap for my data
structure, i.e.,
typedef unsigned int *setX
i'm using this:
SV * T_SV
from the typemap file in the perl library as the typemap for my setX.
When compiling my .xs program, the compiler complained about the type
incompatibility. And when i ran the program, it core dumped. Can
someone please help me to fix it. Thanks.
tong
P.S. Here is the version of my Perl.
This is perl, version 5.003_24
--------------------------------test.xs-----------------------------
#ifdef __cplusplus
extern "C" {
#endif
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#ifdef __cplusplus
}
#endif
#include "test.h"
MODULE = TEST PACKAGE = TEST PREFIX = SETA_
setX
SETA_initseta()
CODE:
RETVAL = initseta();
OUTPUT:
RETVAL
------------------------------
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 926
*************************************