[6437] in Perl-Users-Digest
Perl-Users Digest, Issue: 62 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 6 11:37:22 1997
Date: Thu, 6 Mar 97 08:00:33 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 6 Mar 1997 Volume: 8 Number: 62
Today's topics:
/.*/ works, /[.]*/ doesn't, why!?!!?!! (Peter de Vroomen)
Re: [Q] Extract a regex <merlyn@stonehenge.com>
Re: Cannot connect to www.perl.com/perl anymore. <tchrist@mox.perl.com>
Re: DBD/DBI Oracle (Jay Flaherty)
Re: Getting list of files in a path (Jafar Shameem)
Re: Going from adequate to expert Perl <merlyn@stonehenge.com>
Re: How can I use #! w/o knowing where perl lives? <ltomlin@ucs.indiana.edu>
Re: How to convert a GIVEN date string to seconds (Steffen Beyer)
Re: How to create 666 file from www perl cgi? <tchrist@mox.perl.com>
Re: I am new to perl (Jay Flaherty)
Re: IN THE ZONE Newsletter Vol. 2, No. 3 - March 1997 <merlyn@stonehenge.com>
Interactive drawing alternatives in perl? <skolgan@Helios.goldworks.com>
Re: Knowing the pid of a fork()'ed child, really <mcampbel@tvmaster.turner.com>
Re: need some help here (Jafar Shameem)
Re: Perl & Win 95 <jwilson@ic.ac.uk>
perl program works on command line, but not when run th <cengel@nh1adm.uwaterloo.ca>
perl program works on command line, but not when run th <cengel@nh1adm.uwaterloo.ca>
perl program works on command line, but not when run th <cengel@nh1adm.uwaterloo.ca>
Perl5 references question (Barry G Reville)
Perl5 references question (Barry G Reville)
Re: question of perl experts (Dave Thomas)
Re: question of perl experts (Dave Thomas)
Re: Random Temp File in Perl 5.002 <tchrist@mox.perl.com>
Reversing data flow in TCP C/S examples <lpeters@aol.net>
Re: Stumped by Syntax Error!!! (Rand Simberg)
Re: Why the Win32::GD isn't Working? <rothd@dnr.state.mi.usX>
Re: Win32::ODBC INSERT INTO <Access Database> fails,? R <rothd@dnr.state.mi.usX>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 06 Mar 1997 13:41:56 GMT
From: peterv@valkieser.nl (Peter de Vroomen)
Subject: /.*/ works, /[.]*/ doesn't, why!?!!?!!
Message-Id: <331ec620.16635364@news.xs4all.nl>
Hello wizards,
I'm trying to break a line into words by using the following
construction:
while( <> )
{
$new_line = "";
while( $_ ne "" )
{
$new_line .= $1;
/(\s*)([^\s\n]*)([\n.]*)/;
if( /$match/ )
{
$new_line .= $somestring . $2 . $anotherstring;
}
else
{
$new_line .= $2;
}
$_ = $3;
}
print $new_line;
}
Please note that I wrote this code to be readable....
The trouble is $3 is empty, no matter what. I tried to narrow down the
problem by trying out the following pattern-matches:
1. /[\n.]*/
2. /[.]*/
3. /.*/
Only the last one works (as I'd been expecting). The question is:
WHY!?!?!!?!!
If /a*/ and /[a]*/ do the same thing, then why not /.*/ and /[.]*/???
I'm using Perl version 5.003_25. Is this a bug or have I missed
something in the docs?
Bye,
Peter
------------------------------
Date: 06 Mar 1997 06:57:04 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Vegard Bakke <vegardb@knoll.hibu.no>
Subject: Re: [Q] Extract a regex
Message-Id: <8cvi759l8v.fsf@gadget.cscaper.com>
>>>>> "Vegard" == Vegard Bakke <vegardb@knoll.hibu.no> writes:
Vegard> I would like to "move" the matching pattern from a regex in
Vegard> a string to a new variable.
Vegard> Lets use the three first random cahacters as an example ( /^.{3}/ ).
Vegard> $OrgStr="1234567890";
Vegard> $NewStr="";
Vegard> In this example I would like the result to be:
Vegard> $OrgStr="4567890";
Vegard> $NewStr="123";
Vegard> This is just an example. I after a solution that does this with
Vegard> any regex. (Not only /^.{3}/.)
$NewStr = $1 if $OrgStr =~ s/(^.{3})//;
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 544 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: 6 Mar 1997 12:41:56 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Cannot connect to www.perl.com/perl anymore.
Message-Id: <5fme2k$2ne$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
warrenb@pop.kenan.com (Warren Brown) writes:
:For some reason or another I can't connect to the Perl Homepage from
:my companies Internet connection but I able to reach to site from my
:home computer. Is this site using a port that our company's firewall
:is not allowing through. I don't have problems reaching any of my
:other frequently visited sites.
No, nothing special going on here. Maybe it was just busy?
Sounds strange.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
"Don't let it get to you. Shout happens." --Larry Wall
------------------------------
Date: 6 Mar 1997 13:22:04 GMT
From: fty@hickory.engr.utk.edu (Jay Flaherty)
Subject: Re: DBD/DBI Oracle
Message-Id: <5fmgds$gvn$1@gaia.ns.utk.edu>
Michael Shannon (mshannon@lds.com) wrote:
: this I have been told that I need DBD/DBI and that I can get it from
: http://www.hermetica.com/. From this site, I retrieved a GNEW zip file
: which contains *.pm, *.pl, *.h, *.c, and *.xs files. The problem is I
: have no idea what I have or how to use what I have or what I don't have
: and still need to acquire. Do I have DBB? Do I have DBI? Can't I just
: use a reference module(PM?) or library and use the functions to access
: the database?
If memory serves me correctly, you need to read the README and possibly the
INSTALL files. They should tell you to do something like:
perl Makefile.PL
make
make test
make install (as root)
You need to do this for both the DBI package as well as the DBD
package for Oracle)
Once you have it installed you need to go back to www.hermetica.com and
read some of the tutorials. Also, in the extracted fiels there is a test
file and or directory (that make test uses) that gives excellent examples
Also, join the listservs. Good luck and put a little effort into discovering
this stuff on your own. There is a lot of information out there if you take
the time to research...Jay
Jay
--
**********************************************
Jay Flaherty fty@hickory.engr.utk.edu
------visualize whirled peas------
**********************************************
------------------------------
Date: 5 Mar 1997 21:32:31 GMT
From: jafar@finance (Jafar Shameem)
Subject: Re: Getting list of files in a path
Message-Id: <5fkopf$avp@gein.ge.com>
how about:
$dir=$ARGV[0];
@files=<$dir/*>;
--
http://mville.edu:8000/jafar jafar@beavisandbutthead.com
I got a strong urge to fly
But I got nowhere to fly to.. fly to.. fly to.. fly to..
[Pink Floyd - The Wall]
------------------------------
Date: 06 Mar 1997 07:02:00 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: murali@internix.com
Subject: Re: Going from adequate to expert Perl
Message-Id: <8csp299l0n.fsf@gadget.cscaper.com>
>>>>> "Murali" == Murali Donthireddy <murali@internix.com> writes:
Murali> I think part of the reason the "masters" are so good is that they
Murali> have stong knowledge in areas not strictly Perl:
Murali> like Programming language theory, Operating systems, UNIX etc.
Yes. Perl was something like my 45th computer language that I
learned. I have 20 years of professional computer experience, in many
different operating systems, languages, environments, and so on.
So, most of the clever stuff I do in Perl is really just because I've
seen a helluva lotta code over the years, and remembered all the cool
tricks so that I could rewrite them in Perl.
And the nice thing about Perl is that I can use tricks from algol-like
languages, functional-lispy languages, and now OO-ish languages.
(Prolog-like languages and forth-like languages don't transfer well,
but I have enough stuff from the others to make up for it. :-)
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 544 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: Thu, 6 Mar 1997 08:32:00 -0500
From: Jay Tomlin <ltomlin@ucs.indiana.edu>
Subject: Re: How can I use #! w/o knowing where perl lives?
Message-Id: <Pine.HPP.3.91.970306083001.19481A-100000@ezinfo.ucs.indiana.edu>
On Wed, 5 Mar 1997, Tom Phoenix wrote:
> On Mon, 3 Mar 1997, Paul H. Hargrove wrote:
>
> > Subject: How can I use #! w/o knowing where perl lives?
>
> The sysadmin should, if needed, set up a symlink from /usr/bin/perl to the
> real perl binary. In a perfect world, that is. :-)
But if the sysadmin is elusive, you can always just type:
whereis perl
at your unix prompt to find out the Path to Perl.
-jay
----------
Jay Tomlin
Office of Overseas Study, Indiana University
http://ezinfo.ucs.indiana.edu/~ltomlin
"When it speaks of music, language is lame." --George Steiner
------------------------------
Date: 6 Mar 1997 06:50:55 GMT
From: sb@en.muc.de (Steffen Beyer)
Subject: Re: How to convert a GIVEN date string to seconds
Message-Id: <5flpgf$cc6$1@en1.engelschall.com>
Dave Thomas <dave@fast.thomases.com> wrote:
> On Tue, 04 Mar 1997 09:44:32 -0500, Fu-Chiang (Rich) Tsui
> <tsui@cbmi.upmc.edu> wrote:
> > Hi there,
> >
> > Does anyone know how to convert a given date string, say 1/4/97, to
> > number of seconds since 1/1/1970 in Perl5.001UNIX? Thank you in
> > advance.
> Look in CPAN for Date:: modules
> Dave
In this case, a module is not necessarily needed.
See the Perl documentation for "localtime" and related functions - one
of them does what you want, but can't remember right which at the moment.
(Enter "man perlfunc")
Yours,
--
|s |d &|m | Steffen Beyer <sb@sdm.de> (+49 89) 63812-244 fax -150
| | | | software design & management GmbH & Co. KG
| | | | Thomas-Dehler-Str. 27, 81737 Munich, Germany.
"There is enough for the need of everyone in this world,
but not for the greed of everyone." - Mahatma Gandhi
------------------------------
Date: 6 Mar 1997 15:05:41 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How to create 666 file from www perl cgi?
Message-Id: <5fmmg5$7sf$4@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
soccer@microserve.net (Geoffrey Hebert) writes:
:If I create the file as the owner with 666 permissions from my telnet
:account, everything works fine.
BTW, it's mode 0666 you (apparently and perilously) want, in octal.
Mode 666 is in decimal, which is actually mode 01232, which is surely
not what you want.
But that's not yoru problem. Your problem is you don't understand
the Idiot's Guide to Solving CGI Perl Problems.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
File names are infinite in length where infinity is set to 255 characters.
- Peter Collinson, "The Unix File System"
------------------------------
Date: 6 Mar 1997 13:29:56 GMT
From: fty@hickory.engr.utk.edu (Jay Flaherty)
Subject: Re: I am new to perl
Message-Id: <5fmgsk$gvn$2@gaia.ns.utk.edu>
iljamar (flash@winning.com) wrote:
: Does anyone know of any books or instructional videos on perl? I preffer
: videos, possibly a trainig course in the Connecticut area. Thanks
for a book look at "Learning Perl" by Randal Schwartz
for training this is from Randal's home page:
Learn Perl now! To find out about my on-site and open-enrollment classes,
send a blank message to
perl-training-info@stonehenge.com.
You'll get the answer back by email.
Jay
--
**********************************************
Jay Flaherty fty@hickory.engr.utk.edu
------visualize whirled peas------
**********************************************
------------------------------
Date: 06 Mar 1997 06:55:05 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: skatz@waite.mcp.com (Steven Katz)
Subject: Re: IN THE ZONE Newsletter Vol. 2, No. 3 - March 1997
Message-Id: <8cybc19lc6.fsf@gadget.cscaper.com>
Your "newsletter"needs a peer review. It's passing along very bad
and dangerous code.
>>>>> "Steven" == Steven Katz <skatz@waite.mcp.com> writes:
Steven> # open the day's archive file for appending
Steven> open (FILE, ">>$filename") || &bye2("Can not open $filename");
Steven> flock (FILE, 2); # lock the file before we change it
Steven> print FILE $line; # write to the file
Steven> flock (FILE, 8); # unlock the file after we change it
Steven> close (FILE); # close the file
No! Thou Shalt Not De-flock Before Closing! Anything left in the
STDIO buffer now has a chance of getting lost, because another process
could come in between the flock-release and the close (where the flush
occurs).
For the hard of hearing, *don't* use flock(FILE,8) unless you REALLY
REALLY know what you are doing. And in this example, they didn't
know. :-)
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 544 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: Thu, 6 Mar 1997 10:07:46 -0500
From: Serge Kolgan <skolgan@Helios.goldworks.com>
Subject: Interactive drawing alternatives in perl?
Message-Id: <Pine.SOL.3.91.970306095845.25345A-100000@Helios.goldworks.com>
was looking for some light-weight (not perl/Tk) package in perl(5) which
allows to draw graphics primitives on the screen interactively, nothing
is available on CPAN AFAIK...
any idea if there's such a beast?
Greets,
Serge.
-----------------------------------------------------------------------------
practice your intention
------------------------------
Date: 06 Mar 1997 09:44:47 -0500
From: Mike Campbell <mcampbel@tvmaster.turner.com>
Subject: Re: Knowing the pid of a fork()'ed child, really
Message-Id: <r57mjl2i74.fsf@tvmaster.turner.com>
Joe Rabinoff <joer@mo.net> writes:
> > How can I deal with this so that the parent process really knows what the
> > pid of the process is that I need? I have a workaround now that when
> > "fork()+1" is not found, it tries "fork()+2", but is still fails if the pid
> > goes to "fork()+3".
>
> Elliot,
>
> As a stopgap measure at least, the fork'ed process could write its PID into a
> file that the parent can read. It might be messy, but I don't know of a
> better way.
Can't you re-direct STDERR (to /dev/null) immediately before exec'ing? As I
understand it, child processes get a copy of the parent's fd's.
------------------------------
Date: 5 Mar 1997 21:59:09 GMT
From: jafar@finance (Jafar Shameem)
Subject: Re: need some help here
Message-Id: <5fkqbd$e9m@gein.ge.com>
try using:
($lname,$fname,$location,$mailstop,$phone) = split(/\s+/);
Christopher M. Surber (surber@earthlink.net) wrote:
: hey all,
: im trying to get this script to take a list and from one line at
: a time
: take each word or whatever and put it into a variable so that i can
: insert the information into a different format. what i have don't work
: and im gittin crazy. the script i have so far is
: ***************************
: #!/usr/bin/perl
: print "what file?";
: chop($filename = <STDIN>);
: open (THATFILE, "$filename") || die"cannot open $filename";
: while (<THATFILE>) {
:
: ($lname,$fname,$location,$mailstop,$phone) = split(/ /);
:
: write;
: }
: format STDOUT =
: @<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<@<<<<<<<@<<<<<<<<<<
: $lname,$fname,$location,$mailstop,$phone,$real
: .
: **********************
: part of the list im using is below , all the list looks the same, each
: item is seperated by a space or tab.
: **********************
: Abrams, Sandra Lib2123B L2211 6611
: Academic Advising Lib1401 L1401 6312
: Academic Budgeting Lib3234 L3234 6867
: Academic Computing Lib2409 L2408 6235
: John Aikin Cushing Lib2213 L2211 6234
: Virginia Darney Lib2210 L2211 6436
: **********************
: when i run the script i get:
: **********************
: Abrams, Sandra Lib2123B
: Academic Advising Lib1401
: Academic Budgeting Lib3234
: Academic Computing Lib2409 L2408
: John Aikin
: Virginia Darney Lib2210
: ********************
: does any one have any suggestions?
: feel free to e-mail me directly
: thanx chrisssss...
: --
: ================================
: Just because you're not Paranoid,
: don't mean their not after you.
: ================================
: ONLY THE PARANOID SURVIVE!
: ================================
: surber@earthlink.net
: surberc@elwha.evergreen.edu
: ================================
--
http://mville.edu:8000/jafar jafar@beavisandbutthead.com
I got a strong urge to fly
But I got nowhere to fly to.. fly to.. fly to.. fly to..
[Pink Floyd - The Wall]
------------------------------
Date: 6 Mar 1997 14:20:27 GMT
From: "Jeff Wilson" <jwilson@ic.ac.uk>
Subject: Re: Perl & Win 95
Message-Id: <01bc2a39$88ffcfe0$1d34c69b@leicester.cc.ic.ac.uk>
I downloaded Perl (Win32) from Activeware, http://www.perl.hip.com/,
to my Windows95 P100 and it installed without any real problems.
--
Jeff Wilson
CCS ~ Imperial College ~
London UK
Kevin A. Miller <kmiller@mail.cheta.net> wrote in article
<331DEC02.FF0@mail.cheta.net>...
> Someone please help; I am looking for Perl5 that will run on my P-166
> system using Win95. I have tried to use Perl for Win32 from various
> sources (CD's from books), but it does not install fully or well
enough
> to run. Does anybody have any ideas or means to get the info to run
it
> on my OS. Thank you,
> K. Miller kmiller@cheta.net
>
------------------------------
Date: Thu, 06 Mar 1997 04:47:42 -0400
From: Chris Engel <cengel@nh1adm.uwaterloo.ca>
Subject: perl program works on command line, but not when run through www server
Message-Id: <331E84AE.1A04@nh1adm.uwaterloo.ca>
Hi folks. I have been banging my head against the wall trying
to figure out what I'm doing wrong. I am trying to write a
perl program that will schedule appointments for me. The
The first part of the program reads in data from a file in which
appointment data is stored. The format of the file is:
time:name
for example:
900:x
945:Chris
1030:M. Jones
and so on. The program reads the file, and if it sees an
x, then it will print the time, the word "available" and a
radio button. If it doesn't see an x, then it prints the
time and the name.
The problem is this: when I run the program using
perl -w showappt.cgi, I get a warning saying
use of uninitialized variable. This warning is given when
the if statements are executed. However, the program
saves the printout to the file, and when I look at the file,
everything comes out the way that I wanted.
However, when I try and run the program using lynx or netscape,
the program doesn't save anything that was printed from the
print statements. It will print everything else.
Originally, I had things set up so that the program would print
out straight to the browser. I saved things to a file and then
opened a file (html formatted), and then read the file, hoping
to find the error. No luck.
The part of the program in question is shown below:
#Now lets open the datafile for that date and establish the
#name-value pairs for the data
open (DATES, "<mar0397.dat");
@dates = <DATES>;
close(DATES);
$date = "March 3, 1997";
#$schedule_file_html = "mar0397.html";
#With the data read in from the appointment schedule for that
#date, we now display the schedule. If the time slot is open
# a radio button is created. If the time slot is not open,
# the name of the person who reserved that time slot is
#shown.
open (SCHEDULE,">mar0397.html");
print SCHEDULE "<html>\n";
print SCHEDULE "<head>\n";
print SCHEDULE "<title>\n";
print SCHEDULE "Schedule\n";
print SCHEDULE "</title>\n";
print SCHEDULE "</head>\n";
print SCHEDULE "<body bgcolor=\"#ffffff\">\n";
print SCHEDULE "<h1><center>Schedule for $date\n";
print SCHEDULE "<p>\n";
print SCHEDULE "</center></h1><br>\n";
print SCHEDULE "<form method = \"POST\" action = \"readenv.cgi\">\n";
print SCHEDULE "<input type = \"hidden\" name = \"date\" value = \"March
03\">\n";
print SCHEDULE "<p>\n";
print "@dates\n";
open (DATES,"<mar0397.dat");
while (<DATES>) {
chop;
($time,$student) = split(/:/,$_,2);
print "help help help";
if ($time eq "900") {
$proper_time = "9:00 am";
}
elsif ($time eq "945") {
$proper_time = "9:45 am";
}
elsif ($time eq "1030") {
$proper_time = "10:30 am";
}
elsif ($time eq "1115") {
$proper_time = "11:15 am";
}
elsif ($time eq "1300") {
$proper_time = "1:00 pm";
}
elsif ($time eq "1345") {
$proper_time = "1:45 pm";
}
elsif ($time eq "1430") {
$proper_time = "2:30 pm";
}
elsif ($time eq "1515") {
$proper_time = "3:15 pm";
}
elsif ($time eq "1600") {
$proper_time = "4:00 pm";
}
else {
}
if ($student eq "x") {
print SCHEDULE "$proper_time \t available \t <input type = \"radio\" name
= \"time\" value =\"$time\"><br>\n";
}
else {
print SCHEDULE "$proper_time \t $student<br>\n";
}
}
print SCHEDULE "<center>\n";
print SCHEDULE "<input type = \"submit\" value = \"Reserve your time\">
or
<input type = \"reset\" value = \"Redo your selection\"><br>\n";
print SCHEDULE "</center><br>\n";
print SCHEDULE "</form>\n";
print SCHEDULE "</body></html>\n";
close SCHEDULE;
print "Content-type: text/html\n\n";
open(SCHEDULE_FILE, "<mar0397.html");
while(<SCHEDULE_FILE>) {
print;
}
close SCHEDULE_FILE;
}
So, to summarize:
perl -w showappt.cgi will show use of uninitialized variables
in the if statements.
When executed from the command line, mar0397.html file will have
the proper html code.
When executed using lynx or netscape, the file will not show
any print statements executed from the if statements.
I have checked the if statements, and they are executing
properly. I printed out the @dates file (bad name, I know) and
the information is being read in properly.
Any help would be greatly appreciated!
Chris Engel
------------------------------
Date: Thu, 06 Mar 1997 04:53:14 -0400
From: Chris Engel <cengel@nh1adm.uwaterloo.ca>
Subject: perl program works on command line, but not when run through www server
Message-Id: <331E85FA.45D3@nh1adm.uwaterloo.ca>
Hi folks. I have been banging my head against the wall trying
to figure out what I'm doing wrong. I am trying to write a
perl program that will schedule appointments for me. The
The first part of the program reads in data from a file in which
appointment data is stored. The format of the file is:
time:name
for example:
900:x
945:Chris
1030:M. Jones
and so on. The program reads the file, and if it sees an
x, then it will print the time, the word "available" and a
radio button. If it doesn't see an x, then it prints the
time and the name.
The problem is this: when I run the program using
perl -w showappt.cgi, I get a warning saying
use of uninitialized variable. This warning is given when
the if statements are executed. However, the program
saves the printout to the file, and when I look at the file,
everything comes out the way that I wanted.
However, when I try and run the program using lynx or netscape,
the program doesn't save anything that was printed from the
print statements. It will print everything else.
Originally, I had things set up so that the program would print
out straight to the browser. I saved things to a file and then
opened a file (html formatted), and then read the file, hoping
to find the error. No luck.
The part of the program in question is shown below:
#Now lets open the datafile for that date and establish the
#name-value pairs for the data
open (DATES, "<mar0397.dat");
@dates = <DATES>;
close(DATES);
$date = "March 3, 1997";
#$schedule_file_html = "mar0397.html";
#With the data read in from the appointment schedule for that
#date, we now display the schedule. If the time slot is open
# a radio button is created. If the time slot is not open,
# the name of the person who reserved that time slot is
#shown.
open (SCHEDULE,">mar0397.html");
print SCHEDULE "<html>\n";
print SCHEDULE "<head>\n";
print SCHEDULE "<title>\n";
print SCHEDULE "Schedule\n";
print SCHEDULE "</title>\n";
print SCHEDULE "</head>\n";
print SCHEDULE "<body bgcolor=\"#ffffff\">\n";
print SCHEDULE "<h1><center>Schedule for $date\n";
print SCHEDULE "<p>\n";
print SCHEDULE "</center></h1><br>\n";
print SCHEDULE "<form method = \"POST\" action = \"readenv.cgi\">\n";
print SCHEDULE "<input type = \"hidden\" name = \"date\" value = \"March
03\">\n";
print SCHEDULE "<p>\n";
print "@dates\n";
open (DATES,"<mar0397.dat");
while (<DATES>) {
chop;
($time,$student) = split(/:/,$_,2);
print "help help help";
if ($time eq "900") {
$proper_time = "9:00 am";
}
elsif ($time eq "945") {
$proper_time = "9:45 am";
}
elsif ($time eq "1030") {
$proper_time = "10:30 am";
}
elsif ($time eq "1115") {
$proper_time = "11:15 am";
}
elsif ($time eq "1300") {
$proper_time = "1:00 pm";
}
elsif ($time eq "1345") {
$proper_time = "1:45 pm";
}
elsif ($time eq "1430") {
$proper_time = "2:30 pm";
}
elsif ($time eq "1515") {
$proper_time = "3:15 pm";
}
elsif ($time eq "1600") {
$proper_time = "4:00 pm";
}
else {
}
if ($student eq "x") {
print SCHEDULE "$proper_time \t available \t <input type = \"radio\" name
= \"time\" value =\"$time\"><br>\n";
}
else {
print SCHEDULE "$proper_time \t $student<br>\n";
}
}
print SCHEDULE "<center>\n";
print SCHEDULE "<input type = \"submit\" value = \"Reserve your time\">
or
<input type = \"reset\" value = \"Redo your selection\"><br>\n";
print SCHEDULE "</center><br>\n";
print SCHEDULE "</form>\n";
print SCHEDULE "</body></html>\n";
close SCHEDULE;
print "Content-type: text/html\n\n";
open(SCHEDULE_FILE, "<mar0397.html");
while(<SCHEDULE_FILE>) {
print;
}
close SCHEDULE_FILE;
}
So, to summarize:
perl -w showappt.cgi will show use of uninitialized variables
in the if statements.
When executed from the command line, mar0397.html file will have
the proper html code.
When executed using lynx or netscape, the file will not show
any print statements executed from the if statements.
I have checked the if statements, and they are executing
properly. I printed out the @dates file (bad name, I know) and
the information is being read in properly.
Any help would be greatly appreciated!
Chris Engel
------------------------------
Date: Thu, 06 Mar 1997 04:52:47 -0400
From: Chris Engel <cengel@nh1adm.uwaterloo.ca>
Subject: perl program works on command line, but not when run through www server
Message-Id: <331E85DF.591D@nh1adm.uwaterloo.ca>
Hi folks. I have been banging my head against the wall trying
to figure out what I'm doing wrong. I am trying to write a
perl program that will schedule appointments for me. The
The first part of the program reads in data from a file in which
appointment data is stored. The format of the file is:
time:name
for example:
900:x
945:Chris
1030:M. Jones
and so on. The program reads the file, and if it sees an
x, then it will print the time, the word "available" and a
radio button. If it doesn't see an x, then it prints the
time and the name.
The problem is this: when I run the program using
perl -w showappt.cgi, I get a warning saying
use of uninitialized variable. This warning is given when
the if statements are executed. However, the program
saves the printout to the file, and when I look at the file,
everything comes out the way that I wanted.
However, when I try and run the program using lynx or netscape,
the program doesn't save anything that was printed from the
print statements. It will print everything else.
Originally, I had things set up so that the program would print
out straight to the browser. I saved things to a file and then
opened a file (html formatted), and then read the file, hoping
to find the error. No luck.
The part of the program in question is shown below:
#Now lets open the datafile for that date and establish the
#name-value pairs for the data
open (DATES, "<mar0397.dat");
@dates = <DATES>;
close(DATES);
$date = "March 3, 1997";
#$schedule_file_html = "mar0397.html";
#With the data read in from the appointment schedule for that
#date, we now display the schedule. If the time slot is open
# a radio button is created. If the time slot is not open,
# the name of the person who reserved that time slot is
#shown.
open (SCHEDULE,">mar0397.html");
print SCHEDULE "<html>\n";
print SCHEDULE "<head>\n";
print SCHEDULE "<title>\n";
print SCHEDULE "Schedule\n";
print SCHEDULE "</title>\n";
print SCHEDULE "</head>\n";
print SCHEDULE "<body bgcolor=\"#ffffff\">\n";
print SCHEDULE "<h1><center>Schedule for $date\n";
print SCHEDULE "<p>\n";
print SCHEDULE "</center></h1><br>\n";
print SCHEDULE "<form method = \"POST\" action = \"readenv.cgi\">\n";
print SCHEDULE "<input type = \"hidden\" name = \"date\" value = \"March
03\">\n";
print SCHEDULE "<p>\n";
print "@dates\n";
open (DATES,"<mar0397.dat");
while (<DATES>) {
chop;
($time,$student) = split(/:/,$_,2);
print "help help help";
if ($time eq "900") {
$proper_time = "9:00 am";
}
elsif ($time eq "945") {
$proper_time = "9:45 am";
}
elsif ($time eq "1030") {
$proper_time = "10:30 am";
}
elsif ($time eq "1115") {
$proper_time = "11:15 am";
}
elsif ($time eq "1300") {
$proper_time = "1:00 pm";
}
elsif ($time eq "1345") {
$proper_time = "1:45 pm";
}
elsif ($time eq "1430") {
$proper_time = "2:30 pm";
}
elsif ($time eq "1515") {
$proper_time = "3:15 pm";
}
elsif ($time eq "1600") {
$proper_time = "4:00 pm";
}
else {
}
if ($student eq "x") {
print SCHEDULE "$proper_time \t available \t <input type = \"radio\" name
= \"time\" value =\"$time\"><br>\n";
}
else {
print SCHEDULE "$proper_time \t $student<br>\n";
}
}
print SCHEDULE "<center>\n";
print SCHEDULE "<input type = \"submit\" value = \"Reserve your time\">
or
<input type = \"reset\" value = \"Redo your selection\"><br>\n";
print SCHEDULE "</center><br>\n";
print SCHEDULE "</form>\n";
print SCHEDULE "</body></html>\n";
close SCHEDULE;
print "Content-type: text/html\n\n";
open(SCHEDULE_FILE, "<mar0397.html");
while(<SCHEDULE_FILE>) {
print;
}
close SCHEDULE_FILE;
}
So, to summarize:
perl -w showappt.cgi will show use of uninitialized variables
in the if statements.
When executed from the command line, mar0397.html file will have
the proper html code.
When executed using lynx or netscape, the file will not show
any print statements executed from the if statements.
I have checked the if statements, and they are executing
properly. I printed out the @dates file (bad name, I know) and
the information is being read in properly.
Any help would be greatly appreciated!
Chris Engel
------------------------------
Date: 6 Mar 1997 15:05:57 GMT
From: breville@uoguelph.ca (Barry G Reville)
Subject: Perl5 references question
Message-Id: <5fmmgl$5if@ccshst05.cs.uoguelph.ca>
How do you dereference an array reference once its part of an array?
I know how to dereference under normal circumstances
eg - $arrayref = \@array;
@newarray = @$arrayref;
..And now I have the array back! BUT..
If the reference is part of an array itself..
eg - @refarray = ($arrayref,$arrayref2);
@newarray = ?????;
And yes I do know how to get at the elements of the array one at a time
by saying
$val1 = $$refarray[0][0];
Please tell me the secret!
Barry Reville
University of Guelph
Computing and Communications Services
breville@uoguelph.ca
www.uoguelph.ca/~breville
------------------------------
Date: 6 Mar 1997 15:13:38 GMT
From: breville@uoguelph.ca (Barry G Reville)
Subject: Perl5 references question
Message-Id: <5fmmv2$830@ccshst05.cs.uoguelph.ca>
In the last post I meant to say:
$val = $refarray[0][0];
As a way to get at variables!
Barry Reville
University of Guelph
Computing and Communications Services
breville@uoguelph.ca
www.uoguelph.ca/~breville
------------------------------
Date: 6 Mar 1997 14:01:28 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: question of perl experts
Message-Id: <slrn5htjb7.ghf.dave@fast.thomases.com>
On Wed, 05 Mar 1997 02:44:13 +0000, Patrick Quinn wrote:
> My name is Patrick Quinn and I work for American Management Systems in
> Fairfax, Virginia and currently I am coding a real-time overall testing
> program. I have ran into a barrier while coding my test program. I two
> perl source files. A main, and a source file containing nothing but
> subroutines. My question is how to have my main program calls the
> subroutines not in the main program but in the second subroutine file
> for both Unix and NT development.
Hve you have a look at 'require' in the documentation. If the main file
'require's the second, then basically the second file's contents become
available to it.
If this is something that is likely to grow into multiple source files, you
should probably spend some time with your feet up reading about packages -
they'll help you structure your code into separate namespaces with better
defined interfaces.
If your 'require' complains it can find the second file, look up 'use lib'
or the PERLLIB environment variable.
Dave
--
_________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: 6 Mar 1997 14:03:42 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: question of perl experts
Message-Id: <slrn5htjff.ghf.dave@fast.thomases.com>
On Wed, 05 Mar 1997 02:44:13 +0000, Patrick Quinn wrote:
> My name is Patrick Quinn and I work for American Management Systems in
> Fairfax, Virginia and currently I am coding a real-time overall testing
> program. I have ran into a barrier while coding my test program. I two
> perl source files. A main, and a source file containing nothing but
> subroutines. My question is how to have my main program calls the
> subroutines not in the main program but in the second subroutine file
> for both Unix and NT development.
Hve you have a look at 'require' in the documentation. If the main file
'require's the second, then basically the second file's contents become
available to it.
If this is something that is likely to grow into multiple source files, you
should probably spend some time with your feet up reading about packages -
they'll help you structure your code into separate namespaces with better
defined interfaces.
If your 'require' complains it can find the second file, look up 'use lib'
or the PERLLIB environment variable.
Dave
--
_________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: 6 Mar 1997 14:58:35 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Random Temp File in Perl 5.002
Message-Id: <5fmm2r$7sf$3@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Monte Mitzelfelt <monte@conchas.nm.org> writes:
:You could try something like:
:$tmp = 'aaaa' ;
:$tmp++ while -e ( $tempfile = "/tmp/XXX$tmp" ) ;
:open FILE, "> $tempfile" or die "Can't open $tempfile: $!" ;
RACE CONDITON ALERT. You need O_EXCL there.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
X-Windows: The Cutting Edge of Obsolescence.
--Jamie Zawinski
------------------------------
Date: Thu, 06 Mar 1997 09:32:40 -0500
From: Les Peters <lpeters@aol.net>
Subject: Reversing data flow in TCP C/S examples
Message-Id: <331ED588.167E@aol.net>
I am trying to modify the examples from the Teal Camel on Internet TCP
clients and servers to have the client give the server content. I can
make it work with the non-threaded version of the server, but not the
threaded (preferred) version.
Any assistance would be appreciated.
Les
--
Les Peters, Unix Sys Admin, AOL
------------------------------
Date: Thu, 06 Mar 1997 15:39:01 GMT
From: simberg@interglobal.org (Rand Simberg)
Subject: Re: Stumped by Syntax Error!!!
Message-Id: <331ede43.57382961@nntp.ix.netcom.com>
On 06 Mar 1997 00:31:26 -0800, in a place far, far away, Jeff Coffin
<jcoffin@cs.pdx.edu> made the phosphor on my monitor glow in such a
way as to indicate that:
>>>>>> "Rand" == Rand Simberg <simberg@interglobal.org> writes:
>
>Rand> Can anyone see what's wrong with this piece of code? I pulled
>
>You're gonna hate to hear this, epsecially if you have(n't?) figured
>it out already...
Actually--I'm grateful, if a little abashed...
>
> else { #13
> print WISH "$wishline\n";
> } #13
> } 7# #
>Here ^^
>Should be #7 not 7#, but it's late and I know how you feel.
Ummm..errrrr....actually, I was just throwing out an easy one to give
an opportunity for some to help out who normally can't. Yeah, that's
it...*that's* the story.
(doh!)
Wouldn't you know I'd get tripped up by trying to make my code more
comprehensible? No justice.
Thanx, and the same to all who emailed.
************************************************************************
simberg@interglobal.org * 310 372-7963 (CA) 307 739-1296 (Jackson Hole)
interglobal space lines * 307 733-1391 (Fax) http://www.interglobal.org
"Extraordinary launch vehicles require extraordinary markets..."
------------------------------
Date: 6 Mar 1997 13:35:50 GMT
From: "Dave Roth" <rothd@dnr.state.mi.usX>
Subject: Re: Why the Win32::GD isn't Working?
Message-Id: <01bc2a33$31324cd0$35e118cc@rothd>
duke <duke@uims01.ice.cycu.edu.tw> wrote in article
<331C4FB7.BD9@uims01.ice.cycu.edu.tw>...
> Hi....
>
> I'm trying to use the Win32::GD. I have installed the "GD.PM" and
> "GD.pll".I try to test the GD module.
> So,I do follow instructions.
>
> c:\lang\perl\gd>perl TEST.PL
> Error: Parse exception
> ^^^^^^^^^^^^^^^^^^^^^^
>
> Why??
>
> How do I solve the problem?
> Can you give some option for me?
Quite simple really...
You are using a build of perl that gd.pll was not compiled for. It
currently supports builds 106-110.
If I can find the time I will be compiling for build 303.
dave
------------------------------
Date: 6 Mar 1997 13:52:55 GMT
From: "Dave Roth" <rothd@dnr.state.mi.usX>
Subject: Re: Win32::ODBC INSERT INTO <Access Database> fails,? Read-Only?
Message-Id: <01bc2a35$946595d0$35e118cc@rothd>
Carl <ceklof@vt.edu> wrote in article <331D00E9.475C@vt.edu>...
> I have an M$ Access database that I have been having a good time
> querying through the Win32::ODBC library, quite successfully.
>
> It now comes time to append records to the table. Has ANYONE been
> successful in doing this?
>
> I doing the following SQL statement:
> <code>
> INSERT INTO [MyTable] ( [Date Listed], [Last Name], [First name] )
> SELECT '15-Jan-1997', "Eklof", "Carl";
> </code>
> I have also tried:
> <code>
> INSERT INTO [MyTable] ( [Date Listed], [Last Name], [First name] )
> VALUES ('15-Jan-1997', "Eklof", "Carl")';
> </code>
>
> I have typed these statements into an Access Query and they worked! So,
> these lines should be free of typoes, such as [First name] vs. [First
> Name]. Now, I need them to work from my perl script.
>
> Is there something special that I should be doing because I am modifying
> the table? I am using the same open routines that I used to issue the
> query SQL statment. I only changed the statement to be an INSERT
> operation.
>
First) SQL allows you to have field names with embedded spaces as long as
you use brackets surrounding the field name. Example:
First Name, Last Name <---------Very Very Bad
[First Name], [Last Name] <-----Very Very Good
Second) IF the field [Date Listed] is a timestamp (in Access you only have
timestamps for time/date) then you can not pass it a string like you are
passing it. Access allows you to make it a pretty string but the Access
(Jet) ODBC Driver does not. You need to make it an escaped function:
'15-Jan-1997' <--------------- Very Very Bad
{d '1997-01-02'} <------------ Very Very Good Date
{t '03:45:00'} <-------------- Very Very Good Time
{ts '1997-01-02 03:45:00'} <-- Very Very Good TimeStamp
Third) Use must use the single quotes around stings, NOT THE DOUBLE QUOTES!
SQL only recognizes the single quote as a pre/post deliminator. If you need
to use a single quote as in the contraction "can't" then you MUST escape
the single quote with another single quote so the contraction becomes:
"can''t". Got it?
So... your SQL code should look like:
INSERT INTO [MyTable] ( [Date Listed], [Last Name], [First name]) VALUES
({d '1997-01-15'}, 'Eklof', 'Carl')
Give this a try and good luck,
dave
------------------------------
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 62
************************************