[12028] in Perl-Users-Digest
Perl-Users Digest, Issue: 5627 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 11 14:07:24 1999
Date: Tue, 11 May 99 11:00:25 -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 Tue, 11 May 1999 Volume: 8 Number: 5627
Today's topics:
"die" and waffles rolm@my-dejanews.com
Re: "die" and waffles (Greg Bacon)
Re: array help needed xdream@my-dejanews.com
Re: Bug in Perl 5.005_03 for win32 on NT machine ?? (Larry Rosler)
Re: Can a DNS lookup be performed from within perl ? <xrxoxtxhxdx@xrxoxtxhx.xnxextx>
Hello, good evening, and welcome! <laughingotter@foxinternet.net>
host table management mjbower@my-dejanews.com
Re: How to convert an e-mail to HTML (Charles R. Thompson)
MS-HTML must die! <tchrist@mox.perl.com>
Re: MS-HTML must die! <tchrist@mox.perl.com>
Re: MS-HTML must die! <revjack@radix.net>
Re: Need a little looping help (Randal L. Schwartz)
Re: parse variables to a sub (Charles R. Thompson)
Perl Processes and Deamons. <fungs@logica.com>
RE's jatgal@my-dejanews.com
Re: search engine! (Charles R. Thompson)
Re: search engine! (Charles R. Thompson)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 11 May 1999 16:04:06 GMT
From: rolm@my-dejanews.com
Subject: "die" and waffles
Message-Id: <7h9kdk$70s$1@nnrp1.deja.com>
hi! recently, i was writing some code and enjoying some eggo (r)
waffles when my bird asked me, "Does 'die' close file handles cleanly?"
what he meant was :
say some files are open and a decision is made to die, do i need to say
if (dirty bird) {
close (FILE1);
close (FILE2);
die ("the bird was dirty");
}
or can i just die and assume that Perl, nice lady that she is, will
close my files for me?
all respondents will have a waffle eaten to their honor!
rolm
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: 11 May 1999 16:15:59 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: "die" and waffles
Message-Id: <7h9l3v$54j$1@info2.uah.edu>
In article <7h9kdk$70s$1@nnrp1.deja.com>,
rolm@my-dejanews.com writes:
: hi! recently, i was writing some code and enjoying some eggo (r)
: waffles when my bird asked me, "Does 'die' close file handles cleanly?"
Not per se, but, assuming you have a reasonable operating system, you
shouldn't have to concern yourself with close()ing open filehandles
before die()ing.
Greg
--
Windows was created to keep the stoopid people away from Unix, you know.
An "MS advocate" is already beneath contempt.
-- Tom Christiansen
------------------------------
Date: Tue, 11 May 1999 16:40:54 GMT
From: xdream@my-dejanews.com
Subject: Re: array help needed
Message-Id: <7h9mil$8ld$1@nnrp1.deja.com>
Thanks for the url's and pointers - I will give them a read (or two).
Upon further investigation, I see that I'm using a copy of "Learning
Perl" from April 1994. The term "hash" isn't even in the index. The same
applies to "my" variables. Looks like I need to get a more up-to-date
verion ASAP.
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Tue, 11 May 1999 09:06:08 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Bug in Perl 5.005_03 for win32 on NT machine ??
Message-Id: <MPG.11a1f543d6ef8017989a2b@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <37384EB5.486AB2C5@itb.biologie.hu-berlin.de> on Tue, 11 May
1999 17:37:26 +0200, a_kowald <axel@itb.biologie.hu-berlin.de> says...
> I just installed Perl 5.005_03 for win32 on my NT4 machine and when I
> use "read()" to read a binary file perl only reads the first 511 bytes.
> For instance: $tmp=read(FP,"file.bin",1000) results in $tmp being 511
>
> Is this a bug, a feature or what am I doing wrong ?
> Btw, the same perl script runs fine under unix.
Did you remember to use binmode() immediately after opening the file?
Probably the 511th character in the file is Control-Z, which is being
interpreted as end-of-file.
How many person-years have been wasted by this damned ancient
boondoggle?
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 11 May 1999 07:38:47 -0700
From: "Dave Roth" <xrxoxtxhxdx@xrxoxtxhx.xnxextx>
Subject: Re: Can a DNS lookup be performed from within perl ?
Message-Id: <O1_Z2.410$qQ4.4781@news2.giganews.com>
Ethan H. Poole wrote in message ...
>[Posted and Emailed] In article <7gsou2$pja$1@news.inet.tele.dk>,
>johndoe@this.is.a.bogus.address.com says...
>>
>>This doesn't work for winnt, though, since gethostbyaddr isn's supported.
Is
>>there another way of getting the hostname of someone? (I know this might
be
>>off topic, but I've already asked in several other newgroups, without
>>getting any answers....)
>>
>>Send replies to usenet@sitemakerz.dk and/or post them to the group...
>
>Who told you gethostbyaddr() doesn't work on NT? If your perl doesn't
>support gethostbyaddr() its high-time to update your installation.
>
>Even Perl 5.001 supported gethostbyaddr() (sorry, I don't have any older
>versions available on my system).
In earlier versions of Perl for Win32 (back around build 110 or so)
some of the functions were broken. This was why we added the
caching DNS functions to Win32::AdminMisc.
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: Tue, 11 May 1999 10:42:34 -0700
From: Steve Laybourn <laughingotter@foxinternet.net>
Subject: Hello, good evening, and welcome!
Message-Id: <37386C09.F2C5CE2C@foxinternet.net>
Hello, everyone!
Be gentle with me, it's my first time...
I am a PERL programmer with a problem...
Basically, it involves using the Net::FTP module...
I am doing programming for a bookshop in Hollywood, CA. What they
want to do is this:
When a record for a book is input, a copy of this record is generated
and set aside in another subdirectory for uploading to other sites that
deal with rare and hard-to-find books.
My problem is: How can I rig something up using the Net::FTP module
so that at the end of the working day, a script can be run to upload all
these records to related sites?
I have a list of site names and subdirectories in an array that I can
use for the uploading procedure, I just cannot get Net::FTP to run it or
even initialize so it can do the work.
I am using PERL 5.004. I have also been told that Net::FTP has been
bundled into the latest version of PERL in the libnet module. *sigh*
So, how do I go about invoking the FTP module to do this?
I apologize for my ignorance, but because of management incompetancy
and really unhelpful replies from the server I'm supposed to be working
on (It's an Apache. Vservers.com says they don't provide support for
so-called 'third-party modules'. I had a devil of a time getting the
site in question off of Earthlink (gaah! What were they THINKING?!?)), I
have to sort all this out on my own. If it wasn't for the O'Reilly PERL
In A Nutshell book, I wouldn't even BE here right now...
Anyways, enough of the blather and sob-story...
Glad to be here! Hopefully I can provide an answer or two in turn!
Thanks so much!
Steve Laybourn
------------------------------
Date: Tue, 11 May 1999 16:49:53 GMT
From: mjbower@my-dejanews.com
Subject: host table management
Message-Id: <7h9n3g$939$1@nnrp1.deja.com>
anyone seen a script to manage a host table ?
I'd like to use a html front end to add/delete/edit entries
in the hosts table.
any help is greatly appreciated
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Tue, 11 May 1999 16:30:10 GMT
From: design@raincloud-studios.com (Charles R. Thompson)
Subject: Re: How to convert an e-mail to HTML
Message-Id: <MPG.11a226679dbaebfd98968f@news>
In article <m11zgnof61.fsf@halfdome.holdit.com>, Randal L. Schwartz
says...
> print "Just another Perl hacker,"
;
(or was that the punch line?) :)
--
Charles R. Thompson
RainCloud Studios
"That? That's no script. That's your attempt at a rather complex README
file."
------------------------------
Date: 11 May 1999 11:07:49 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: MS-HTML must die!
Message-Id: <373863e5@cs.colorado.edu>
Send this form letter to every single webmaster or designer
you come across who creates pages with MS-HTML
Perl content and a cure will be found in my next followup.
--tom
In reading over your otherwise fascinating and useful website, I noticed
documents that your web server alleges to be of content-type "text/html",
but which in fact are not. The HTML standard uses the 8-bit ISO Latin-1
character set, but you include characters that are outside of that, such
as those whose decimal values are in the 146-149 range. This renders
your pages in an illegal, non-standard, proprietary HTML variant, and
consequently illegible to millions of your readers.
I doubt your goal is to limit your audience, but this is what you have in
effect done. My guess is that you are using an on-line publishing tool
provided by Microsoft, or at least running on their systems. In so doing,
you have unwittingly fallen prey to Microsoft's recently revealed stated
goal of killing HTML by the "embrace/extend/extinguish" method. Illegal
characters are just the start of these intentional incompatibilities.
See http://www.fourmilab.ch/webtools/demoroniser/ for details.
If I were you, I would contact whoever provided the publishing software
you are using. I would have them explain why the product you
surely paid good money for has severe bugs in its basic operations.
Microsoft-based tools that claim to "save as" or "generate" HTML do not
in fact do so, but rather instead generate broken HTML, sometimes called
`MS-HTML' to distinguish it from legal, valid HTML. Likewise, those
Microsoft publishing and word-processing tools that purport to save as
ASCII text again fail to do so, producing `MS-ASCII' instead, which is
non-standard, proprietary, and incompatible with real ISO Latin-1.
These behaviors are unlikely to be simple bugs caused by ignorance
or oversight on the part of Microsoft and their supports. Rather,
they appear to be intentional errors designed to destroy the web
by subverting open standards and thus secure Microsoft's hegemony.
Permit me to illustrate.
In his sworn testimony in Federal Court on November 9th, 1998, Intel VP
Steven McGeady testified that Microsoft executives said they intended to
"embrace, extend, extinguish" competing technologies, including Internet
standard HTML. You can read through the news coverage of the DoJ v MSFT
anti-trust trial for November 9th and 10th to find more about this.
But the Intel executive's trial testimony is not the sole source revealing
this strategy of undermining open standards. Here's an excerpt from
the Halloween Document (http://www.opensource.org/halloween1.html)
an internal strategy document leaked from Microsoft whose authenticity
Microsoft has publicly acknowledged. The commentary is by Eric Raymond.
De-commoditize protocols & applications
OSS [Open Source Software] projects have been able to gain a foothold
in many server applications because of the wide utility of highly
commoditized, simple protocols. By extending these protocols and
developing new protocols, we can deny OSS projects entry into
the market.
David Stutz makes a very good point: in competing with Microsoft's
level of desktop integration, "commodity protocols actually become
the means of integration" for OSS projects. There is a large amount
of IQ being expended in various IETF working groups which are
quickly creating the architectural model for integration for these
OSS projects.
{ In other words, open protocols must be locked up and the IETF
crushed in order to ``de-commoditize protocols & applications''
and stop open-source software. --ESR }
Once again, open-source advocates' best response is to point out
to customers that when things are ``de-commoditized'', vendors gain
and customers lose. }
The following day's Wall Street Journal's coverage of that document
draws particular attention to this matter:
A way to beat the movement, the memo says, would be to replace those
software standards with proprietary "extended" versions that exist
only in Microsoft products. That way, "we raise the bar & change
the rules of the game," the memo said.
Open standards like HTML help guarantee maximal accessibility. If you'd
like to know what the standards deem legal HTML -- rather than what you
are unfortunately and probably inadvertently publishing -- check out
the WWW Consortium's documents.
Complete HTML 3.2 specification:
http://www.w3.org/TR/REC-html32.html
Formal grammar on high-bit characters:
http://www.w3.org/MarkUp/Wilbur/ISOlat1.ent
Complete table of legal "text/html" characters and what
they look like:
http://www.w3.org/MarkUp/Wilbur/latin1.gif
I offer you three solutions to your current problem:
1) The optimal fix for your site is to adjust your page-generating
software to generate valid, 100% pure HTML rather than what it
uses now. Whoever sold you the buggy software really should fix
this for you. Assuming you bought it, of course -- if it's a custom
application written by your own programmer, this becomes very easy
to fix.
2) While you wait for those vendors to respond, a free program that will
fix your non-compliant pages for you after the fact is available at
http://www.fourmilab.ch/webtools/demoroniser/
There's also a nice explanation of the myriad problems created by the
polluted MS-HTML you are using.
3) A short-term alternative is to change what your server returns as
its content type for those pages from "text/html" or "text/plain" to
something reflective of its true content type, such as "text/x-ms-html"
and "text/ms-ascii" respectively. This is worse than solutions
one and two, but far, far better than doing nothing at all about
the problem.
Good luck, and thanks for the site.
--
"We don't care. We don't have to. We're the Phone Company."
------------------------------
Date: 11 May 1999 11:12:14 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: MS-HTML must die!
Message-Id: <373864ee@cs.colorado.edu>
Here's the promised perl content.
#! /bin/perl
#
# De-moron-ise Text from Microsoft Applications
#
# by John Walker -- January 1998
# http://www.fourmilab.ch/
#
# This program is in the public domain.
#
$lineWrap = 72; # Wrap lines at this column
$lineBreak1 = '[<]'; # Line break first pass candidates
$lineBreak2 = '[>]'; # Line break second pass candidates
# Process command line options
for ($i = 0; $i <= $#ARGV; $i++) {
if ($ARGV[$i] =~ m/^-/) {
$o = $ARGV[$i];
splice(@ARGV, $i, 1);
$i--;
if (length($o) == 1) {
last;
}
$opt = substr($o, 1, 1);
$arg = substr($o, 2);
# -u -- Print how-to-call information
if ($opt eq 'u' || $opt eq '?') {
print("Usage: demoroniser [ options ] infile outfile\n");
print(" Options:\n");
print(" -u Print this message.\n");
print(" -wcols Wrap lines at cols columns, 0 = no wrap.\n");
exit(0);
# -wcols -- Wrap lines at cols columns, 0 = no wrap
} elsif ($opt eq 'w') {
if ($arg =~ m/^\d+$/ && $arg >= 0) {
$lineWrap = $arg;
if ($lineWrap == 0) {
$lineWrap = 1 << 31;
}
} else {
die("Invalid wrap length '$arg' in -w option.\n");
}
}
}
}
# Open input and output files
$if = STDIN;
$of = STDOUT;
$ifname = "(stdin)";
if ($#ARGV >= 0) {
$if = IF;
open($if, "<$ARGV[0]") || die("Cannot open input file $ARGV[0]: $!\n");
$ifname = $ARGV[0];
}
if ($#ARGV >= 1) {
$of = OF;
open($of, ">$ARGV[1]") || die("Cannot open output file $ARGV[1]: $!\n");
}
$iline = 0;
$oline = 0;
while ($l = <$if>) {
$iline++;
$l1 = &demoronise($l);
&printWrap($l1);
}
close($if);
close($of);
# demoronise -- Translate moronic Microsoft bit-drool into
# vaguely readable and compatible HTML.
sub demoronise {
local($s) = @_;
local($i, $c);
# Eliminate idiot MS-DOS carriage returns from line terminator
$s =~ s/\s+$//;
$s .= "\n";
# Map strategically incompatible non-ISO characters in the
# range 0x82 -- 0x9F into plausible substitutes where
# possible.
$s =~ s{&#(\d+);}{
if ($1 >= 0x82 && $1 <= 0x9F) {
chr($1); # let remainder fix it more
} else {
"&#$1;";
}
}ge;
$s =~ s/\x82/,/g;
$s =~ s-\x83-<em>f</em>-g;
$s =~ s/\x84/,,/g;
$s =~ s/\x85/.../g;
$s =~ s/\x88/^/g;
$s =~ s-\x89- 0/00-g;
$s =~ s/\x8B/</g;
$s =~ s/\x8C/Oe/g;
$s =~ s/\x91/`/g;
$s =~ s/\x92/'/g;
$s =~ s/\x93/"/g;
$s =~ s/\x94/"/g;
$s =~ s/\x95/*/g;
$s =~ s/\x96/-/g;
$s =~ s/\x97/--/g;
$s =~ s-\x98-<sup>~</sup>-g;
$s =~ s-\x99-<sup>TM</sup>-g;
$s =~ s/\x9B/>/g;
$s =~ s/\x9C/oe/g;
# Now check for any remaining untranslated characters.
if ($s =~ m/[\x00-\x08\x10-\x1F\x80-\x9F]/) {
for ($i = 0; $i < length($s); $i++) {
$c = substr($s, $i, 1);
if ($c =~ m/[\x00-\x09\x10-\x1F\x80-\x9F]/) {
printf(STDERR "$ifname: warning--untranslated character 0x%02X in input line %d, output line(s) %d(...).\n",
unpack('C', $c), $iline, $oline + 1);
}
}
}
# Supply missing semicolon at end of numeric entity if
# Billy's bozos left it out.
$s =~ s/(&#[0-2]\d\d)\s/$1; /g;
# Fix dimbulb obscure numeric rendering of < > &
$s =~ s/&/&/g;
$s =~ s/</</g;
$s =~ s/>/>/g;
# Fix unquoted non-alphanumeric characters in table tags
$s =~ s/(<TABLE\s.*)(WIDTH=)(\d+%)(\D)/$1$2"$3"$4/gi;
$s =~ s/(<TD\s.*)(WIDTH=)(\d+%)(\D)/$1$2"$3"$4/gi;
$s =~ s/(<TH\s.*)(WIDTH=)(\d+%)(\D)/$1$2"$3"$4/gi;
# Correct PowerPoint mis-nesting of tags
$s =~ s-(<Font .*>\s*<STRONG>.*)(</FONT>\s*</STRONG>)-$1</STRONG></Font>-gi;
# Translate bonehead PowerPoint misuse of <UL> to achieve
# paragraph breaks.
$s =~ s-<P>\s*<UL>-<p>-gi;
$s =~ s-</UL><UL>-<p>-gi;
$s =~ s-</UL>\s*</P>--gi;
# Repair PowerPoint depredations in "text-only slides"
$s =~ s-<P></P>--gi;
$s =~ s- <TD HEIGHT=100- <tr><TD HEIGHT=100-ig;
$s =~ s-<LI><H2>-<H2>-ig;
$s;
}
# printWrap -- Print one or more lines with wrap at
# the specified column.
sub printWrap {
local($s) = @_;
local($l, $sep, $rem, $ter, $lwrap, $indent);
# Pick the input apart line by line and reformat each line,
# if necessary, so as not to exceed the maximum line length.
$s =~ m/(\s*)(\S)/;
$indent = $1;
if ($2 eq '<') {
$indent .= ' ';
}
while (length($s) > 0) {
if (($s =~ s/(.*\n)//) != 1) {
$aax = $_[0];
print("printWrap arg = |$aax|\n");
print("printWrap s = |$s|\n");
$aal = length($s);
print("printWrap length(s) = $aal\n");
die("$ifname: Error splitting lines.");
}
$l = $1;
$sep = '';
$lwrap = '';
while (length($l) > $lineWrap) {
if (($l =~ s/(^.{1,$lineWrap})(\s)//o) ||
($l =~ s/(^.{1,$lineWrap})($lineBreak1)//o) ||
($l =~ s/(^.{1,$lineWrap})($lineBreak2)//o)
) {
$rem = $1;
$ter = $2;
if ($ter =~ m/\s+/) {
$ter='';
}
$lwrap .= "$sep$rem$ter\n";
$oline++;
$l =~ s/^\s*//;
$sep = $indent;
} else {
last;
}
}
print($of "$lwrap$sep$l");
$oline++;
}
}
__END__
--
"I have never understood why it should be necessary to become irrational in
order to prove that you care. Or indeed why it should be necessary to prove
it at all." - Avon to Vila, `Blake's 7'
------------------------------
Date: 11 May 1999 17:29:44 GMT
From: Trudy Farsi <revjack@radix.net>
Subject: Re: MS-HTML must die!
Message-Id: <7h9pe8$q86$1@news1.Radix.Net>
Keywords: Hexapodia as the key insight
Tom Christiansen explains it all:
:Send this form letter to every single webmaster or designer
:you come across who creates pages with MS-HTML
:Perl content and a cure will be found in my next followup.
Tom,
Have you ever seen WebTV markup?
--
/~\ tent cutesy genotype pilot Rabat turtleneck deletion Constantin
C oo poverty indignation streptomycin quantify mingle Doris bile it
_( ^) 1 , 0 0 0 , 0 0 0 m o n k e y s c a n ' t b e w r o n g
/___~\ http://www.radix.net/~revjack/mnj revjack@radix.net
------------------------------
Date: 11 May 1999 09:25:56 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Need a little looping help
Message-Id: <m1vhdzlgiz.fsf@halfdome.holdit.com>
>>>>> "Bart" == Bart Lateur <bart.lateur@skynet.be> writes:
Bart> Randal L. Schwartz wrote:
>> "20 nested for's" almost certainly means you're trying to use
>> a screwdriver as a hammer.
>>
>> I can bet the rent money that there won't be a single expert here that
>> will agree "20 nested fors... yup, that's the only way to do this
>> one".
Bart> How about.... processing a 20-dimensional array?
Recursive solutions would generally work better. For example, here's
a way to explode every element of an arbitrary list of lists:
sub hack_it {
my $item = shift;
if (ref $item) {
if (ref $item eq "ARRAY") {
for (0..$#$item) {
&hack_it($item->[$_], @_, $_);
}
} else {
die "unknown reference ", ref $item;
}
} else {
## process here
print "saw $item at @_\n";
}
}
hack_it([
["fred","wilma", ["pebbles"]],
["betty","barney", ["bamm-bamm"]],
"dino",
[[[[[["mister slate"]]]]]],
]);
If you don't like the recursion, you can simulate it using a push-pop
index stack. The principle is the same.
Any time I see a lot of redundant code, I think "inelegant - there's
gotta be a better way".
print "Just another Perl hacker,"
--
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@teleport.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: Tue, 11 May 1999 17:40:24 GMT
From: design@raincloud-studios.com (Charles R. Thompson)
Subject: Re: parse variables to a sub
Message-Id: <MPG.11a236e53e4e65cf989691@news>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <37381419.353286810@news.inet.it>, Andrea L. Spinelli says...
> ># ADD THIS - will keep you in line. :)
> ># when you get errors, look in your log files!
> >use strict;
> >$q=new CGI;
> ^^^^^^^^^^^---- use strict did not keep _you_ in line!
> Did you test what you posted? I did, and got
> Do you realise you
> are further confusing an already confused mind?
Didn't have to test it... I knew it would bomb. Further, I don't think I
was a jerk for it. I gave him a 'first step' lesson in debugging right
off the bat.
> ># when you get errors, look in your log files!
^^^^
Nothing is more illustrative than an example. He would either look in the
logs for the error in my example, or come back and ask what was wrong
when he started modifying it with 'prebuilt perfect code'. Either way,
he's got to learn where the error logs are, what use strict does and how
to debug his code.
Maybe my approach was the wrong one, I'll step up to that, but even
handing over a perfectly coded script telling him what use strict does
would result in the this question being asked one to two days from now
when he starts to work with the param() values from his form in
variables.
Which is the lesser of two evils? I just picked a pitchfork in the road
and walked. Ultimately I was curious if he would come back just saying
the script didn't work, or citing the error from the log.
> >http://language.perl.com/newdocs/pod/perlfaq9.html
> I agree. However, the poster has already the concept
> that he must use CGI.pm, and has probably already
> had a look at its documentation.
By the look of the original code, I didn't get that feeling.
> Sorry, Charles, nothing personal...
No, not at all, just different pov's. I can see how I might could have
illustrated that the script would generate an error and included the
answer. Next time, I'll probably be less elusive.
CT
------------------------------
Date: Tue, 11 May 1999 18:16:06 +0100
From: "Ming" <fungs@logica.com>
Subject: Perl Processes and Deamons.
Message-Id: <7h9okr$bsi@romeo.logica.co.uk>
Can anyone give me some pointers for writing Perl Deamons and Spawning child
processes in Perl.
Cheers
Ming.
------------------------------
Date: Tue, 11 May 1999 16:35:17 GMT
From: jatgal@my-dejanews.com
Subject: RE's
Message-Id: <7h9m85$8gl$1@nnrp1.deja.com>
I have a montly log file, with following format.
Date:
-----------Html files ....
Report Title : Search Results
and other reports based upon .. IP address'.
I need to extract Date and Search Results from this report
in the format of
Date Search Results
I tried following and it doesn't work at all.
perl -ne 'print $1, "\t" if /^Date: (\d+ \w+ \d+)/; print $1, "\n" if
/^SearchTotal?([\d,]+)/' filename.txt
Please help me out with this. Thanx.
J
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Tue, 11 May 1999 16:14:50 GMT
From: design@raincloud-studios.com (Charles R. Thompson)
Subject: Re: search engine!
Message-Id: <MPG.11a222d1b4857b7098968d@news>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <3737F535.8687B94C@adcc.alcatel.be>, S.R.SriRam says...
> I am trying to write a search engine for our intranet web server using
> perl.
> Any pointer/freeware/shareware info appreciated.
#!/usr/bin/perl
use CGI_Lite; #(Or the standard CGI.pm module, your choice)
use File::Find;
use File::Slurp;
# things to do.
# 1 output your header
# 2 check for errors in the CGI input
# 3 put your keywords in an array
# 3 feed find a path, let it descend the directories
# 4 slurp the file into a scalar while taking out
# the newlines and extra whitespace s/\s+/ /g
# 6 do a m// (ig optional) for your keywords
# against the slurped scalar in a foreach loop
# 7 report your output
That's a basic framework with very little error checking if you wish to
DIY. I have yet to find one decent freeware/shareware search script out
there. They are either mangled Perl/C-ish code, or bloated scripts full
of all kinds of problems.
The benefit of a DIY project is it's *your* code and you'll have a better
grasp on it when you are ready to add features to it. Further, nothing in
a script like this is beyond the scope presented in something like
"Learning Perl" or the fundamentals of using the Perl language which can
be found in the bundled documentation.
When using the Perl modules, a fairly effective search script that you
can easily understand and later modify can be done in less than 30 lines
of code (most of the folks here could probably do it in 10).
It gets a little hairy if you want to get into search options, but if you
are using 5.005, you can include the Text::Query::Advanced module and get
full 'AltaVista Style' boolean searches at the drop of a hat.
-------
Charles "Vila" Thompson
RainCloud Studios
"That? That's no script. That's your attempt at a rather complex README
file."
------------------------------
Date: Tue, 11 May 1999 17:43:27 GMT
From: design@raincloud-studios.com (Charles R. Thompson)
Subject: Re: search engine!
Message-Id: <MPG.11a237961a548d98989692@news>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <MPG.11a222d1b4857b7098968d@news>, Charles R. Thompson says...
eh...
> #!/usr/bin/perl
#!/usr/bin/perl -w
use strict;
> use CGI_Lite; #(Or the standard CGI.pm module, your choice)
> use File::Find;
> use File::Slurp;
Hehe.... was a quick email... too quick.
--
Charles R. Thompson
RainCloud Studios
"That? That's no script. That's your attempt at a rather complex README
file."
------------------------------
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 5627
**************************************