[9150] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2768 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 30 13:07:24 1998

Date: Sat, 30 May 98 10:00:27 -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           Sat, 30 May 1998     Volume: 8 Number: 2768

Today's topics:
    Re: Autoloader question (Jonathan Stowe)
    Re: Autoloader question (Nathan V. Patwardhan)
    Re: Best tool? <zenin@bawdycaste.org>
    Re: Clearly define "free software" lvirden@cas.org
    Re: Don't Know how to decrypt using PERL (Michael Rubenstein)
    Re: Don't Know how to decrypt using PERL <lr@hpl.hp.com>
    Re: Don't Know how to decrypt using PERL (Chris Nandor)
    Re: GNU attacks on the open software community lvirden@cas.org
    Re: Have we got a good free Perl manual? lvirden@cas.org
    Re: Have we got a good free Perl manual? lvirden@cas.org
    Re: Have we got a good free Perl manual? lvirden@cas.org
    Re: Leap Year Script... (Michael Armstrong)
    Re: Pass filehandler to WIN32 process (Jonathan Stowe)
    Re: Perl OO - proper inheritance needed (Jonathan Stowe)
    Re: Perl Standard In/Out/Error on NT <trin@1.net>
    Re: PLEASE HELP ME ... I need input on this from as man (Jonathan Stowe)
        Problem with EXISTS in MLDBM/Storable when running setg (Adam Spiers)
    Re: quality assurance (Jonathan Stowe)
    Re: seek advice on simple first program (Andre L.)
    Re: seek advice on simple first program <lr@hpl.hp.com>
    Re: seek advice on simple first program (Andre L.)
    Re: seek advice on simple first program <lr@hpl.hp.com>
    Re: seek advice on simple first program <lr@hpl.hp.com>
    Re: seek advice on simple first program (Andre L.)
    Re: Seeking HTML::FormatPS module (Jonathan Stowe)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 30 May 1998 16:04:55 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Autoloader question
Message-Id: <3570175d.14314992@news.btinternet.com>

On Fri, 29 May 1998 00:39:23 -0700, finortis wrote :

<snip>
>
>Lets now suppose I'm totally stupid....OK...I've properly autosplit my
>module into a directory (named after the module that was autosplit of
>course), along with a file containing each subroutine, and an index file.
>Now, I go back to my "main" script....I'm supposed to remove the "use
>module" directives, right??  If I include them, I get "can't locate
>module.pm" error message, so this must be right...However, there is
>something missing...I've included a "use Autoloader" directive...Everything
>seems to be intact...
>
>Can somebody please help who has actually gotten this thing to work.
>

OK,  I did this (my perl libraries are in /develop/lib/perl5 - yours
probably arent):

Create module SplitTest.pm thus:

package SplitTest;

require 5.000;
use Carp;

# this is effectively only a funny way of importing the AUTOLOAD name
# into the SpliTest namespace at runtime - you could equally have done
# use AutoLoader 'AUTOLOAD';

require AutoLoader;
*AUTOLOAD = \&AutoLoader::AUTOLOAD;

# You dont have to export but if if you dont you will have to
# give them explicit package name (ie SplitTest::test1) in your
# program

require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(test1 test2);

1;
__END__

sub test1 {
   print "This is test1\n";
}

sub test2 {
    print "This is test2\n";
}


Then split this thus:

 perl -MAutoSplit -e \
"autosplit('SplitTest.pm','/develop/lib/perl5/auto',0,1,1);"

(Excuse the broken line there but you know what I mean)

in directory /develop/lib/perl5/auto/SplitTest you should now have
three files:

AutoSplit.ix
test1.al
test2.al

The test program is thus:

use SplitTest;

test1();

test2();

And hey presto! My first autosplit module. Thanks

Hope that helps

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



------------------------------

Date: 30 May 1998 16:14:33 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Autoloader question
Message-Id: <6kpb99$d9@fridge.shore.net>

Jonathan Stowe (Gellyfish@btinternet.com) wrote:

: OK,  I did this (my perl libraries are in /develop/lib/perl5 - yours
: probably arent):

Hmmmm.  Why not use h2xs?  It will do all of this stuff for you:

$ h2xs -X -n FooBar (If you won't be using XS)
Writing FooBar/FooBar.pm
Writing FooBar/Makefile.PL
Writing FooBar/test.pl
Writing FooBar/Changes
Writing FooBar/MANIFEST
$ 

$ vi FooBar.pm
You'll see a line like:
# Autoload methods go after =cut, and are processed by the autosplit program.

PUT YOUR AUTOLOADED STUFF AT THE END OF THE MODULE:

$ perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for FooBar

$ make
~/FooBar> make
mkdir ./blib
mkdir ./blib/lib
cp FooBar.pm ./blib/lib/FooBar.pm
AutoSplitting FooBar (./blib/lib/auto/FooBar)
etc etc etc ...

So, did it work?  Yes.

$ find . -name \*.al -print
 ./blib/lib/auto/FooBar/foo_bar_biffo.al

$ more blib/lib/auto/FooBar/foo_bar_biffo.al 
# NOTE: Derived from ./blib/lib/FooBar.pm.  Changes made here will be
# lost.
package FooBar;

# Below is the stub of documentation for your module. You better edit
it!


sub foo_bar_biffo {
    my($foo) = @_;
    print("$foo\n");
}

1;

There you go.

--
Nate Patwardhan|root@localhost
"Fortunately, I prefer to believe that we're all really just trapped in a
P.K. Dick book laced with Lovecraft, and this awful Terror Out of Cambridge
shall by the light of day evaporate, leaving nothing but good intentions in
its stead." Tom Christiansen in <6k02ha$hq6$3@csnews.cs.colorado.edu>


------------------------------

Date: 30 May 1998 15:17:46 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Best tool?
Message-Id: <896541896.440886@thrush.omix.com>

stlam@yahoo.com wrote:
: 1) What is the best tool for PERL programmer?

	Perl, of course.

: Is Perl Builder from www.solutionsoft.com is the best IDE for PERL?

	Nope, X Windows is.  It even lets you pick the editor you like
	to use instead of trapping you into learning something else.

: 2) What is the best tool for Web developer?

	Perl.

: Is Cold fusion is the best?

	No.

: It seems that using cold fusion, I don't need to write code.

	And thus, you run out of options quickly if you have to do
	anything remotely interesting that Cold Fusion doesn't
	support.

: but I know Perl.

	Then use perl.

-- 
-Zenin
 zenin@archive.rhps.org


------------------------------

Date: 30 May 1998 13:44:27 GMT
From: lvirden@cas.org
Subject: Re: Clearly define "free software"
Message-Id: <6kp2fr$ahr$1@srv38s4u.cas.org>


According to  <Klaus.Schilling@home.ivm.de>:

:Irrelevant. Anyone who has not been spoilt by multimedia junk and evil 
:proprietarists like M$, Lotu$, Apple, Oracle, ... , and is not a 
:fool or teenie, can use the best software of all times, the GNU Emacs on a
:vt100, instead of all the wysiwyg junk. 


Hmm - is DEC, Intel, and others somehow immune from the proprietaritarian
label?  Seems like their software, and hardware, and docs, are also proprietary.


If so, then on what do you plan to run GNU EMACS?  
-- 
<URL:mailto:lvirden@cas.org> Quote: In heaven, there is no panic,
<*> O- <URL:http://www.teraform.com/%7Elvirden/> only planning.
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.


------------------------------

Date: Sat, 30 May 1998 14:59:41 GMT
From: miker3@ix.netcom.com (Michael Rubenstein)
Subject: Re: Don't Know how to decrypt using PERL
Message-Id: <35741ad2.772224570@nntp.ix.netcom.com>

On Fri, 29 May 1998 23:07:02 -0500, fl_aggie@thepentagon.com (I R A
Aggie) wrote:

>In unix, one might say 'man 3 crypt'.

Of course, on a Solaris system this won't give you what you want.  You
get a message that it can't find the man page for 3.  It then prints
the man page for crypt(1).

Of course, all a beginner has to do is figure out that the 3 is the
section number in the Unix manual.  He can then use man man to find
that on Solaris one uses -s to specify the section so he'll try

	man -s3 crypt

Unfortunately, that doesn't work either.  He'll get the message "No
entry for crypt in section(s) 3 of the manual."

If he doesn't give up, he can go back to the manual page for man and
find that the -a switch prints all matching manual pages.  Or perhaps
he can figure out to use the command

	man -s3 Intro.3

to get a list of everything in section 3.  He'll then find out that
crypt is in section 3C so he should use

	man -s3c crypt

Gee.  I don't understand why beginners have so much trouble with this
stuff.  I've only been programming Unix for 15 years and I don't have
any trouble.
--
Michael M Rubenstein


------------------------------

Date: Sat, 30 May 1998 08:34:17 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: Don't Know how to decrypt using PERL
Message-Id: <6kp8ub$mel@hplntx.hpl.hp.com>

[posted and emailed]

Chris Nandor wrote in message ...
>In article <6knn46$94t14@eccws1.dearborn.ford.com>,
>kfox@pt0204.pto.ford.com wrote:
>
># "Larry Rosler" <lr@hpl.hp.com> writes:
># > Please, folks.  Get your heads out of the Unix sandbox.  Continued
blind
># > Unix-centrism will hinder Perl, not help it.
>#
># How is not copying the definition of crypt() out of the C
documentation
># being Unix-centric?  If your C library doesn't have crypt(), then
neither
># does your Perl.
>
>Funny.  With MacPerl:
>
>perl -le 'print crypt($ARGV[0], substr($ARGV[0], 0, 2))' mypassword
>myylAylKPNtmw
>
>Yet, my C library on my Mac has not crypt().


Hehehe.  In my (I hope, final) response to brian d foy, I casually
dropped in the other dirty word (besides 'Windows'),  And now you have
confirmed it.

># If your C library has crypt(), then why isn't a pointer
># from the Perl docs to the C docs enough?
>
>I don't have C docs on my Mac.  Perl for Win32 will have crypt built
into
>the binary, yet it does not have C docs on the OS, either.


Because it doesn't have to have the C library at all.

Small PS:  As you're likely to be aware, the Perl crypt() documentation
points out somewhere that the 'salt' comprises the first two characters
of the second argument, so the 'substr' in your example is characterized
as a waste of processor time.  I can't quote chapter and verse from
home, though.

--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com





------------------------------

Date: Sat, 30 May 1998 15:57:30 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Don't Know how to decrypt using PERL
Message-Id: <pudge-3005981151500001@dynamic416.ply.adelphia.net>

In article <6kp8ub$mel@hplntx.hpl.hp.com>, "Larry Rosler" <lr@hpl.hp.com> wrote:

# ># If your C library has crypt(), then why isn't a pointer
# ># from the Perl docs to the C docs enough?
# >
# >I don't have C docs on my Mac.  Perl for Win32 will have crypt built
# into
# >the binary, yet it does not have C docs on the OS, either.
# 
# 
# Because it doesn't have to have the C library at all.

No.  It is because Macs don't ship with C docs.  Even if crypt() was in
the C library, it would not be documented anywhere in the files that come
with the OS.

Assuming there are docs for C library functions is a poor assumption to
make for non-Unix systems.  That is my only point.

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])


------------------------------

Date: 30 May 1998 13:29:09 GMT
From: lvirden@cas.org
Subject: Re: GNU attacks on the open software community
Message-Id: <6kp1j5$9ig$1@srv38s4u.cas.org>


According to Matt Curtin  <cmcurtin@interhack.net>:
:So it is annoying that the FSF does not recognize Perl documentation
:as "free".  I'll have more to say about this later.

As long as FSF incorporate the requirement that anyone be permitted to modify
something tagged as FSF-free, they will not recognize that portion of
Perl doc currently licensed to prevent modification.

As one person recently referenced it - it's FSF-speak...
-- 
<URL:mailto:lvirden@cas.org> Quote: In heaven, there is no panic,
<*> O- <URL:http://www.teraform.com/%7Elvirden/> only planning.
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.


------------------------------

Date: 30 May 1998 14:21:53 GMT
From: lvirden@cas.org
Subject: Re: Have we got a good free Perl manual?
Message-Id: <6kp4m1$cop$1@srv38s4u.cas.org>


According to Greg Lindahl <lindahl@pbm.com>:
:Hypothetically speaking, what happens if someone wants to heavily
:modify Perl, and release modified documentation to go with this
:heavily modified Perl? Perl itself is covered by the GPL or Artistic

They are, by the terms of the license of the pieces of doc in question,
expected to write their own replacement versions of the file and license
them as they deem appropriate.

-- 
<URL:mailto:lvirden@cas.org> Quote: In heaven, there is no panic,
<*> O- <URL:http://www.teraform.com/%7Elvirden/> only planning.
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.


------------------------------

Date: 30 May 1998 14:17:33 GMT
From: lvirden@cas.org
Subject: Re: Have we got a good free Perl manual?
Message-Id: <6kp4dt$cjc$1@srv38s4u.cas.org>


According to Tina Marie Holmboe <tina@tech.scandinaviaonline.se>:
:In article <87vhqtoihe.fsf@io.oryxsoft.com>,
:	Paul Fisher <rao+usenet@oryxsoft.com> writes:

Actually, Paul indicated that this text was authored by RMS and posted for
RMS by Paul

:
:> Once upon a time, I thought I would learn Perl.  I got a copy of a
:> free manual, but I found it simply unreadable, and gave up.  Perl
:> users told me that there were better manuals, but they were not free.

:  These manual-pages are very well written, and covers in a very good

:  But perhaps I've gotten this wrong - the man-pages ain't as free as Perl?

Please, let's not start down that path.  Let's go another way today.

RMS says "I got a copy of a free manual, but I found it simply unreadable..."
and you say "These manual-pages are very well written...".

Apparently, there are two different concepts in action here.  We don't
know what version of the Perl doc RMS read.  We can _infer_ what he
would consider well written by looking at the doc he has written or
has allowed to be associated with EMACS.

The follow on text Paul posted for RMS indicated that some one else
reported to RMS basically that if he wanted _good doc_, he needed
to get one of the printed books written about Perl.  They must have been
talking about O'Reilly's books, because that's who RMS then uses as
a reference point to discuss free documentation.

Perhaps if RMS actually looked at Programming Perl, he would conclude that
it too was unreadable - by his standards.

The issue _seems to me_ to be that RMS has not seen any doc of a bent
that suits his method of learning programming languages in a free to
use (and probably modify) format.

We don't need to argue about the megabytes of doc that comes with Perl -
RMS has already let us know that at least one generation of it wasn't
of the right kind for him to be able to use.  I would guess that in
general the latest would still be considered that.  Surely no one is
going to claim that everyone in the world will learn a language from
scratch in the manner that Perl documents itself.
-- 
<URL:mailto:lvirden@cas.org> Quote: In heaven, there is no panic,
<*> O- <URL:http://www.teraform.com/%7Elvirden/> only planning.
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.


------------------------------

Date: 30 May 1998 14:25:12 GMT
From: lvirden@cas.org
Subject: Re: Have we got a good free Perl manual?
Message-Id: <6kp4s8$cqh$1@srv38s4u.cas.org>


According to John Porter <jdporter@min.net>:
:On 28 May 1998 22:02:52 -0400,
:in article <sd7k975zvek.fsf@mescaline.gnu.org>,
:rms@gnu.org (Richard Stallman) wrote:
:>  
:> Once upon a time, I thought I would learn Perl.  I got a copy of a
:> free manual, but I found it simply unreadable, and gave up.  Perl
:> users told me that there were better manuals, but they were not free.
:
:So all this time we've been arguing about the definition of "free",
:we should have been arguing about the definition of "good".

Close - except that the word good itself wasn't used.  Instead, the
undefined "unreadable" and "better" are used.  Notice that RMS doesn't
say _he_ found the published literature better - just that someone
else told him that.  We have yet to discover if he considers the issue
that Programming, Learning, etc. acceptable doc but enslaved, or if
it is merely unreadable enslaved doc.  Instead of staying on the topic
of unreadable vs readable, RMS seems, to me, to have gotten off onto
the bandwagon of flaming O'Reilly's for selling books, instead of discussing
what is missing or unacceptable in terms of _content_ in the current
doc.
-- 
<URL:mailto:lvirden@cas.org> Quote: In heaven, there is no panic,
<*> O- <URL:http://www.teraform.com/%7Elvirden/> only planning.
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.


------------------------------

Date: Sat, 30 May 1998 16:34:15 GMT
From: michaela@phosphor.com (Michael Armstrong)
Subject: Re: Leap Year Script...
Message-Id: <35703279.65947337@news.visi.com>

Wouldn't it be easier to just subtract the day at the localtime(time)
statement and cut out most of the rest of the code. Leaving you with: 

#!/usr/perl

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time
- 86400);
$mon++;  # adjusts the month to go from 1-12 instead of 0-11
# $year = $year + 1900; # uncomment this line to use 4 digit years. 
$time = localtime(time);

print "Today is $time\n";
print "yday = $yday\n";
print "wday = $wday\n";
print "isdat = $isdst\n";
print "Time is $hour:$min:$sec\n";
print "Date is $month-$mday-$year\n";


---
Michael Armstrong
michaela@phosphor.com                     http://www.phosphor.com/

         Full service Web design and Internet consulting


------------------------------

Date: Sat, 30 May 1998 16:04:54 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Pass filehandler to WIN32 process
Message-Id: <357010cd.13438609@news.btinternet.com>

On Fri, 29 May 1998 11:31:36 +0300, Michael wrote :

>I am looking for way pass to WIN32 process (of course, perl script) previosly created SOCKET or FILEHANDLER.

If the process wants a file descriptor (and most probably wont) you
can use the fileno builtin to return this from the Perl filehandle.
check perldoc -f fileno for more on that.

Otherwise you might want to post something (as short as possible some
of us have no attention span whatsoever) illustrating what you want to
achieve - even if what you think you need to do is not possible *There
May Be Another Way* 

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



------------------------------

Date: Sat, 30 May 1998 16:04:58 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Perl OO - proper inheritance needed
Message-Id: <35701e5a.15528066@news.btinternet.com>

On Fri, 29 May 1998 09:52:58 +0100, F.Quednau wrote :

<snip>

>Sooo, what I am doing right now is that:
>
>sub new {
>  my $class = shift; # or my $proto= shift; my $class =
>ref($proto) || $proto; (???)
>  my $self = {};
>  my $gm = gmtime();
>  $self->{TITLE} = undef;
>  $self->{TEXT} = undef;
>  $self->{WEEKDAY} = (qw(Sun Mon Tues Wednes Thurs Fri Satur
>Sun))[ $gm->wday() ]."day";
>  $self->{YEAR} = $gm->year()+1900;
>  $self->{MONTH} = $gm->mon()+1,
>  $self->{DAY} = $gm->mday(),
>  bless($self, $class);
>  return $self;
>}
>

I put it like this for a little more concision and the stuff to make
it work at the front (I dont want to get involved in the copy/instance
constructor discussion):

package ModTest;

use Time::gmtime;
@ISA =qw(Time::gmtime);

sub new {
  my $class = shift; 
  my $gm = gmtime();
  return bless {
                 TITLE   => undef,
                 TEXT    => undef,
                 WEEKDAY => (qw(Sun Mon Tues Wednes Thurs Fri Satur
Sun))[ $gm->wday() ]."day",
                 YEAR    => $gm->year()+1900,
                 MONTH   => $gm->mon()+1,
                 DAY     => $gm->mday()
                },$class;
}

1;

Then the test code:

use ModTest;

$modtest = new ModTest;

print $modtest->{WEEKDAY};

This works fine (as far as it goes) printing "Saturday" correctly.  Of
course you'll probably want to provide access methods for your hash
elements if you care about what is going into them.  You might not do
something like:

$modtest->{WEEKDAY} = "anchovy";

but this is reusable code we're talking about here.  

Also another benefit of using access methods is the ability to
completely alter the implementation of your class without affecting
existing users (as long as they are using the "published" interface
and that is not changed).

I dont know if there is any substantial benefit of using the 

return bless {}, $class

idiom beyond reducing the number of statements in your code and making
it more explicit what is going on but the benchmark boys might come
along in a while and have something further to say about that.

Have Fun

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



------------------------------

Date: Sat, 30 May 1998 11:44:30 -0400
From: "Brian J. Sayatovic" <trin@1.net>
Subject: Re: Perl Standard In/Out/Error on NT
Message-Id: <35702aed.0@news.one.net>

First of all, the following works for me in Windows NT server 4.0:

    echo C:\WinNT > foo
    dir < foo > bar

The 'bar' file does contain the directory listing of C:\WInNT.  Thus,
redirection does work on NT as it does on UNIX (except that you can't radily
redirect STDERR in NT using the 2>&1 redirection syntax.)  However, if you
plan to have your perl script feed the program AND read from the program, it
is a idfferent story.

In UNIX, you could easily use something like open3 -- which lets you attach
file handles to each the three stndard IO handles.  However, open3 is not
implemented in Perl for Win32 because fork isn't implemented on NT (it's
just not in the NT paradigm.)  There are ways of accomplishing it -- i've
seen it done -- but I don't know how.

If perl is to feed/read your script and you know what you're going to feed
it ahead of time, you could write that out to a temp file, and then when you
execute your command, have the temp file redirected into the program at the
comand line.

Brian.

Jahan@PriceCut.com wrote in message <6kn7ed$4m5$1@nnrp1.dejanews.com>...
>Hello.
>I am trying to implement a ksh script in perl on NT similar as
>
>% program < input_data > output_data
>
>where my program is the executable that takes user input
>the input_data is data that is piped in the program
>and the output_data is the result of the program which will be captured in
the
>outout_data file.
>
>I am trying to write a perl script to execute "program" for me and pipe the
>input_data to it and capture the output of the "program".
>
>How do I accomplish this using perl on windows NT?
>
>Thank you
>
>-Jahan
>
>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/   Now offering spam-free web-based newsreading




------------------------------

Date: Sat, 30 May 1998 16:05:05 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: PLEASE HELP ME ... I need input on this from as many people as possible.
Message-Id: <3570286f.17982609@news.btinternet.com>

On Sat, 30 May 1998 04:25:26 GMT, Michael Dori wrote :

>Subject: PLEASE HELP ME ... I need input on this from as many people as possible.

This is is a fairly busy newsgroup.  People may be more inclined to
look at your posting if you follow the advice given here:

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post


>And yes i know there are free search engines available for free ... my
>ISP will not allow it ... i need to do this, and i have never done
>this, and i need help ... i have only written small programs and would
>appreciate all the help and/or sample files anyone could provide ...
>and i cannot afford the camel book, and no i cannot go to the library
>to get it ... they do not have a copy, it was stolen...
>

Nasty.  So much misfortune - perhaps your Gods are against this
project. (Mind I dont think our Library *ever* had a copy of the Camel
book and my ISP wont allow CGI at all, but there you go)

>
>
>I am developing an algorithm for a search engine for a simple site.
>The pages will be located in a small directory structrue like below
>
>root/
>root/store1
>root/store2
>root/store3
>
>In each directory will be the html files ... i have developed the
>following steps to try to make a search engine ... i would appreciate
>all the input people can provide me.
>

<snip>

This approach might sound appealing but if you have more than a very
few files then it could take as they say "a bastarding long time".  A
better bet would be to create an index file (actually in much the same
way as you describe) containing the relevant details and URL and
searching through that rather than searching the HTML files on the
fly.  For this you would need to create 2 programs : one to create the
index which could be run every once in a while when your site changes
and one a CGI which will simply search through this index and then
create the necessary HTML with the links etc.

I have a fairly crude example (designed for a different purpose
admittedly) that could be hacked around to achieve the first bit -
producing, say, a comma separated file rather than HTML.  

<URL:http://www.btinternet.com/~gellyfish/resources/dir2html.pl>

The second bit is not that difficult once you have got the first right
and have sorted out the CGI bit - a pretty standard perl type
application or at least one that Perl is well suited to.

Once you've had a go and if you've got any further problems that
relate to the Perl program please feel free to post an example of what
isnt working (as short, but as relevant as possible some of us have
negative attention spans) .

Good luck

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



------------------------------

Date: 30 May 1998 14:43:30 +0100
From: adam@thelonious.new.ox.ac.uk (Adam Spiers)
Subject: Problem with EXISTS in MLDBM/Storable when running setgid?!
Message-Id: <6kp2e2$8p1$1@thelonious.new.ox.ac.uk>

I have a MLDBM/Storable tied hash, and the program that accesses it
sometimes runs setgid via the typical simple C wrapper.

When it does run setgid, doing an exists($hash{$key}) gives the
following mysterious error (from a Carp stack trace):

-------- 8< -------- 8< --------
Not a scalar string at /usr/lib/perl5/site_perl/auto/Storable/thaw.al line 13, at /usr/lib/perl5/site_perl/auto/Storable/thaw.al line 14
        Storable::thaw(undef) called at /usr/lib/perl5/site_perl/MLDBM/Serializer/Storable.pm line 27
        MLDBM::Serializer::Storable::deserialize('MLDBM::Serializer::Storable=HASH(0x812ad70)', undef) called at /usr/lib/perl5/site_perl/MLDBM.pm line 155
        MLDBM::FETCH('MLDBM=HASH(0x823c030)', '$key =~ /^163.1.145.130$/') called at /home/manglers/machine_database/bin/../lib/MachineDB.pm line 432
        MachineDB::keyExists('$key =~ /^163.1.145.130$/') called at /home/manglers/machine_database/bin/../lib/MachineDB.pm line 452
-------- 8< -------- 8< --------

The code for MachineDB::keyExists is simply:

-------- 8< -------- 8< --------
sub keyExists {
  my $key = shift;
  return exists($entries{$key});
}
-------- 8< -------- 8< --------

As far as I can see, that exists() call is activating the
MLDBM::FETCH method rather than the MLDBM::EXISTS method, but I
have no clue why.  This then causes problems because the key:

   $key =~ /^163.1.145.130/

(no, it's not a coincidence that that looks like Perl code)
doesn't exist (and isn't supposed to), so as the stack trace
shows, MLDBM tries to deserialize a non-existent key and dies.

I'm using MLDBM 2.00 and Storable-0.5@9 (both the latest off
CPAN).

Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration:
  Platform:
    osname=linux, osvers=2.0.32, archname=i386-linux
    uname='linux porky.redhat.com 2.0.32 #1 wed nov 19 00:46:45 est 1997 i686 unknown '
    hint=recommended, useposix=true, d_sigaction=define
    bincompat3=y useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O2', gccversion=2.7.2.3
    cppflags='-Dbool=char -DHAS_BOOL'
    ccflags ='-Dbool=char -DHAS_BOOL'
    stdchar='char', d_stdstdio=define, usevfork=false
    voidflags=15, castflags=0, d_casti32=define, d_castneg=define
    intsize=4, alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
    libc=, so=so
    useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'


Characteristics of this binary (from libperl): 
  Built under linux
  Compiled at Mar 10 1998 13:01:05
  @INC:
    /usr/lib/perl5/i386-linux/5.00404
    /usr/lib/perl5
    /usr/lib/perl5/site_perl/i386-linux
    /usr/lib/perl5/site_perl
    .

Am I doing something really stupid?  Any suggestions would be
MUCH appreciated!


-- 
/* Adam Spiers, Computing Officer, New College, Oxford University, UK */
#! perl -l-0, 'cello, jazz, cycling, juggling, Linux, security, anti-M$
open$[;$;=q,,,$-++?$?:($#=lc<0>),$==$=>>++$* ,$-++,map{($k=ord)-=$=+$*,
$c=($k&$-+$*)<<$*,$k>>=$-;$;.=($#=~m[^.{$k}(.{$c})])[$[],$#=$'}(split//
=>(q,.";7=/43+':,)[$===$[]);;s;;$\;;,y$k, /u*$c@.kau$&&s&||/\&&print&e;


------------------------------

Date: Sat, 30 May 1998 16:05:03 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: quality assurance
Message-Id: <35702667.17462360@news.btinternet.com>

On Fri, 29 May 1998 19:05:03 GMT, montiq@my-dejanews.com wrote :

>i am trying to identify  quality assurance, system test and configuration
>management professionals. I need to hire 27 people for the New York
>M<etropolitan Area. Please help.
>
Well if you can come up with airfares and accomodation I'm sure I can
arrange for 27  <ahem> "quality assurance, system test and
configuration management professionals" to come to New York.  That'll
be me, Mrs Gellyfish, Red Pete, Lord Lucan, Ned, my Mother and Father,
Alf and Petunia the Herring Gulls, Cyrix the cat, Larry and Leo the
Lobsters, Johnny and Suzie Panic ... ;-}

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



------------------------------

Date: Sat, 30 May 1998 11:14:44 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: seek advice on simple first program
Message-Id: <alecler-3005981114440001@dialup-867.hip.cam.org>

In article <356FF68A.3C8234D0@negia.net>, Dan Boorstein <danboo@negia.net>
wrote:

> Andre L. wrote:

> > #!/usr/bin/perl -w
> > 
> > $" = "\n";
> > 
> > foreach $file (@ARGV) {
> >    open(F, "+<$file")
> >        or warn "Couldn't open '$file': $!\n" and next;
> >    @content = <F>;
> 
>      seek F,0,0;   # oops, forgot to rewind ( that'll be 25 cents :-)
> 
> >    truncate(F, 0);
> >    print F "@content\n";
> >    close F;
> > }


Mind you, I did consider using seek there, but the script appears to work
just fine without it (as tested in MacPerl). Is there a OS-specific issue
here?

A.L.


------------------------------

Date: Sat, 30 May 1998 07:57:15 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: seek advice on simple first program
Message-Id: <6kp7k5$m6o@hplntx.hpl.hp.com>

[posted and emailed]

Shaun Sides wrote in message ...
>Original message by: Larry Rosler <lr@hpl.hp.com>
>Date: Sat, 30 May 1998 01:07:02 -0700
>Subject: Re: seek advice on simple first program
>
>
>> That's neat, and suggests Yet Another Way to Do It, using $\, the
output
>> record separator:
>>
>> $\ = "\n";
>> ...
>>    print F @content;
>> ...
>>
>> I Benchmark this about 30% faster than using $".  YMMV, of course.
>
>Why do you suppose the list separator is so much faster than the output
>record separator?  Geez, when they say there's more than one way, that
>ain't no joke, eh? ;-)
 ...

No joke.  Real benefit.  You can often choose between programmer
efficiency or execution efficiency (which is why the Benchmark module is
so useful when run-time performance matters), between clarity of
expression and elegance (or obfuscation, if you insist), and on and on.

In this case, it was no surprise to me that the output record separator
is significantly faster than the list separator.  (I think you meant
your sentence the other way around.)

Consider the semantics of the two statements 'print "@content\n";' and
'print @content;'.

The first statement instructs perl to construct a (long) string
comprising the elements of @content joined by the list separator,
exactly as if it read 'print join($", @content) . "\n";'  This
concatenation takes significant time.

The second statement instructs perl to print the elements of the list
constructed from the elements of @content, printing the output record
separator $\ after each list element.  As discussed elsewhere (if I were
at my office, I would start to look somewhere around page 540 in the
Blue Camel), the 'print' statement efficiently prints the elements of
its list argument one at a time, without concatenation.  As I recall,
the book says the speed tradeoff is architecture dependent and should be
verified.  So I did.

--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com




------------------------------

Date: Sat, 30 May 1998 11:34:14 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: seek advice on simple first program
Message-Id: <alecler-3005981134140001@dialup-867.hip.cam.org>

> Andre L. (that's me) wrote ...

[...]

> >#!/usr/bin/perl -w
> >
> >$" = "\n";
> >
> >foreach $file (@ARGV) {
> >   open(F, "+<$file")
> >       or warn "Couldn't open '$file': $!\n" and next;
> >   @content = <F>;
> >   truncate(F, 0);
> >   print F "@content\n";
> >   close F;
> >}
> >
> >-----------------------

 ... and Larry Rosler <lr@hpl.hp.com> wrote:

> That's neat, and suggests Yet Another Way to Do It, using $\, the output
> record separator:
> 
> $\ = "\n";
> ...
>    print F @content;
> ...
> 
> I Benchmark this about 30% faster than using $".  YMMV, of course.


Hi Larry,

Inside a while loop, modifying $\ would be an obvious approach, of course,
but it does not work if you print all the file at once with a single print
statement. It only adds a newline at the end of the file. So I'm not
surprised at the difference in speed you measured; the thing is, it
doesn't do what it's supposed to. :-) 

Regards,
A.L.


------------------------------

Date: Sat, 30 May 1998 08:39:36 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: seek advice on simple first program
Message-Id: <6kp986$mj2@hplntx.hpl.hp.com>

Shaun Sides wrote in message ...
>Original message by: Andre L. <alecler@cam.org>
>Date: Fri, 29 May 1998 23:59:42 -0500
>Subject: Re: seek advice on simple first program
>
>> Why not open the file only once, with read and write access?
>
>Baby steps.  I'm taking baby steps.  <from the movie "What About Bob?">
 ...
>Cool.  Would it be better to change $" locally if the program were
>larger?


Indeed, as I was aware (re $\) and I'm certain Andre L. was too.  Baby
steps...

--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com





------------------------------

Date: Sat, 30 May 1998 08:43:02 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: seek advice on simple first program
Message-Id: <6kp9eg$mj7@hplntx.hpl.hp.com>

[posted and emailed]

Dan Boorstein wrote in message <356FF68A.3C8234D0@negia.net>...
>Andre L. wrote:
 ...
>>    @content = <F>;
>
>     seek F,0,0;   # oops, forgot to rewind ( that'll be 25 cents :-)
>
>>    truncate(F, 0);


Why???  Is it possible that truncating a file to 0 length leaves the
file position indicator anywhere but at the beginning of the file?

I think you owe Andre L. 25 cents :-)

--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com





------------------------------

Date: Sat, 30 May 1998 11:49:36 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: seek advice on simple first program
Message-Id: <alecler-3005981149360001@dialup-867.hip.cam.org>

In article <slrn6mvenq.3ks.arch@abts.net>, arch@abts.net wrote:

> Cool.  Would it be better to change $" locally if the program were
> larger?


You got it!

A.L.


------------------------------

Date: Sat, 30 May 1998 16:05:02 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Seeking HTML::FormatPS module
Message-Id: <3570245b.16938870@news.btinternet.com>

On Fri, 29 May 1998 14:16:20 -0500, Michael Murphy wrote :

>I've purchased the Perl Resource Kit by O'Reilly and in the module
>reference and the module listing there is a reference to  a module named
>HTML::FormatPS.  I've looked on the CD and CPAN and can't find it.  Does
>anyone know anything about this module and know where I can get it.  Any
>help would be appreciated.
>

AS far as I can remember the HTML::* modules are part of the LWP
(libwww-perl)  package which is most definitely available from CPAN.
But hang on a sec I'll check. 

Yup there it is

Go to www.perl.com/CPAN (lack of trailing / significant here) and
follow the helpful instructions.

/J\ 
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



------------------------------

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 2768
**************************************

home help back first fref pref prev next nref lref last post