[6355] in Perl-Users-Digest
Perl-Users Digest, Issue: 977 Volume: 7
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 19 22:27:29 1997
Date: Wed, 19 Feb 97 19:01:37 -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 Wed, 19 Feb 1997 Volume: 7 Number: 977
Today's topics:
IN THE ZONE February 1997 - Vol. 2, No. 2 (Steven Katz)
Intrpretor Perl 5 for Win95... <mephisto@qbc.clic.net>
Links Related To comp.lang.perl.misc - FREE ACCESS 0219 links@m2c.com
locking files on the web? <mbuttrum@indiana.edu>
membership... <baskaran@isi.com>
Re: NDBM limitation <merlyn@stonehenge.com>
Re: Newbie ODBC module question <rothd@roth.netX>
Re: Passing command line parameters (Jagadeesh Venugopal)
Re: PERl (via www) Databases from the ground up <marten.mickos@solidtech.com>
Re: Perl Sockets reprise msosteri@yesic.com
postgres95 problems: dynamic pg95perl5 (fish)
Re: Public Domain - Date Graphic Script <jsteven@sirris.com>
Q: Adding method to external class (Kevin Zwack)
Q: format text (Keith Thomas Sherry)
Re: Reference docs for CGI.PM?? <nmljn@wombat.staff.ichange.com>
Re: Regexp to do minimal email validation (Mark-Jason Dominus)
trouble with 'use strict' and 'use Getopt::Long' (Kenneth W. Lee)
Re: Why doesn't gethostbyaddr return a value? <rootbeer@teleport.com>
Why is perl different from perl -w on shebang line? (Todd Lehman)
Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 20 Feb 1997 00:42:27 GMT
From: skatz@waite.mcp.com (Steven Katz)
Subject: IN THE ZONE February 1997 - Vol. 2, No. 2
Message-Id: <5eg6sf$k3q$3@news.iquest.net>
February 1997
Volume 2, No. 2
http://www.waite.com/ezone
This newsletter is (C) 1996, 1997 Waite Group Press. It comes out once
a month.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
CONTENTS
1. Front End: Late breaking news and other cool stuff of interest to
eZone students, by Mike Britten (newsletter editor)
2. FEATURE EXCLUSIVE FOR PERL PROGRAMMERS: Dynamic Web Site Creation,
by Charles K. Reed
3. How do I ... ? Our eZone hackers explore a few different ways to
accomplish the same task
4. Wisdom of the Round Tables (highlights of the eZone discussion
forums):
5. Email to the Editor
6. Books We Love
7. How to Subscribe/Unsubscribe
8. Who We Are
* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
1. FRONT END:
Welcome to the February issue of IN THE ZONE! Each month, this
section will feature interesting items that don't fit neatly into
other categories. We're going to begin with a summary of results from
the first eZone user survey, submitted by our publisher, Mitchell
Waite:
Date of results: 1-9-97
1. Approximately 50% use ezone less than 5 hrs a week.
2. The online text is NOT a critical feature of the eZone.
3. 82% rate the eZone good to excellent.
4. Online testing is the most favorite feature (~70%).
5. The 2nd favorite features are online testing, downloading
certificate, resources.
6. Online book text (typos) least favorite feature, discussion group
2nd least favorite.
7. 36% of current users like look and feel (we are all programmers?)
8. No dominant disliked feature.
9. 40% felt online text needs improvement (typos mostly).
10. 50% wants more sophisticated quizzes and exercises, 38% want some
kind of certification or college credit.
11. Repeats what 10 says but "white board" appears (16%)
12. Not many people dislike banner ads.
13. 78% found mentors good to excellent.
14. 50% could accept, while 50% don't like paying for mentors.
15. 60% bugged or bothered if we got rid of mentors.
17. 89% find book good to excellent.
***
Mitch has also posted these interesting eZone Factoids:
Turns out that 87.6% of the people using the eZone are using
Windows 95. And 87.6% are using Netscape 3.0. Here are the details:
Operating System:
87.6% Windows (includes 3.1, 95, and NT)
7% Unix
4.2% Mac
Windows breakdown
71.1% Win 95
9.6% Win 3.1
6.9% Win NT
Browser:
87.6% Netscape Navigator
8.1% MS Explorer
2.9% AOL
Netscape Browser breakdown
75.6% Nav 3.x
10.3% Nav 2.x
***
Moving right along, the eZone is gaining much deserved recognition
from the industry press. The January 1997 newsstand issue of NetGuide
includes coverage of the eZone in it's hot products section. Netguide
Live (http://www.netguide.com ) also did a four-star "Best of the
Web" review of the eZone. You can find it by searching on the string:
"eZone" at their site.
***
We're happy to report that two web sites dedicated to eZone learning
have recently come on line. Under the direction of Mr. Charles K. Reed,
the Perl 5 Interactive Course discussion group has built a web site.
It includes an archive of their discussions, examples of Perl code,
job listings, book errata, an answer board for their chapter exercises,
and much more. Just as the Perl language is constantly evolving, so
too is their web site. You can join them at
htp://www.netset.com/~gdi/perl/.
Our C++ students also have a web site called the C++ Exercise Page. It
is cosponsored by Waite Group Press. For working answers to the
exercises for the C++ Interactive Course, and to contribute, point
your browser at http://www.oakweb.com/cpp/.
***
And finally this month, for your surfing pleasure, here are a few
resources we hope you enjoy:
-- Web Design & Development '97 is a large conference to be held at
the end of February in San Francisco. They have an innovative web
site. Check it out at http://www.web97.com.
-- Doctor HTML is a Web page analysis tool which retrieves an HTML
page and reports on any problems that it finds. Although they have a
commercial site, this one is free. They're worth a visit. Go to
http://www2.imagiware.com/RxHTML/
-- Borland seems to have another hot development winner on it's hands
with C++ Builder. Available now for download in Beta, it should be
officially released sometime this quarter. Read about it at
http://www.borland.com/bcppbuilder/press/1997/cppbdemo.html
* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2. FEATURE
"Dead or Alive?"
This is the first of a two-part feature about the evolution of a Web
site -- from one that is static in nature to one that is dynamic. In
this context, "dynamic" means that Web pages are created for the
viewer on the fly. To illustrate this, we will discuss the evolution
of the email archiving system on the site I created for the Perl 5
Interactive Course. There is much more at this site than an email
archive, but that is our focus this month.
The idea behind creating an email archive was to give new members of
the discussion list a way to view previously asked questions. As you
will see, the best solution to creating this archive was not the first
solution. There is a saying about programming; you can write code to
perform the same task a hundred different ways. Well, this is real life,
and I've only reached the fourth phase of improving the email archive.
Phase One - Manual HTML design (the old cut and paste method)
Static Web pages may be boring, but they are easy to create. This was
how the email archive started, out of a desire for easy page design
and a lack of time to create a better way to do it.
Every morning, I would open an HTML file called "Todays List" and
paste the HTML code for displaying the days discussions (since they
were now yesterday's discussions) into another file called "This Week".
I would then find all the messages related to Perl that had
accumulated in my mailbox the previous day. Each message would be
placed, with appropriate HTML tags, into the "Todays List" file. I
also had to change any < and > characters to their appropriate HTML
characters, < and >. If it was Monday, I would also save the
"This Week" file into the archives using the name of the week it
represented and add a line to the Archive page to access it.
Does that sound tedious or what! I would spend a good 10 to 30 minutes
every morning doing the email archiving using this method. It got to
the point where I knew there had to be a better way.
Phase Two - Automated HTML design (AppleScripting at its finest)
Automating the creation of the "Todays List" file and the updating of
the "This Week" file was pretty easy. I asked myself, "What tools do I
have to perform this task?" The first that came to mind was
AppleScript -- a powerful shell language that you can use with the
Macintosh Operating System.
The entire explanation of what my AppleScript does is beyond the scope
of this article. Here is a summary: The Script opens a file called
"Todays List" and moves the HTML code for displaying the days
discussions into another file called "This Week". It then opens Eudora,
grabs all the messages in my Perl Discussion List mailbox, and places
them in the "Todays List" file.
Simply running the script does all that automatically. However, I
still had to go in and manually check for < and > characters as well
as fix any other bad HTML code created with unusual characters. Doing
the email archiving now took less time every morning, but after a week
it still seemed like I was doing an awful lot of work. There still had
to be a better way to do it.
Phase Three - Pseudo-Dynamic HTML design (Did someone say Perl?)
OK. By this point you are probably asking yourself, "If he is making
an archive for a Perl discussion list, why doesn't he just write a
program in Perl to do it?" You are exactly right! That is what I
did next. It only made sense. It was also a lot more fun than
writing Apple Scripts!
Here is the Perl code created during this phase with in-depth
explanation. You will notice a lot of comments. These are essential
when you, or someone else, has to modify a program.
#!/usr/bin/perl -w
####################################################################
# emailfilter.pl
####################################################################
# This program will filter incoming email.
####################################################################
# copyright 1996-1997 the GRAPHICS department, inc., Charles K. Reed
####################################################################
The script header has two purposes; to define the path to the Perl
engine and to provide some information about the script. This should
include the program name, an explanation of what the script does, and
copyright information.
# Define Variables
$todayfile = 'YourDirectoryPathHere/thisweek.shtml';
$body = '';
%fields = ();
The definition section of the script has one basic purpose and a
second subtler, but even more important, function. The basic use is to
declare initial values for variables in an easy to read area before
the body of the script. The more subtle function is to allow the
developer to easily modify items that may appear many times throughout
the script, such as filenames. For example, if I had hardcoded the
Today's List filename throughout my script, I would have to go through
it and find and replace every instance of it if it ever changed.
However, as shown above, if the filename ever changes, I only have to
change it in one place. This is more about programming style than a
Perl specific technique, but it is too important not to mention.
############################################################
# Main program code
More comments. By breaking up the code into sections, the script is
easier to read while designing and debugging it. You can almost never
have too many comments. They do not affect the speed of the script
execution in any noticable way.
# get the header data
while (<>)
{
# exit the loop if a blank line is found
last if /^$/;
# split the line into two components
($field, $value) = /^(\S*)\s*(.*)/;
# add the item to the header hash
if (length ($field) > 1)
{
$fields{$field} = $value;
}
else
{
$fields{$field} .= " $value";
}
}
This is the start of the script body. When this script is initiated,
it is fed a stream of data -- an email message consisting of two
parts: the email header and the email body.
The snippet above is a while loop. This will continue until there is
no more data in the input stream, or the 'last' condition is true. The
last condition is looking for a blank line. It does this by using the
match operator // and trying to match the beginning of the line ^ with
the end of the line, $. Since there is no text between the Special
Characters ^ and $, the match is looking for nothing, i.e. a blank
line. If a blank line is encountered, the "last" condition is true,
causing an exit from the loop.
Next, we split the line we just read in into two variables. The match
operator is used again to match a component at the beginning of the
input line, followed by zero or more whitespace characters, followed
by another component. A whitespace character is defined as a space, tab,
or newline. The first component, matches a set of zero or more
non-whitespace characters. The second component matches any character
zero or more times. The parenthesis around the components are important
as they create backreferences. A backreference is a portion of a string
matching a group of characters. These two backreferences get compared
to the two variables on the left side of the equation. As an example, a
line containing "From: gdi@netset.com" would get split into the $field
component "From:" and the $value component "gdi@netset.com."
The reason the input line is split like this is so a hash can be
created from the elements. A hash is a table of data that associates
one scalar value with another. That is what happens next in the code
above. The value of $value is being associated with the value of
$field in the hash %fields.
# get the body data
while (<>)
{
$body .= $_;
}
Once again, a while loop is used to read in lines from the input
stream. This time, each line of input data is appended to the variable
$body. The loop ends when there is no more data in the input stream.
The content of the email body, is now stored in $body.
# set up a filter to automatically generate the Today's List page
if (($fields{'To:'} =~ /wgp-perl50-discussion\@mcp\.com/) ||
($fields{'To:'} =~ /wgp-perl50-discussion\@misl\.mcp\.com/))
{
Now that the email message has been read in, it has to be decided
whether we will act upon this particular message. The 'To:' field of
the header is tested. If it matches the first or second discussion
list address, the body of the 'if' statement is executed. When
matching characters, care has to be taken with Special Characters.
Both '@' and '.' are Special Characters but we want to use their
actual character values. This is accomplished by placing a '\'
character in front of any characters that may be interpreted as a
Special Character.
# set the submission name (first name only) and email address
if ($fields{'From:'} =~ /gdi\@netset\.com/)
{
$name = 'Charles K. Reed';
$email = 'gdi@netset.com';
}
else
{
$fields{'From:'} =~ /^(\S+)/;
$name = $1;
$email = '???';
}
The name and email address of the message sender has to be determined
next. If the name in the value associated with the 'From:' field of
the header matches 'gdi@netset.com' then the sender was me. I don't
mind my full name and email address being displayed so the $name and
$email variables are set to my full name and email address.
If the sender was someone else, we want to protect their privacy and
only use their first name and no email address (for now). The value
associted with the 'From:' field of the header is tested for a match
of one or more non-whitespace characters at the beginning of it. The
parentheses create a backreference which is given to the variable
$name. The $email variable is simply set to '???' for anonymity.
# split the body into seperate lines based on newline characters
(@bodyarray) = split (/\n/, $body);
The body of the email has no use as one long $body variable. The
'split' function breaks up the $body variable into smaller elements
seperated by newlines, \n. These smaller elements are put, without the
newline characters, into an array called @bodyarray.
# trim any garbage (forwarded text) from the start of the body
while (($#bodyarray > 0) &&
(($bodyarray[0] =~ /^\>/) ||
($bodyarray[0] =~ /wrote:/) ||
($bodyarray[0] =~ /-------/) ||
($bodyarray[0] =~ /^$/)))
{
shift (@bodyarray);
}
Now that the body of the email is in a usable form, it needs to be
trimmed of any unnecessary data. I'm making a judgement call and
defining forwarded text at the beginning and end of the email message
as unnecessary since the original message should be stored in the
archive already.
A while loop is used to keep checking the first line of the array. The
loop continues if the last index of bodyarray is greater than 0 and
the first element of the array starts with a greater than character or
matches the text 'wrote:', the text '-------', or a blank line, ^$.
All four of these items are consistent with forwarded text.
If all of the while loop conditions are true, the first element of
the array is removed by the shift function. The while loop terminates
when none of the conditions can be met.
# trim any garbage (forwarded text) from the end of the body
while (($#bodyarray > 0) &&
(($bodyarray[$#bodyarray] =~ /^\>/) ||
($bodyarray[$#bodyarray] =~ /^$/)))
{
pop (@bodyarray);
}
The beginning of the message body was trimmed of forwarded text. Now
we must do the same with the end of the message body.
A while loop is used again to test for more than one element in the
array, and to make sure that the last element of the array begins with
'>' or is a blank line. If the conditions are true, the last element
of the array is removed using the pop function. The while loop
terminates when none of the conditions are met.
The body of the message is now trimmed to contain only the essential
message of the sender and, hopefully, not too much forwarded text.
# open the "Today's List" file
open (FILE, "<$todayfile");
# read the file in to an array
@filearray = <>;
# close the file
close (FILE);
The next step is to retrieve the "Today's List" HTML page so that the
new email message can be inserted into it. The "Today's List" file is
opened for reading, <, with the 'open' function. For efficiency, the
entire file is read, <>, and placed into the @filearray file. The file
is then closed using the 'close' function.
# open the "Today's List" file again, but for writing
open (FILE, ">$todayfile");
# lock the file before we use it, to avoid data conflict
flock (FILE, 2);
The "Today's List" file is opened again, but this time it is opened
for writing. Since the file is being written to, it needs to be locked
so that no one else will write to it at the same time we are. This is
done by using the flock function with a setting of 2, which sets the
file exclusively as ours.
# write to the file until the "insert here" tag is found
$x = 0;
while (($filearray[$x] !~ /<!--insert here (\d+)-->/) &&
($x <= $#filearray))
{
print FILE $filearray[$x++];
}
Inside the "Today's List" file there is an HTML comment tag set at the
beginning of each day to look like this: <!--insert here 1-->. This
is the position in the file where new discussion list messages are to
be placed. Therefore, the file can be rewritten as it was up to that
point.
A while loop is executed and it loops until a line is found containing
the "insert here" tag or until there are no more lines left. Notice
that when the tag is found, a backreference is created containing a
series of one or more digits. Each successfull iteration of the loop
causes the particular tested line to be written to the file using the
print command. The line number is incremented within the print
function.
# write the new mail message to the file
if ($x <= $#filearray)
{
# increment the message number
$y = $1 + 1;
print FILE "<BR><B>$y- $name ($email)</B>";
print FILE "<I>$fields{'Subject:'}</I><BR>\n";
print FILE "<BR><PRE>";
foreach $line (@bodyarray)
{
# fix any < and > characters
$line =~ s/</</g;
$line =~ s/>/>/g;
print FILE "$line"\n";
}
print FILE "</PRE>\n";
# set the new message number in the comment tag
$filearray[$x] = "<!--insert here $y-->\n";
}
If the previous while loop ended before reaching the end of the file,
the point where the new discussion message needs to be inserted has
been reached.
The backreferenced series of digits which represents the current
message number is saved into a variable, $y. If we are to add a new
message, the message count variable is incremented by 1. The message
starts to take shape as it is printed to the "Today's List" file
including the message number, the sender's name, their email address,
and the value associated with the 'Subject:' field of the header. The
body of the message is written within HTML <PRE> tags to make it
appear exactly as it was when it was sent via email.
Each line of the body is checked for < and > characters. If there are
any, '<' and '>' are respectively substituted for them using the
substitution operator in a global sense, s///g. The line containing
the "insert here" tag is modified to eflect the incrmented message
number.
# write any trailing lines back to the file
while ($x <= $#filearray)
{
print FILE $filearray[$x++];
}
The rest of the "Today's List" file needs to be written back to the
file. This is accomplished with yet another while loop which executes
until the end of the @filearray array is reached. Each successful
execution of the loop writes the respective line back to the "Today's
List" file.
# unlock the file after we use it
flock (FILE, 8);
# close the file
close (FILE);
}
Now that everything has been written into the "Today's List" file, it
needs to be unlocked and closed. The unlocking is done using the
'flock' function again but with a setting of 8, which removes the lock
previosuly placed on the file. The 'close' function is used again to
close the file.
# end program
exit;
It is time for the program to end. A simple exit command is executed
and the script ends.
And that is the end of the script! However, there is still one more
thing to do in order to make the script run. After creating the email
filter, I had to tell the operating system what Perl script to run
when I received new mail. On a Unix platform, this involves the
creation of a file called .forward in your personal root directory.
This simple one line file contains the following line:
\YourLoginNameHere, "|/PathToThePerlScript/emailfilter.pl"
Once the Perl script and the .forward files are up on the server, all
new email you receive will be filtered. If you ever need to add
another filter for any reason, such as joining a new discussion list
and needing new archive files made, it is easy to add a new module
inside the Perl email-filter script you have already written.
Next Month - Phase Four ("A Hands-Off Approach to HTML Viewing")
Next month I will discuss the final phase of the Perl email archiving
system. Portions of the Perl code to do this will be discussed in
depth.
_______________
Charles K. Reed is the Ohio Regional Director for The Graphics
Department Inc., a leading Web site development company in the midwest.
He has been writing code in multiple computer programming languages for
over 10 years.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3. HOW TO ...
Each month, this section of IN THE ZONE will tell you how to do...
well, most anything, as long as it's something to do with a computer.
Tips come from Waite Group Press' popular series of How-To books, or
may be specially written for IN THE ZONE. This month our submissions
come from our Perl discussion group.
But even if Perl is not your language of choice, "hacking", or getting
your code to accomplish a particular task in the fastest way possible
using the fewest lines of code, is a mindset we all can appreciate.
We start out with this enthusiastic message from Ken Trenkelbach
(a.k.a. "Agony"):
***
Ok, I'm all worked up because today I made my first practical script.
It's fairly small, so I'm going to present it to you guys and girls
for criticism. I work for an ISP, and customers who upload files for
personal web pages for the first time often ask for help changing all
of the .htm files to .html. Also, often the files are upper case when
their references to them in the actual documents are lower case. So I
made this script to run, which takes an entire directory, and
lower-cases everything, and appends an 'l' to every .htm document.
Tear it up!
#!/usr/local/bin/perl5
chdir($_);
opendir(DIR,$_) or die; ####
@af=readdir(DIR); #open dir and assign contents to @af
closedir(DIR); ####
foreach $af(@af) {
$tf=$af; #make temp variable
if ($af=~(/\L\w+\E/)){$tf=~(tr/A-Z/a-z/);} #lowercase everything
if ($tf=~(/.htm$/)){$tf .=l;} #add an 'l' if .htm
next if $tf eq $af; #go to next if no changes made
`mv $af $tf`; #rename old file to new file
}
If anyone has any advice for making it smaller or faster, please let
me know.
***
Douglas J. Davenport replies:
Change the body of the foreach loop to:
.. {
my $tf = lc $af; # lower case and copy to temp
$tf .= 'l' if $tf =~ /\.htm$/ ; # .htm => .html
rename $af, $tf if $af ne $tf ; # rename file as needed
}
The above is the first thing that comes to mind. I believe that
further improvements are possible.
***
To which Mitchell Waite asks:
Douglas Davenport can you say why your version is faster than Agony's?
***
Douglas responds to Mitchell's query:
- The conversion to lowercase uses the built-in function 'lc',
built-ins are almost always faster.
- merged the local copy creation with the lc operation, probably
no speed gain here.
- changed the RE /.htm$/ to /\.htm$/, this changes the '.' from
a match-anything wildcard character to a literal. Subsequently
Perl performs a faster internal string search.
- Removed a process spawn by changing the `mv ...` to the
rename() built-in. This is probably the biggest time saver of
those I suggested.
***
Charles K. Reed offers this in response to Agony's original message:
This is probably one of the more practical scripts I have seen. Our
ISP in Michigan has similar scripts available to the users. One of
the best is a permission changing script so that when they upload
files they can change the permissions automatically to 755 just by
typing a program name at the Telnet command line rather than having to
know about UNIX permissions.
Anyway...I saw that David had a few improvements for you and I can
think of another improvement. Instead of doing an opendir, and then
a readdir and then a closedir (three spawned commands), you can simply
do a glob. This automatically performs directory opening and closing
behind the scenes, saving valuable system resources and time.
Example (instead of opendir/readidr/closedir):
@af = glob('*');
You also made a note that it was not working properly. I have a few
suggestions for that also. The program looks like it is expecting a
FULL path name upon entry into the program. Are you providing a full
path name? How and WHERE do you run this script? Do you run it from
the directory where it is supposed to be changing the files? If this
is a script for users to run and they run it from their root directory
a suggestion might be to change your chdir($_); command to simply
chdir;. This will reset the directory handle to be at the user's
root. Otherwise, if you run it for multiple dirs, remember to use a
full path name when you call the script. If the script is called
'ChuckScript' and you want to modify the contents of directory
'/users/c/chuckdir' then you would invoke the program, as written,
like this:
ChuckScript /users/c/chuckdir/
I am sure you have already thought of this, but if not, then I hope it helps.
***
Douglas Davenport again:
I would have to disagree with the above paragraph. Globs
(either glob('*') or <*>) spawn a process, whereas
opendir/readdir/closedir are syscalls (library routines that are
performed by the OS in the calling process's context).
I ran a few tests and found under Linux and SunOS 4.1 and found
opendir/readdir/closedir to be two to three times faster.
Also in the book "Programming Perl" 2nd Edition, by Larry Wall, Tom
Christiansen & Randal L. Schwartz in the section of Time Efficency
(in ch. 8) readdir is recommended over globs.
***
Charles Reed wraps up the thread with this:
In our Perl book it states on page 177 "but glob() is faster and
safer".
If I misread it or I am wrong, I apologize for giving false advice.
You also bring up thoughtful advice that should answer Agony's
original question of what to do for speed. The answer...try coding
your script a few different ways and benchmark it. There are hundreds
of different ways to do the same script in Perl so benchmarking is a
good idea if you have a question of which way is most
time-conservative.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
4. Wisdom of the Round Tables
Each month, IN THE ZONE will quote comments of general interest that
appeared on one of the discussion lists. (If you aren't already a
member of one of these round tables, see "How to Join" at the end of
this section.) If your comment gets quoted, you'll get a free copy of
any two of our books!
This month's message thread arose from an innocent and enthusiastic
question posted by one of our youngest students (age 16):
***
I'm new to C++(only one other book under my belt) and am really
enjoying this book so far. In your opinion, when someone finishes this
book, could they call them selves a good C++ Object-Oriented
Programmer?
Thanks a lot
Justin
***
This response, from Rob Andrews, raises several interesting points:
Hi Justin,
In MY opinion, just because you read a book and have completed all the
exercises and quizzes, you still don't qualify as a C++ Object
Oriented Programmer. By using this book, you are well on your way
towards being a C++ programmer, but are missing the Object Oriented
part.
Let me explain. There are two parts to your statement. C++
Programmer: My feelings are, no matter how well you've done on the
example exercises and the quizzes, you still haven't written anything
'in anger'. This means you haven't created any kind of workable
application, from scratch, by yourself. Write several of those, and
you'll be amazed at how much you've missed in the text. Concepts you
thought you understood will confuse you when you start implementing
them. What you've just learned is how to swing a hammer. Now you
need to practice hammering things, as well as the proper places to
use the hammer (c++) vs. a screwdriver (a different language that might
be better suited towards the job at hand)
Object Oriented Programmer: So far, I haven't seen anything in the book
(having skimmed through the remainder of it also) that shows you
ANYTHING about Object Oriented analysis and design. If you don't
understand the analysis and design philosophy of OO, all your going to
be doing is writing C or VB or COBOL or whatever programs in C++. You
won't be able to truly take advantage of the benefits of objects stuff
is different. Just trying to figure out what objects you need, much
less their attributes and methods are, is a whole different art.
Rob
***
Without missing a beat, Mitchell Waite offers his view:
If you really want to get your anger up I believe the exercises in the
C++ book will do that job :) Its true that Lafore's book is not an OOP
design book (anyone think they can write one for us please email me).
However, I do think that if you finish his book you will have gone a
long distance to understanding many of the concepts, tradeoffs, and
kind of thinking that is required to utilize OOP.
Mitch
***
When you're ready to tackle more advanced texts on the subject,
Jacques Doyon provides these resources:
May I suggest two good books where the way to think OO is well
explained. Of course, this is not real experience but I guess it can
help to tackle your first mission.
They are:
G. Booch, Object-Oriented Analysis & Design (Second Edition) Benjamin-Cummins
1994
This one is particularly good because it analyses very different
problems and shows how OO can be put to work.
J. Rambaugh, M. Blaha, W. Premerlani, F. Eddy, W. Lorensen
Obejct-Oriented Modeling and Design, Prentice-Hall 1991
-
How to Join a Discussion List:
You must be a registered eZone user to join a discussion list. Once
you have registered for a course, enter the eZone and go to the Chill
Zone. You can get to the Chill Zone by clicking on the torch in the
frame on the left or choosing the word CHILL from the bottom of the
page. On the Chill Zone page, select your course, then click the
Discussion List link. You'll see a page that permits you to subscribe
to the discussion list related to your course.
How to Unsubscribe: No longer want to be a part of the round table?
Simply repeat the above steps and click the link labeled "Unsubscribe."
If you want to be a part of the round table discussion, but don't want
its messages to be mixed up with your personal e-mail, use your e-mail
client's filtering abilities to move messages you receive from the
discussion server (misl.mcp.com) to a dedicated folder automatically.
(The instructions for doing this vary according to your e-mail client,
which will need to be a full-featured program such as Eudora Pro or
Claris Emailer.)
* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
5. Email to the Editor
This is where you can put in your 2 cents. We welcome (and retain the
right to publish, or not to publish) any and all comments. Please send
email to us by clicking "Webmaster" on the eZone main page. Make sure
you start your message with the text "Letter to the Editor" so we know
you want to be published. Look for actual letters in the March issue
of IN THE ZONE.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
6. NEW BOOKS WE LOVE
This section contains a list of current books that we think you might
want to check out. You can order any of them directly by going to the
Macmillan Publishing Web site at http://www.mcp.com and clicking the
Bookstore link. Or, just call the Macmillan order line at
(800) 716-0044.
WEB DATABASE CONSTRUCTION KIT
Imprint: Waite Group Press
Author: Gunnit S. Khurana, Balbir S. Khurana
ISBN: 1-57169-032-8
Retail Price: $49.99 US
Looking for the quick and easy way to create an organized database
and interface for the Web? Need superior know-how so you can support
HTML forms, manage databases with Microsoft Access, and implement the
Windows CGI standard through Visual Basic? If so, look no further
than Web Database Construction Kit.
With tip's, tricks, and instructions that'll take you from ground zero
to advanced database creation and management in no-time flat, Web
Database Construction Kit is the definitive step-by-step manual to all
the tools and information you'll need to construct powerful databases
and publish them over the Web.
Whether you're a Web developer wondering where to start, a Perl
programmer looking for a simpler approach, or a Microsoft Access
programmer interested in the Web gateway, you'll combine the diverse,
finicky elements of Web database publishing and launch your own
practical, Web-based applications.
With Web Database Construction Kit you will:
Create exciting Web database publishing projects including an on-line
book ordering system.
Learn how to develop Windows CGI applications with Microsoft's Visual
Basic, Access 95, and other Web tools.
Make dynamic HTML forms that allow you to search and maintain
databases over the Web.
Understand database and query design in Microsoft Access.
Discover how to use advanced techniques such as multi-user database
connections, dynamic form generation, and security to enhance your Web
site.
ACTIVEX PROGRAMMING UNLEASHED, SECOND EDITION
Imprint: SAMS.NET
Author: Weiying Chen, et al.
ISBN: 1-57521-154-8
Retail Price: $39.99 US
TIMELY SOLUTIONS
Use ActiveX controls to create active elements in a Web page.
Integrate OLE scripting within your Web pages.
Create COM objects.
Build OLE custom controls and an OLE control container.
Program an OLE automation server.
Use Microsoft Internet Explorer Object Model for Scripting.
Develop interactive databases with VBScript.
Integrate VBScript and Visual J++ within an HTML document.
Add hyperlink navigation to your Web page.
Master WinCGI programming.
Convert CGI script to the faster, more powerful ISAPI standard.
Connect various databases on the Web using the ISAPI Internet database
connector.
Embed ActiveVRML files within your Web page.
7. How to Subscribe/Unsubscribe to IN THE ZONE
How to Subscribe: You must be a registered eZone user to subscribe to
the newsletter. Once you have enrolled in a course, enter the eZone
and go to the Chill Zone. You can get to the Chill Zone by clicking
the Torch in the navigation frame (on the left) or choosing the word
CHILL from the bottom of the page. In the Chill Zone, select your
course, then select the Newsletter link and click Subscribe. You'll be
on the mailing list for IN THE ZONE, this monthly newsletter.
How to Unsubscribe: No longer want to receive IN THE ZONE? Enter the
Chill Zone and choose your course. Select the Newsletter link and
click Unsubscribe. Your address will be removed from the mailing list.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
8. Who We Are
Waite Group Press, based in Corte Madera, CA, is a publisher of
high-quality books on computer programming and emerging technologies.
The eZone is an innovative approach to online education, offering
courses in scripting and programming languages. Current courses
include: Perl 5, HTML 3, C++, Java, JavaScript, and Visual Basic
Scripting Edition. Coming soon: Office 97, Visual Basic 5, and ActiveX
Scripting.
* * * * * * * * * * * * * * * * * * * * * * * * * * * *
------------------------------
Date: 20 Feb 1997 01:43:23 GMT
From: "Mario Carrier" <mephisto@qbc.clic.net>
Subject: Intrpretor Perl 5 for Win95...
Message-Id: <01bc1ecf$5d9460c0$70fa13cc@mephisto.ppp.qbc.clic.net>
May have an interpretor Perl 5 for Win95. Where?
Is it possible to execute Perl scrips with
Microsoft Personnal Web Server. Where get it and how install it?
Thanks.
----------------------------
J'aimerais savoir si l'on peut aller chercher un interpriteur Perl 5 pour
Windows 95 et si l'on peut y exicuter des scripts en Perl avec le Serveur
personnel Web de Microsoft. Si oui, j'aimerais savoir oy pouvoir aller
chercher cet interpriteur et comment l'installer.
Merci.
------------------------------
Date: Wed, 19 Feb 97 21:55:37 GMT
From: links@m2c.com
Subject: Links Related To comp.lang.perl.misc - FREE ACCESS 0219
Message-Id: <5eft3d$s9o@nicaragua.earthlink.net>
For Free Access To Links Related To comp.lang.perl.misc Set Your Web Browser
To:
http://www.m2c.com/links/compute.htm
Courtesy Of Surfing Links By M2C
-----------------------------
Sponsored by Robo Surfer - Your Own Personal Internet Robot
Download Your Free Demo Today!
http://www.robosurfer.com
------------------------------
Date: Wed, 19 Feb 1997 15:50:46 -0500
From: Melissa Ann Buttrum <mbuttrum@indiana.edu>
Subject: locking files on the web?
Message-Id: <330B67A6.15A0@indiana.edu>
I'm writing a program which does the following
open (FILE, $database) or die "";
flock (FILE, 2);
@data = <FILE>;
# flock (FILE, 8);
# close (FILE);
&modify_data_based_on_html_form_input;
if ($need_to_rewrite_data eq "true"){
open (FILE, ">" . $database) or die "";
flock (FILE, 2);
print FILE @database;
flock (FILE, 8);
close (FILE);
}
if ($simply_need_to_append eq "true"){
open (FILE, ">>" . $database) or die "";
flock (FILE, 2);
print FILE @newstuff;
flock (FILE, 8);
close (FILE);
}
##################end of script#############
If four or five people were to submit at the same
time, some requiring appends and some requiring
rewrites, would the above script allow ANY
possibility of data loss? the man page for flock
says that flocks from different clients don't
communicate with each other. Does this mean that
people surfing my web page are different clients
whose flocks can't communicate with each other? Is
there any way around this?
Do I need a seek statement? if so, how do it do it?
What if one of the process' @newstuff or @database
is so long that during the rewrite or append
operation, another process(call it # 2) could
attempt to read the FILE. Would that process #2 (a
duplicate of the above script) WAIT AROUND for #1
to finish or would I need to add some more code to
the script?
What code should I add to make process #2 wait for
#1 to finish?
andy rumelt
arumelt@indiana.edu
------------------------------
Date: Wed, 19 Feb 1997 15:23:38 -0800
From: Baskaran Tranquebar <baskaran@isi.com>
To: comp.lang.perl.misc
Subject: membership...
Message-Id: <330B8B7A.167EB0E7@isi.com>
Hi ..
I would like to enroll myself in this news group. May I ask for your
advise in how should I do that?.
Thanks in advance.
Baskaran Tranquebar.
------------------------------
Date: 19 Feb 1997 16:01:16 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: dgl@offis.lu
Subject: Re: NDBM limitation
Message-Id: <8cvi7o5rk3.fsf@gadget.cscaper.com>
>>>>> "David" == David Gallone <dgl@offis.lu> writes:
David> Hi,
David> Here is an extract from NDBM man pages (on SINIX).
>> The sum of the sizes of a key/content pair must not exceed the
>> internal block size (currently 4096 bytes). Moreover all key/content
>> pairs that hash together must fit on a single block. dbm_store will
>> return an error in the event that a disk block fills with inseparable
>> data.
David> This seems to be a very hard constraint making NDBM of little use for
David> real applications.
David> Is there a work around ?
Yes. Use something else. Something incompatible with NDBM. :-)
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 558 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: 19 Feb 1997 21:22:16 GMT
From: "Roth Consulting" <rothd@roth.netX>
Subject: Re: Newbie ODBC module question
Message-Id: <01bc1eaa$92db4b10$0100a8c0@www>
OHarra, John <john.oharra@transquest.com> wrote in article
<330B5D7A.6608@transquest.com>...
> I installed the ODBC module per the instructions, downloaded the new
> ODBC drivers from Microsoft and the latest version of PERL, and when I
> run the TEST.PL script, I get the following error:
>
> Error: Parse exception
>
> Where did I go wrong?
You are using a build of perl that is not supported by the extention
you installed.
The latest win32::odbc (v970208) has two odbc.pll files, one for
perl builds 106-110 and build 303. Check which build you have
with:
perl -v
dave
--
================================================================
Dave Roth ...glittering prizes and
Roth Consulting endless compromises, shatter
rothd@roth.net the illusion of integrity
My email address is disguised to fool automailers. Remove the
trailing 'X' to send me email.
****************************************************************
Use of this message or email address for commercial purposes
(including "junk" mailings) is strictly prohibited and protected
under current international copyright laws and United States
Code, Title 47, Chapter 5, Subchapter II.
------------------------------
Date: 19 Feb 1997 22:11:15 GMT
From: jvenu@ctp.com (Jagadeesh Venugopal)
Subject: Re: Passing command line parameters
Message-Id: <5eftq3$t7j@concorde.ctp.com>
In article <Pine.LNX.3.95.970219122727.4676B-100000@wauug.erols.com> Joe Tseng <jtseng@wauug.erols.com> writes:
>I checked with my blue camel book but I could not find the answer.
>
>script directly on the command line. Right now I have parameters being
>passed as:
> $foo = <STDIN>;
>
Maybe your Camel is missing Page 445, Getopt::Long?
--
/\/\ |Jagadeesh K. Venugopal, jvenu@ctp.com |http://w3.ctp.com/~jvenu
/ /_.\|Cambridge Technology Partners, Inc. |http://www.ccs.neu.edu/home/jkvg
\ /./|304 Vassar St. Cambridge, MA 02139 |
\/\/ |Phone: 617.374.2028 FAX: 617.374.8300 +
------------------------------
Date: Wed, 19 Feb 1997 23:45:25 +0200
From: Marten Mickos <marten.mickos@solidtech.com>
Subject: Re: PERl (via www) Databases from the ground up
Message-Id: <330B7475.3E4A@solidtech.com>
Aveek Datta wrote:
<snip>
> Hence I'm
> looking for a simple, easy, and free relational database that I can use
> to maintain a database that will be accessed primarily through a Web
> based interface.
Try out SOLID Server at http://www.solidtech.com
Keywords: SQL-compliant, multiplatform, carefree.
Marten Mickos
Solid Information Technology Ltd
------------------------------
Date: Wed, 19 Feb 1997 19:02:47 -0600
From: msosteri@yesic.com
Subject: Re: Perl Sockets reprise
Message-Id: <856399272.7057@dejanews.com>
In article ,
tom@palver.nospam.eiscat.no (Tom Grydeland) wrote:
>
>
> From the pink camel, p.174 or the blue camel, p.211:
Bizarre, obscure AND NITPICKY, in my "RED" Camel the select Function
is on page 177.
>
> select((select(STDERR), $|=1)[0])
I think I got it. This cryptic incantation "selects" STDERR, gives PERL
control over output buffering and then "selects" the previous filehandle
(whatever that was) via the return value of the inner select. But select
returns the previously selected filehandle as a scalar? Why the array
offset [0]?
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 20 Feb 1997 00:25:19 GMT
From: gis84514@cis.nctu.edu.tw (fish)
Subject: postgres95 problems: dynamic pg95perl5
Message-Id: <5eg5lf$aa8@news.cis.nctu.edu.tw>
I want to use pg95perl5 to access the database,
Since I have already installed perl5, I want it to be dynamic loaded.
However, I can't find libpq.so.1 in the postgres95/lib!!
Only libpq.a there!
So..where can I find a libpq.so.1 or how to create it??
Thanks a lot for your help....
------------------------------
Date: Wed, 19 Feb 1997 14:15:57 -0800
From: "James Steven" <jsteven@sirris.com>
Subject: Re: Public Domain - Date Graphic Script
Message-Id: <jsteven-1902971415570001@blv-pm103-ip16.halcyon.com>
In article <330abca7.3036705@news.eunet.no>, sajaa@sn.no (Jarle Aasland)
wrote:
<I am new to perl also, and I'm curious: How do you call the script
<from the web-page, and how do you get the output from the script into
<the page. Are you using Server Side Include or some other method?
I use server side includes, files like index.shtml. I call like so:
<!--#exec cgi="cgi-bin/dategraph.pl"-->
Thx!
JS
------------------------------
Date: Wed, 19 Feb 1997 22:49:54 GMT
From: kevinz@stortek.com (Kevin Zwack)
Subject: Q: Adding method to external class
Message-Id: <E5vGr6.FGK@gazette.stortek.com>
I've reread chapter 5 and still and figure out if/how I can do this.
I want to implement an additional method (as opposed to overriding) an
existing class/module.
For example:
#!/usr/local/perl
use Stuff;
my $thing = Stuff->new(); # New is already implemented in Stuff
$thing->foo; # Foo is my own method
exit;
sub foo {
...
};
__END__
How can I make foo a method of Stuff? (Without changing Stuff.pm?)
Thanks in advance,
Kevin Zwack
Boulder, CO
------------------------------
Date: 20 Feb 1997 01:28:24 GMT
From: ktsherry@nntp.best.com (Keith Thomas Sherry)
Subject: Q: format text
Message-Id: <5eg9bo$i4f$1@nntp2.ba.best.com>
To all,
I am stumped, bewildered and perplexed...so please help.
I have looked at Text::Wrap as a possible solution to my
formatting problem, but this module grabs everything. So, if I have a
list, for example:
dog
cat
bird
pig
this also gets absorbed into the formatting causing the "list" to become
part of the paragraph. How can I format the text correctly?
Tidbit:
The text is being passed to a cgi from a FORM which contains text
boxes (using the <TEXTAREA> tags). For example:
use CGI;
$query=new CGI;
$text = $query->param('text');
At this point format the text so that no line is greater than 80 chars.
--
Keith T. Sherry
------------------------------
Date: 19 Feb 1997 18:47:35 -0500
From: nelson <nmljn@wombat.staff.ichange.com>
Subject: Re: Reference docs for CGI.PM??
Message-Id: <w10pvxw9x48.fsf@wombat.staff.ichange.com>
"Stephen K. Bohler" <skbohler@ix.netcom.com> writes:
> I was wondering if anyone knew where I can find a rather exhaustive
> reference guide on all of the available functions available in CGI.pm?
I've found the embedded documentation to be very helpful. Using the
pod2text program that comes with every perl distribution, type:
pod2text /your/path/to/CGI.pm
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: 19 Feb 1997 23:24:34 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Regexp to do minimal email validation
Message-Id: <5eg23i$20l@picasso.op.net>
Keywords: Heckman Weston chrysanthemum tubule
In article <8clo8pmtjx.fsf@gadget.cscaper.com>,
Randal Schwartz <merlyn@stonehenge.com> wrote:
><fred&barney@stonehenge.com> is a valid address, Really. Go ahead
>and send to it... you'll get an autoreply. (I just set that up
Randal is not just being perverse here. Two of the pople in my
fantasy baseball league have an email address that contains an
ampersand, so this sort of thing really does come up naturally.
--
mjd@pobox.com Mark-Jason Dominus
mjd@plover.com Plover Systems, Philadelphia, PA
------------------------------
Date: 19 Feb 1997 20:05:29 -0500
From: kenlee@congo.morgan.com (Kenneth W. Lee)
Subject: trouble with 'use strict' and 'use Getopt::Long'
Message-Id: <kenlee.856400708@congo>
Hi,
I've checked the man pages, the pink perl book, and the big
How-To book but I'm still having difficulty with 'use strict'
and 'use Getopt::Long' together. I'm using an unix xterm under
SunOS 4.1.3. The following code is taken directly from page 59
of the big How-To book, withe the added 'use strict' of course.
--- CUT HERE ---
#!/usr/local/bin/perl5
use strict;
use Getopt::Long;
$Getopt::Long::autoabbrev = 0;
# Main
{
my @optl = ("loglevel:i","file=s","trace!");
die "Usage. $0 [-loglevel[<int>][-file <name>][-[no]trace]\n"
unless GetOptions @optl;
print "Trace active\n"
if $opt_trace;
print "No Trace\n"
unless $opt_trace;
print "Log file is $opt_file\n"
if $opt_file;
print "Loglevel value $opt_loglevel\n"
if $opt_loglevel > 0;
}
--- CUT HERE ---
I keep getting the following error:
congo kenlee $ foobar3.pl
Global symbol "opt_trace" requires explicit package name at foobar3.pl line 16.
Global symbol "opt_trace" requires explicit package name at foobar3.pl line 18.
Global symbol "opt_file" requires explicit package name at foobar3.pl line 19.
Global symbol "opt_file" requires explicit package name at foobar3.pl line 20.
Global symbol "opt_loglevel" requires explicit package name at foobar3.pl line 21.
Global symbol "opt_loglevel" requires explicit package name at foobar3.pl line 22.
Execution of foobar3.pl aborted due to compilation errors.
congo kenlee $
Does anyone know of a fix for this problem? (I think it's a problem
with the my() and/or (de)referencing.
Thanks,
--
Ken
--
------------------------------
Date: Wed, 19 Feb 1997 18:51:54 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Matti Hultstrand <matti-hu@dsv.su.se>
Subject: Re: Why doesn't gethostbyaddr return a value?
Message-Id: <Pine.GSO.3.95q.970219184244.18400K-100000@kelly.teleport.com>
On Wed, 19 Feb 1997, Matti Hultstrand wrote:
> But the simple script below doesn=B4t print anything.
>=20
> #!/usr/local/bin/perl
> $hostname =3D gethostbyaddr("199.45.129.30", AF_INET);
> print "$hostname\n";
And it's not going to until you fix it. :-) The two problems are embodied
in the parameters to gethostbyaddr. The first one is not supposed to be
text, but a packed network address. The second one is a constant, but
you've never defined it!=20
The easiest way to use these is with the Socket module, and the manpage
for that module should appear if you use the magic spell 'perldoc Socket'.
Hope this helps!
#!/usr/bin/perl -w
use Socket;
$hostname =3D gethostbyaddr(inet_aton("199.45.129.30"), AF_INET);
print "$hostname\n";
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 20 Feb 1997 01:15:21 GMT
From: lehman@visi.com (Todd Lehman)
Subject: Why is perl different from perl -w on shebang line?
Message-Id: <5eg8j9$erl$1@darla.visi.com>
Here's a weird Perl/Unix question. I want to invoke a perl script add.pl
on the shebang line and feed the rest of the script not to perl but to
add.pl. This works when my shebang line is
#!/bin/perl add.pl
but not when it is
#!/bin/perl -w add.pl
Here's what happens. I have a file addtest1 that looks like this:
--------begin addtest1--------
#!/bin/perl add.pl
1
2
3
4
5
--------end addtest1--------
This file is chmod 700. When I run it, it produces:
--------begin output--------
Total = 15
--------end output
I have a second file addtest2 that looks like this (same but with -w):
--------begin addtest2--------
#!/bin/perl -w add.pl
1
2
3
4
5
--------end addtest2--------
This file is also chmod 700. When I run it, it produces:
--------begin output--------
Number found where operator expected at addtest2 line 3, near "2"
(Missing semicolon on previous line?)
syntax error at addtest2 line 3, near "2"
Number found where operator expected at addtest2 line 4, near "3"
(Missing semicolon on previous line?)
Number found where operator expected at addtest2 line 5, near "4"
(Missing semicolon on previous line?)
Number found where operator expected at addtest2 line 6, near "5"
(Missing semicolon on previous line?)
Execution of addtest2 aborted due to compilation errors.
--------end output--------
Obviously perl is loading and interpreting addtest2 and ignoring
add.pl. Why is this? Is there any way around it?
I don't see anything in the sh manpages or in Kernighan & Pike or in the
Perl FAQs on this.
My add.pl file, for completeness (although it's really pretty irrelevant
to this problem, I think):
--------begin add.pl--------
use strict;
my $total = 0;
<>; # throw out shebang line
while (<>) { $total += $_; }
print "Total = $total\n";
--------end add.pl--------
--Todd Lehman
p.s. No, my ultimate goal is not to be able to total numbers (heh). The
number totalling script is just a way to distill the issue.
------------------------------
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 977
*************************************