[12159] in Perl-Users-Digest
Perl-Users Digest, Issue: 5759 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 23 19:07:21 1999
Date: Sun, 23 May 99 16:00:18 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 23 May 1999 Volume: 8 Number: 5759
Today's topics:
Checking URL's for 404 Errors in Perl CGI <webmaster@*nospam*mugomilk.freeserve.co.uk>
chmod in Perl Scripts? (MAXRIVERS)
Re: Creating index from html code (long) <cassell@mail.cor.epa.gov>
Re: date conversion and comparison routines (Kai Henningsen)
Re: date conversion and comparison routines <rra@stanford.edu>
Re: Don't understand ctime / stat[10] <cassell@mail.cor.epa.gov>
Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe (Ilya Zakharevich)
Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe (Ilya Zakharevich)
Re: Help with challenge script <cassell@mail.cor.epa.gov>
In favor of extending "my" to apply to subroutines as w <elliotsl@mindspring.com>
Re: Mac-specific Perl help requested - The Answer (foll <josh@bitwell.net>
Re: Mac-specific Perl help requested - The Answer (Chris Nandor)
Re: Need Perl interpreter <cassell@mail.cor.epa.gov>
Re: No answer found in Perlfaq <cassell@mail.cor.epa.gov>
Object Copy constructor? <xrxoxtxhxdx@xrxoxtxhx.xnxextx>
Re: Object Copy constructor? <brad@wcubed.net>
Re: perl for parsing the CBOE options quote pages <cassell@mail.cor.epa.gov>
Re: Perl on Win32 - How can I hide the process? <perin@panix7.panix.com>
Re: Perl Tutorials <camerond@mail.uca.edu>
Re: Question. <cassell@mail.cor.epa.gov>
Storing GD::Image <brad@wcubed.net>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 23 May 1999 20:25:00 +0100
From: "Mug-O-Milk" <webmaster@*nospam*mugomilk.freeserve.co.uk>
Subject: Checking URL's for 404 Errors in Perl CGI
Message-Id: <7i9ks9$92l$1@news4.svr.pol.co.uk>
I've been recently creating a search engine for my own amusement, and also
partly a university assignment, the script has been on the internet for a
few weeks and has over 130 sites listed, now my problem is, I am having
difficulties in maintaining the database -- I can't paste a snippet into
this post, as the formatting will be ruined. Instead, I have chmodded the
file so that anyone can read it. It's at
http://mugomilk.hypermart.net/cgi-bin/data.txt
Basically it's a text file, with the fields separated by a pipe " | ".
Each Record is separated by the Carriage Return character.
What would the code I would need to scan the database for the URL's, and
visit each one in turn to check that the URL is valid - (i.e. not returning
a Error 404, File Not Found) and, subsequently remove the line from the
database and append it to a "kick list" file which would store all the lines
that have invalid / broken URL's?
I'm semi-new to Perl, so any advice whatsoever is greatly appreciated,
although I cannot find anything in the wonderful Camel book that could give
me a pointer into the direction I need to head.
Thanks in Advance!
=========================
"How does the man that drives the snowplough get to work in the morning"
@mugomilk, the UK Internet Guide - http://www.mugomilk.freeserve.co.uk
------------------------------
Date: 23 May 1999 22:05:14 GMT
From: maxrivers@aol.com (MAXRIVERS)
Subject: chmod in Perl Scripts?
Message-Id: <19990523180514.10953.00003768@ng31.aol.com>
I have a script which creates a new file for each user. My problem is that even
tho I have the script and the directories set to rwx and even rwxs, the user
becomes www when the script runs, and it keeps setting the permission of the
file it creates to r--.
I've tried using the chmod() Perl command, and even teh chown, but they seem to
be ignored.
Anyone know about this?
maxrivers@aol.com
------------------------------
Date: Sun, 23 May 1999 15:47:50 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Creating index from html code (long)
Message-Id: <37488596.DF84BD43@mail.cor.epa.gov>
Christine Gaunt wrote:
>
> Hi,
>
> I'd been working with a programmer to create an index from a portion of
> the web site I co-compile. The programmer no longer has time to work on
> this script, but the need for it is still there, and I've been trying to
> fix the script myself. But I'm not a programmer, so you can imagine my
> frustration.
Particularly when you have krufty code like this to grapple with.
You probably feel more like you're wrestling Antaeus than fixing
a program.
> The index is to be used as a lookup for surnames included in genealogy
> mailing lists, and the cgi script to do that is yet to be written.
> The surnames are included on the web pages as follows:
>
> [snip]
> The script is supposed to create a file separated by the verical bar, and
> for the most part, does. A snippet of the index is below.
> Fields are: Soundex code | surname | Listname | filename#Anchor
Is soundex really what you want here? After all, it will
give different values to 'Beaudry' and 'Beauregard', but
it will give the same values to 'Knuth' and 'Kant' [and I'm
pretty sure Knuth didn't claim to be related to Immanuel Kant
:-] As you see by examining the text you included, soundex
is also doing bad things to 'VANESSE DIT BEAUVAIS', to name
but one entry. Perhaps you should re-evaluate the design of
your program. I would have designed this as a structured
database, with keys like 'Beaudry' and values that were
arrays of names which would be considered to be genealogical
matches.
> B251|BEAUCHAMPS|BEAUCHAMP|b.html#BEAUCHAMP
> B360|BEAUDRY|BEAUDRY|b.html#BEAUDRY
> B360|BAUDRY|BEAUDRY|b.html#BEAUDRY
> B360|BEAUDRY|BEAUDRY|b.html#BEAUDRY
> B365|BAUDRY INCLUDES BEAUREGARD DIT JARRET|BEAUDRY|b.html#BEAUDRY
> B626|BEAUREGARD DIT VINCENT|BEAUDRY|b.html#BEAUDRY
> B626|BEAUREGARD DIT DAVIGNON|BEAUDRY|b.html#BEAUDRY
> B626|BEAUREGARD TOUTANT|BEAUDRY|b.html#BEAUDRY
> B360|BEAUDRY|BEAUDRY|b.html#BEAUDRY
> B365|BAUDRY INCLUDES BEAUREGARD DIT JARRET|BEAUDRY|b.html#BEAUDRY
> B626|BEAUREGARD DIT VINCENT|BEAUDRY|b.html#BEAUDRY
> B626|BEAUREGARD DIT DAVIGNON|BEAUDRY|b.html#BEAUDRY
> B626|BEAUREGARD TOUTANT JAMES|BEAUDRY|b.html#BEAUDRY
> V523|VANESSE DIT BEAUVAIS|BEAUDRY|b.html#BEAUDRY
> C363|CODERRE DIT BEAUVAIS|BEAUDRY|b.html#BEAUDRY
> B130|BEAUVET|BEAUDRY|b.html#BEAUDRY
> B130|BAUVET|BEAUDRY|b.html#BEAUDRY
> B234|BECHTEL|BECHTEL|b.html#BECHTEL
> B234|BECHDOL|BECHTEL|b.html#BECHTEL
>
> For some reason the script is retaining the match on the BAUDRY surname
> and combining it with the "(includes Beauregard dit Jarret" from the next
> line. It is doing this with other lists with multiple word surnames as
> well.
I don't have enough time to read through this entire Perl
program to track down the source of this problem, but I see some
other problems lying in wait.
> Here is the perl script:
>
> #! /usr/local/bin/perl
#!/usr/local/bin/perl -w
> # create-list-list.pl
>
> use locale;
If you have this in here, then the line far below which
comments out the use of uc() in favor of tr/[a-z]/[A-Z]/
is just A Bad Thing. And it ought to be tr/a-z/A-Z/ anyway.
But uc() will upper-case using the locale information, so
it can (if done with the correct locale) handle things like
accents, tildes, cedillas, umlauts, etc. tr/// here will
*not*. Are you sure your programmer knows Perl?
> use LWP::Simple;
> use Text::Soundex;
> [BIG SNIP]
Okay, now the code is just getting too long and krufty and
un-Perlish to wade through without devoting a lot of time to
the problem. I'm sorry. But any good programmer should
be thinking of ways to turn duplication into formula or
subroutine, instead of cutting-and-pasting over and over
and over and...
> @files = `ls -1 *.temp`;
Workable but not as nice as readdir()
> FILE:
> foreach $file (@files) {
> open(F, $file) || die "can't find file\n";
> chop $file;
And this works for you? Well then, good. I would have
expected to have to chomp $file before feeding it to the
open(). And your programmer left the $! variable out of the
error message above.
> $* = 1;
Oooh. Don't do this. Use of $* is deprecated in modern
versions of Perl.
> while (<F>) {
Okay, I skipped over the next stuff. Your programmer
probably should have used HTML::Parser to parse out the
HTML instead of trying it by hand.
> foreach $name (@names) {
> $_ = $name;
Not good style, and unnecessary.
foreach (@names) {
would do those two lines automagically.
> #$NAME = uc($name); #per cookbook on page 19
> tr/[a-z]/[A-Z]/;
Bad choice here...
> s/\&OUML\;/\231/;
> s/\&UUML\;/\232/;
> s/\&EACUTE\;/\220/;
> s/\&UACUTE\;/\125/;
Ugh. This probably doesn't get everything you needed to
translate, anyway. Perl has an HTML::Entities module that
can do this for you.
> $name = $_;
> $code = soundex $name ;
More icky switching with $_; still not needed.
> if (! /SOUNDEX/ ) {
> # print "$code|$NAME|$list_name|$page_url$tag\n";
> print "$code|$name|$list_name|$page_url$tag\n";
So the problem is in your $tag variable. Would you like to
just elide it from your print() string?
print "$code|$NAME|$list_name|$page_url$tag\n" unless (/SOUNDEX/);
HTH, but you may want to find an accomplished Perlite to
re-do this code.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 23 May 1999 17:50:00 +0200
From: kaih=7HQ00Wumw-B@khms.westfalen.de (Kai Henningsen)
Subject: Re: date conversion and comparison routines
Message-Id: <7HQ00Wumw-B@khms.westfalen.de>
rra@stanford.edu (Russ Allbery) wrote on 21.05.99 in <ylg14qdb4y.fsf@windlord.stanford.edu>:
> I usually use Date::Format to convert them to Unix timestamps and do my
Don't you mean Date::Parse?
Kai
--
http://www.westfalen.de/private/khms/
"... by God I *KNOW* what this network is for, and you can't have it."
- Russ Allbery (rra@stanford.edu)
------------------------------
Date: 23 May 1999 12:52:50 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: date conversion and comparison routines
Message-Id: <ylso8n8sx9.fsf@windlord.stanford.edu>
Kai Henningsen <kaih=7HQ00Wumw-B@khms.westfalen.de> writes:
> rra@stanford.edu (Russ Allbery) wrote:
>> I usually use Date::Format to convert them to Unix timestamps and do my
> Don't you mean Date::Parse?
Er. Yes. Thanks.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Sun, 23 May 1999 15:55:30 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Don't understand ctime / stat[10]
Message-Id: <37488762.2FB22ABA@mail.cor.epa.gov>
Joakim Hove wrote:
>
> Hello,
>
> I have a program with the following main-loop:
>
> while (1) {
> [...Snip...]
> open(FILE,">>$load_file") || die("Could not open $load_file $! \n");
> printf(FILE "%10.0f %6.2f %6.2f %6.2f \n",time - $start_time ,
> $1,$2,$3);
> close(FILE);
> sleep($sleep_time);
> }
>
> The file $load_file is created at the top of the program, and then in
> the main-loop shown above one new line is added to this file for every
> iteration in the loop.
>
> In another program, which analyses this file, I would like to compare
> the creation time, and the last modification time of this file. Now, I
If you're using a unix/linux/*x OS, there is no creation time.
None. ctime is the *change* time. This is a prevalent mis-
conception. If you're on certain other OS'es which I won't
mention because TomC has posted in this thread and the mere
mention might give him a bad case of mal de mer (umm Tom, is
that mal de merde, considering the OS?), then you might
have access to some sort of creation time, but then the other
unix-ish times don't really exist. So you can't get there
from here.
> do know that stat[10] gives the _inode_change_time_ which is different
> from the creation time, however I thought the loop shown above would
> not alter the ctime of $load_file, and hence in this particular case
> ctime would equal creation time. However this seems to be wrong, for
> every iteration ctime is updated, and ctime == mtime.
>
> If someone could shed light on why this is so I would be very
> grateful,
TomC already explained this in his post.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 23 May 1999 19:14:04 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <7i9k1s$hjj$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to hymie!
<hymie@lactose.smart.net>],
who wrote in article <7i9d94$7j8$1@news.smart.net>:
> I found a quote once ...
>
> It's not Perl's fault if you don't know how to program. --Ronald J Kimball
It *is* a Perl's fault that *nobody* knows how to program Perl (well,
I did not check Larry, but extrapolating from other prominent people,
he should be in the same category). Perl documentation is circa 1500
pages long, and it describes (I would say) circa 80% of things needed
to know to program Perl. And I do not mean some obscure constructs, I
mean the most plain constructs used everyday everywhere. Like
$a = $b + $c;
The best thing people know is how to *script* using Perl. The
difference between scripting and programming is very subtle (as Tom
will readily show you), the best advice to recognize it is to compare
the Art of Computer Programming with the Perl CookBook.
Putting it in words, if you (educatedly) guess that your "solution"
(=algorithm?) works in 99.99% of cases, and you use it, it is
scripting. If you un-educatedly guess that your "solution" works in
100% of cases (but it does not, since you do not know how the
language you use works), it is scripting.
Scripting *is* derogatory, but only if the task you program is not
one-off. Perl was *initially designed* for one-off tasks, this is why
it became so bad when it overgrew its initial audience and started to
be used as a general-purpose programming language.
On p5p we are trying to design ways to tight the screws of Perl to
make it better suitable for these tasks, but this process is in its
childhood yet. Basically, now only use strict and -w are your
helpers, but this is a very poor help.
Ilya
P.S. These topics have only tangential relationship to the questions
of silliness of (localtime)[5]. But note that the initial
audience of Perl were quite happy with this silly definition,
since they were versed in C.
The silliness was realized only when a lot of people for who
*Perl* was a reference point, not *C*, came into the discussion.
------------------------------
Date: 23 May 1999 19:26:11 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <7i9koj$hpv$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Uri Guttman
<uri@sysarch.com>],
who wrote in article <x77lq074hi.fsf@home.sysarch.com>:
> IZ> Perl decided to follow a stupid convention, thus Perl has everything
> IZ> to do with the fact that the year-return of Perl's localtime has a
> IZ> brain-dead semantic.
>
> but it is a known convention which is not y2k buggy. rtfm is still
> important whenever you use any library call.
rtfm is useless if there is no way to internalize the knowledge, so
that it stays for long. This is why I use a word "stupid". This is a
question of psychology, not logic.
> and perl has local which is as bad a name as yours!
Note also how long did it take to realize that the "correct" name
should be `save' (I do not think I saw it before the last year).
> IZ> I did not read the "critique" you are refering to, but a fact is a
> IZ> fact: there is no legal usage of $y = (localtime)[5] except as
>
> IZ> $y % 100;
>
> IZ> and
>
> IZ> 1900 + $y;
>
> and $y is perfectly fine if you want a value offset by 1900. it could be
^^^^^
> modified later as long as that is known.
No. It *should* be modified later. (The only exception is when you
take a difference of two years, but this will work with a "4-digit"
year without any change.)
> IZ> Having localtime() return 1900 + $y would save *a lot* of frustration,
> IZ> since it is much harder to get *false expectations* how one can use
> IZ> $y. Quoting Larry, "that's linguistic" in designing programming
> IZ> languages.
>
> so write your own module and overload localtime.
Why? I do not think I used (localtime)[5] once in my life. I'm
discussing the *language*. It has some mis-designed sides indeed.
> IZ> Humans *are* fallible, and one tells good programming languages from
> IZ> bad programming (or scripting) languages by how much attention they
> IZ> pay to the fact that programmers are humans. Some sides of Perl are
> IZ> quite good in this regard. Some other sides of Perl are abyssmal in
> IZ> this regard. Deciding on which side (localtime)[5] is left as an
> IZ> exersize to the reader.
>
> not at all. it is well defined and fully functional which is all i want
> at a minimum from an api.
We use Perl, which lifts the treashold a lot. We are not satisfied by
a Turing-completeness, thank you.
> hope this clears up the api confusion for you.
Thank you, *I* have no confusion. *You* had confusions that Perl's
APIs have non faults, and I hope I cleared this for you.
> api's EXIST as they are. you can always write one above it it you
> don't like it. you just don't change the lower one from its
> specification. that is the rule.
If the API is designed well, you do not *need* to change it or work
around it. In fact you not even *wish* to change it. ;-)
Ilya
------------------------------
Date: Sun, 23 May 1999 14:55:42 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Help with challenge script
Message-Id: <3748795E.AA57CB57@mail.cor.epa.gov>
anonymous wrote:
>
> Thanks a lot for your response. You are correct that there are
> lot of flaws in this script. I have basically rewritten the script
> with lots of bug fixes. With this in mind I was just wondering if
> you can help me out with my script or tell me where I can look for
> a example on archiving a post automatically by the end of the months.
> I know that cron can do what I want but I don't have access to it.
> thanks
Well, if you persist in using a program that may go belly-up in
some arcane way this coming January, then so be it.
Take a look at the Date::Calc module. It has a Days_in_Month()
function. So all you'd have to do is use localtime() to get
the monthday, and check to see if it is equal to the value of
Days_in_Month($four_digit_year,$monthnum_starting_with_one) .
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Sun, 23 May 1999 14:20:43 -0400
From: Steven Elliott <elliotsl@mindspring.com>
Subject: In favor of extending "my" to apply to subroutines as well as variables
Message-Id: <374846FB.FBAFAE1E@mindspring.com>
Currently in perl there is no way of directly marking a
subroutine/method as being private to a given file/module (assuming one
module per file). In C this can be accomplished using the "static"
keyword. In C++ it can be accomplished using the "private" keyword
(assuming one class per file). I realize there are various ways of
indirectly accomplishing this as the following demonstrates:
----------PrivateSubs.pm ---------------
package PrivateSubs;
### private methods ###
# technique #1
my $private_method_1 = sub
{
print "1: This private method was implemented using an anonymous ".
"subroutine.\n";
};
# technique #2
package PrivateSubs::private;
sub private_method_2
{
print "2: This private method was implemented using a sub package ".
"named \"PrivateSubs::private\".\n";
}
package PrivateSubs;
# technique #3
sub _private_method_3
{
print "3: This private method was implemented using an ".
"underscore.\n";
}
# technique #4 <- This is what I am suggesting, but it is not allowed.
# Consequently it is commented out.
#my sub private_method_4
#{
# print "4: This private method was implemented using the ".
# "\"my\" keyword.\n";
#}
### public methods ###
sub new
{
my $class = shift;
&$private_method_1();
&PrivateSubs::private::private_method_2();
&_private_method_3();
#private_method_4(); # Commented out because it can't be done.
return bless {}, $class;
}
----------invoke_privatesubs.pl ---------------
#!/usr/bin/perl -w
use PrivateSubs;
$ps_obj = new PrivateSubs;
----------------------------------------
I think there would be a significant benefits to extending the "my"
keyword in order to allow technique #4. These benefits include:
1) A Compiler enforced scope rule would be universal whereas mere naming
conventions (techniques techniques #2 and #3) may vary from project to
project. For example, one project may interpret "_" to mean private to
a given file whereas another might interpret it to mean private to a
given class. Trying to intermix code that differs in such a way would
be tricky.
2) There is nothing to "grep" for in order generate a list of all
private methods. This makes it difficult to create tools that parse and
display perl object hierarchies.
3) There might be some performance gains by perl that could be made if
it was known that a given subroutine could not be invoked a outside of a
given file, assuming a reference to it was not returned.
I realize that one of perl's mottos is "There is more than one to do
it.", but allowing several easy but equivalent techniques to compete
with one another when the language could provide a single very easy
technique for impatient programers to gravitate towards results in
needless chaos.
I also release that the very complex world of enforced privacy as it is
implemented in java ("private", "protected", "private protected",
"public", blah blah blah) and similar languages is one Pandora's box
that perl's maintainers probably don't want to open. Nevertheless,
being able to limit a given function to a given file is something even C
("static" keyword) offers. This is something that can be done in
moderation.
Does anyone else agree that perl would benefit such a change?
-Steve
------------------------------
Date: Sun, 23 May 1999 22:48:05 GMT
From: Josh Pointer <josh@bitwell.net>
Subject: Re: Mac-specific Perl help requested - The Answer (followup)
Message-Id: <3748867C.7A5B@bitwell.net>
Chris Nandor wrote:
>
> In article <37477760.712B@bitwell.net>, josh@bitwell.net wrote:
>
> # The MacPerl documentation says the following:
> #
> # ""\n" on a Mac means ASCII 13, as opposed to Unix, where it means ASCII
> # 10. If you want ASCII 10, write "\012"."
> #
> # That's it. What it needs to say is this:
>
> perlport.pod (not included with MacPerl, since it was written and included
> with perl in a more recent release, but will be included next time around)
> goes into some significant detail about newline issues. You can get it
> from perl5.004_05 and later, or from CPAN, or from my web site.
Any subsequent revisions of the documentation notwithstanding, it should
be considered a developer's responsibility to properly document publicly
released software, particularly ports (which is to say, new
representations of someone else's primary work). I quoted above the
MacPerl documentation's full treatment of this matter. It's insufficient
at best, and it reflects poorly on the developer.
> # I've tried to imagine why the writer of the MacPerl documentation failed
> # to adequately address this issue, but I just lost three hours of my life
> # driving to the dark side of the moon in search of the only bookstore in
> # the region which stocks the obscure tome "MacPerl: Power and Ease." $40.
> # Did the book answer my question? Yes. Do I believe that it should be
> # necessary to spend $40 and/or three hours of my life to discover why a
> # port of a UNIX text processing language doesn't properly handle UNIX
> # text? Absolutely not.
>
> It does properly handle Unix text. I'm not sure why you think it
> doesn't. Nothing improper about it.
Sure, as long as you translate the linebreaks in every document you read
in and explicitly set $/. That's not my definition of "properly
handling." MacPerl does not, by default, respect and properly handle \n
in UNIX-derived files. It interprets \n as \015. That's not a standard
line break in UNIX. That's not Perl's default behavior. "Properly
handling" means respecting compatibility issues, or, at the very least,
properly documenting one's lack of respect for the same. I would seem to
me that common sense dictates either \n should mean the same thing in
all versions of Perl, or the differences should be clearly and
meaningfully documented (in documentation accompanying the
distribution). MacPerl fails on either count.
> Also, you shouldn't have gone so far. The book is available in its
> entirety online in HTML for free, so you can "try before you buy", and as
> a public service to the community. See http://www.macperl.com/ptf_book/
> for a link.
Which is helpful, but again doesn't relieve, in my opinion, the
developer from the responsibility of properly documenting his work in
the first place. PTF is to be commended for doing what they can to make
up for the developer's shortcomings.
> # BTW, I didn't buy the book. I sat there in the store and read it, taking
> # notes, and then put it right back where I found it. On the other hand,
> # despite UNIX Perl's extensive, useful documentation, I've bought 4 Perl
> # books from O'Reilly. There's a lesson in that.
>
> I don't understand what the lesson is.
Skimping on software (particularly Open Source) documentation in the
hopes of selling add ons is a losing proposition. Do right by your users
and they'll do right by you. Document your software (again, particularly
when your software is a port of someone else's and you change its
standard behavior.).
> --
> Chris Nandor mailto:pudge@pobox.com http://pudge.net/
> %PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
Regards,
Josh Pointer
josh@bitwell.net
------------------------------
Date: Sun, 23 May 1999 22:03:46 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Mac-specific Perl help requested - The Answer
Message-Id: <pudge-2305991803460001@192.168.0.77>
In article <37477760.712B@bitwell.net>, josh@bitwell.net wrote:
# The MacPerl documentation says the following:
#
# ""\n" on a Mac means ASCII 13, as opposed to Unix, where it means ASCII
# 10. If you want ASCII 10, write "\012"."
#
# That's it. What it needs to say is this:
perlport.pod (not included with MacPerl, since it was written and included
with perl in a more recent release, but will be included next time around)
goes into some significant detail about newline issues. You can get it
from perl5.004_05 and later, or from CPAN, or from my web site.
# I've tried to imagine why the writer of the MacPerl documentation failed
# to adequately address this issue, but I just lost three hours of my life
# driving to the dark side of the moon in search of the only bookstore in
# the region which stocks the obscure tome "MacPerl: Power and Ease." $40.
# Did the book answer my question? Yes. Do I believe that it should be
# necessary to spend $40 and/or three hours of my life to discover why a
# port of a UNIX text processing language doesn't properly handle UNIX
# text? Absolutely not.
It does properly handle Unix text. I'm not sure why you think it
doesn't. Nothing improper about it.
Also, you shouldn't have gone so far. The book is available in its
entirety online in HTML for free, so you can "try before you buy", and as
a public service to the community. See http://www.macperl.com/ptf_book/
for a link.
# BTW, I didn't buy the book. I sat there in the store and read it, taking
# notes, and then put it right back where I found it. On the other hand,
# despite UNIX Perl's extensive, useful documentation, I've bought 4 Perl
# books from O'Reilly. There's a lesson in that.
I don't understand what the lesson is.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Sun, 23 May 1999 13:47:59 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Need Perl interpreter
Message-Id: <3748697F.EDDF8ADD@mail.cor.epa.gov>
Eric Bohlman wrote:
>
> Daniel Grisinger <dgris@moiraine.dimensional.com> wrote:
> : quikscor@ix.netcom.com (anonymous) writes:
>
> : > Where's the best place to get a Perl interpreter for Windows 98?
>
> : Interpreters'R'Us, just off of Arapahoe and I-25 20 miles
> : south of downtown Denver. It's the little building with
> : the giant stuffed camel in front of it.
>
> Note, though, that because of the proximity to Littleton, they won't let
> you in if you're wearing a black camel-hair trenchcoat. Bummer.
Is that a rifle in your pants, or are you just glad to see me?
David, doing his part to keep this thread further off-topic...
------------------------------
Date: Sun, 23 May 1999 13:42:28 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: No answer found in Perlfaq
Message-Id: <37486834.90FCCB81@mail.cor.epa.gov>
Jody Fedor wrote:
>
> I'm trying to read a whole file into a variable.
>
> Such as:
>
> open (FILE,"template.htmt") || die "Cannot open template file
> template.htmt\n";
Good! I see you've been paying attention to the useful things
we say here - which we say in arcane ways. :-)
> while (<FILE>){
> $HTML .=$_;
I would recommend using all caps only on the file, not on
your scalars and arrays. cf. the perlstyle pages.
> }
> close(FILE);
But you might want to check the return on your close too.
> $HTML =~s/\$(\w+)/${$1}/g;
> return $HTML;
>
> I get the whole file into $HTML but I don't know how. When I used $HTML =$_
> I only got
> the last line.
As you should. If you make that assignment every time through
the loop, you write over the old info every time.
> What is the significance of the . before the =?
>
> Programming Perl says as an operator . is concatenation but why does it
> work? Can
> anyone explain this?
You'll want to look through perlop fairly carefully to find
this. But this is one of the areas where Perl took a feature
from another language or tool (C in this case) and expanded
its utility. This works like += does:
$var += 2; # same as $var = $var +2;
$var *= 2; # same as $var = $var *2;
$var .= '2'; # same as $var = $var . '2';
You can also do this assignment with:
**=
-=
/=
%=
x=
|=
||=
&=
&&=
and several others.
Try it.. you'll like it! But remember: Jonathan already
showed you a superior approach. In Perl, TMTOWTDI.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Sun, 23 May 1999 13:11:51 -0700
From: "Dave Roth" <xrxoxtxhxdx@xrxoxtxhx.xnxextx>
Subject: Object Copy constructor?
Message-Id: <1fZ13.32261$5e2.568808@news2.giganews.com>
I've looked through dejanews and the various faq's but unless I
have overlooked it I can not find the answer to this...
Let's say I have an instance of a perl object that I pass into a
subroutine. I appears that a copy of the object is passed into
said subroutine. My problem here is that the object points to a
C++ object. When the subroutine exits, the copy of the object is
destroyed thus destroying the C++ object. When the original copy
of the object then accesses the C++ object we have problems.
Consider:
$Obj = new MyClass();
# Now $Obj has a member which points to a C++ object
ProcessMyObject( $Obj );
$Obj->Foo();
sub ProcessMyObject
{
my( $CopyOfObj ) = @_;
$CopyOfObj->Foo();
return;
}
When $Obj is created it also creates a C++ object which contains a
method called Foo(). When we call $Obj->Foo() we are passing through
into the C++ object's Foo() method.
When the ProcessMyObject() routine calls $CopyOfObj->Foo() all is well but
when the routine ends it DESTROYS() $CopyOfObj. Since $CopyOfObj is
destroyed
so is the C++ object. So when the $Obj->Foo() takes place in the main
loop we get a run-time exception.
SO THE QUESTION is... when $Obj is passed into ProcessMyObject() is there
some way to trap the copying of the object so that the extension can
create a copy of the C++ object? In C++ parlance a copy constructor would
suffice.
I have seen that the overload module allows you to overload the = function.
This is *almost* what I am looking for -- unless pushing $Obj onto the stack
to be passed into ProcessMyObject() invokes the = function (which would be
cool).
Can anyone shed some light on this for me?
Thanks tons in advance,
dave
--
=================================================================
Dave Roth ...glittering prizes and
Roth Consulting endless compromises, shatter
<rothd at roth dot net> the illusion of integrity
http://www.roth.net
Win32, Perl, C++, ODBC, Training
Our latest Perl book is now available:
"Win32 Perl Programming: The Standard Extensions"
http://www.roth.net/books/extensions/
------------------------------
Date: Sun, 23 May 1999 16:33:51 -0600
From: Brad Waite <brad@wcubed.net>
Subject: Re: Object Copy constructor?
Message-Id: <3748824F.26A6B910@wcubed.net>
Dave,
You've got a better grasp of what's going on, but it sounds like I might
be having a similar problem. I'm trying to store a GD::Image (GD.pm is
a perl front-end to Thomas Boutell's GD) object via Storable.pm, but I
can't, unless I store it and retrieve it in the same program, which
mostly defeats the purpose of storing it in the first place.
Dave Roth wrote:
>
> I've looked through dejanews and the various faq's but unless I
> have overlooked it I can not find the answer to this...
>
> Let's say I have an instance of a perl object that I pass into a
> subroutine. I appears that a copy of the object is passed into
> said subroutine. My problem here is that the object points to a
> C++ object. When the subroutine exits, the copy of the object is
> destroyed thus destroying the C++ object. When the original copy
> of the object then accesses the C++ object we have problems.
>
> Consider:
>
> $Obj = new MyClass();
> # Now $Obj has a member which points to a C++ object
>
> ProcessMyObject( $Obj );
>
> $Obj->Foo();
>
> sub ProcessMyObject
> {
> my( $CopyOfObj ) = @_;
>
> $CopyOfObj->Foo();
> return;
> }
>
> When $Obj is created it also creates a C++ object which contains a
> method called Foo(). When we call $Obj->Foo() we are passing through
> into the C++ object's Foo() method.
> When the ProcessMyObject() routine calls $CopyOfObj->Foo() all is well but
> when the routine ends it DESTROYS() $CopyOfObj. Since $CopyOfObj is
> destroyed
> so is the C++ object. So when the $Obj->Foo() takes place in the main
> loop we get a run-time exception.
>
> SO THE QUESTION is... when $Obj is passed into ProcessMyObject() is there
> some way to trap the copying of the object so that the extension can
> create a copy of the C++ object? In C++ parlance a copy constructor would
> suffice.
> I have seen that the overload module allows you to overload the = function.
> This is *almost* what I am looking for -- unless pushing $Obj onto the stack
> to be passed into ProcessMyObject() invokes the = function (which would be
> cool).
>
> Can anyone shed some light on this for me?
> Thanks tons in advance,
> dave
> --
> =================================================================
> Dave Roth ...glittering prizes and
> Roth Consulting endless compromises, shatter
> <rothd at roth dot net> the illusion of integrity
> http://www.roth.net
> Win32, Perl, C++, ODBC, Training
>
> Our latest Perl book is now available:
> "Win32 Perl Programming: The Standard Extensions"
> http://www.roth.net/books/extensions/
--
Brad Waite
W Cubed - The World Wide Web Company
------------------------------
Date: Sun, 23 May 1999 13:46:32 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: perl for parsing the CBOE options quote pages
Message-Id: <37486928.D1A612A3@mail.cor.epa.gov>
Stryer wrote:
>
> Has anyone written (or know where I can find) a perl
> script for parsing the CBOE delayed options quote
> pages? (www.cboe.com)
>
> Would be massively grateful for any info.
Not that I know of. But.. look in the latest issue of
The Perl Journal, and you'll find a surprisingly-short
program to do the same for the Salomon Smith Barney
webpage. That should do what you want with minor
mods.
> Thanks
You're welcome,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 23 May 1999 14:20:30 -0400
From: Lewis Perin <perin@panix7.panix.com>
Subject: Re: Perl on Win32 - How can I hide the process?
Message-Id: <pc7lnefzlzl.fsf@panix7.panix.com>
Thomas/Shurflo <thomas@shurflo.com> writes:
> Anyone know how I can hide the process (dos box) that starts when I run
> a Perl script? It could take a while to run and I don't want users
> seeing it.
>
> I've been through the manuals and the newsgroups.
In a DOS box on the NT or 9X system you use, type
start /? | more
and you'll see the info you seek.
Cheers, Lew
------------------------------
Date: Sun, 23 May 1999 16:25:36 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
To: Gene Dolgin <Gened@ohinter.net>
Subject: Re: Perl Tutorials
Message-Id: <37487250.1BFB704@mail.uca.edu>
[cc'd to gd]
Gene Dolgin wrote:
>
> I want to jump into learning perl. Right now, I have two books, "Perl
> in a Nutshell" and "Learning perl" What would be some other
> books/tutorials for me to look at. I am interested in cgi and database
> programming mostly. Sql database is my DB of choice.
I haven't done any database programming, yet, but if you want to use
Perl for CGI, get "The Official Guide to CGI.pm," by Lincoln Stein (pub
Wiley). Comprehensive and easy to read.
Cameron
--
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu
------------------------------
Date: Sun, 23 May 1999 15:00:38 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Question.
Message-Id: <37487A86.6CC4CEF0@mail.cor.epa.gov>
T.Chen wrote:
>
> I am still learning the basics of perl and I apologize if this question has
> been asked already. I need my script to execute a unique program from the
> unix prompt with certain variables. I am aware that system commands can be
> done, but can other programs be executed? If so, how?
There are several ways to do it. In fact, it is even covered
in the FAQ. I suggest you learn to use perldoc, and then start
by trying these commands:
perldoc -f system
perldoc -f qx
perldoc -f open
then go to the relevant questions in the FAQ, and then...
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Sun, 23 May 1999 13:49:24 -0600
From: Brad Waite <brad@wcubed.net>
Subject: Storing GD::Image
Message-Id: <37485BC4.B63645E5@wcubed.net>
I'm trying to obtain object persistence between processes and am having
a lot of problems. Here's a code snippet:
use GD;
use Storable;
open(FILE, "image.gif");
$gif = newFromGif GD::Image('FILE');
close FILE;
store( \$gif, 'newimage.gif' );
Why is newimage.gif only 30 bytes long? Any suggestions on how to store
it? What I'm really trying to do is pass it to another program via
shared memory, but I can't even get it to store or freeze correctly.
I'm thinking it might be because GD.pm uses the external GD library and
therefore the objects aren't native to perl. Am I barking up the wrong
tree here?
BTW, I can get storable to work fine on scalars and hashes.
--
Brad Waite
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5759
**************************************