[8154] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1772 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 30 15:10:38 1998

Date: Fri, 30 Jan 98 12:00:28 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 30 Jan 1998     Volume: 8 Number: 1772

Today's topics:
    Re: 5 REAL languages (was: Re: AOL SPAM) (Sitaram Chamarty)
    Re: Array and Split? (Chip Salzenberg)
        Can't find loadable object rreuss@nmdp.org
        Compiling regexs for efficency <joneil@cks.ssd.k12.wa.us>
    Re: CSV (comma separated, quoted) <Russell_Schulz@locutus.ofB.ORG>
    Re: Don't use signal handlers (was Re: Child processes) (Ilya Zakharevich)
    Re: Don't use signal handlers (was Re: Child processes) (Ilya Zakharevich)
    Re: Enlightenment: regexes: fun with /x (Abigail)
        How to set return code for warnings and errors: maybe $ <steve.tolkin@fmr.com>
    Re: howto find out if $x is a blessed reference (object (Chip Salzenberg)
    Re: howto find out if $x is a blessed reference (object <rootbeer@teleport.com>
    Re: Insecure Path (Chip Salzenberg)
    Re: Really Stupid Question (Chip Salzenberg)
    Re: regex with variables? (Sitaram Chamarty)
    Re: removing a line from a file (Chip Salzenberg)
    Re: require "./setup.pl" # never works for me (Lack Mr G M)
    Re: sed2perl conversion? <cmbaker@fedex.com>
    Re: Seeking Search Engine Code (Chip Salzenberg)
    Re: Weird error for beginner (Chip Salzenberg)
    Re: Weird error for beginner <rootbeer@teleport.com>
    Re: Why can't I unzip? (Sitaram Chamarty)
    Re: Working directory when exec. Perl w/ Netscape Serve (Chip Salzenberg)
    Re: Working directory when exec. Perl w/ Netscape Serve <barnett@houston.Geco-Prakla.slb.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 30 Jan 1998 19:22:42 GMT
From: sitaram@diac.com (Sitaram Chamarty)
Subject: Re: 5 REAL languages (was: Re: AOL SPAM)
Message-Id: <slrn6d499k.1ah.sitaram@ltusitaram.diac.com>

On 28 Jan 1998 12:21:06 -0500, Adam Turoff <ziggy@panix.com> wrote:
>In article <34CF45C5.95E@min.net>, John Porter  <jdporter@min.net> wrote:
>>[...]
>>
>>This also confirms my suspicion that there are in fact only five
>>programming languages.  (As if C and Java have anything in common
>>besides curly braces.)
>
>I assume you mean (not necessarily in order):
>	C/C++/Java, FORTRAN, Assembly Language, COBOL, Lithp/Scheme.
>
>Where does perl fall into that list?

One ring to hold them all
One ring to find them
One ring to (I forgot)
And in the darkness bind them

:-)

(Apologies to JRRT)


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

Date: Fri, 30 Jan 1998 19:33:16 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: Array and Split?
Message-Id: <6ata1c$bj9$1@cyprus.atlantic.net>

According to "Craig A. Keefner" <keefner@kinetic.com>:
>I want to run a dos program within perl and
>generate a return list of search finds, read that data into array
>and put it on the screen as formatted html.

Sounds like you need comp.infosystems.www.authoring.cgi, just down the
hall and turn left at the flensing tables.  Ignore the blood.
-- 
Chip Salzenberg               - a.k.a. -                <chip@pobox.com>
    Like Perl?  Want to help out?  The Perl Institute: www.perl.org
           ->  Ask me about Perl training and consulting  <-
             "It's the lemon zester of death!!"   // MST3K


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

Date: Fri, 30 Jan 1998 13:41:18 -0600
From: rreuss@nmdp.org
Subject: Can't find loadable object
Message-Id: <886188961.400162824@dejanews.com>

Hi, I hope someone can help.  I am trying to use Msql and Perl together
and after installing and compiling when I try to run a test script here
is the error I am getting.

Can't find loadable object for module Msql in @INC (<paths>) at
<paths>Msql.pm line 99.

so looking at line 99 of Msql.pm the code is
  Bootstrap Msql;

Does anyone know what is wrong?  Is this a configuration issue?  Please
help!!!

Thanks in Advance

BOB

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Fri, 30 Jan 1998 10:56:25 -0800
From: Jerome O'Neil <joneil@cks.ssd.k12.wa.us>
Subject: Compiling regexs for efficency
Message-Id: <34D22257.3659CC3E@cks.ssd.k12.wa.us>

After grepping the perlop and perlre pages, I am a bit confused as to
the use of regexs in loops, and how they are compiled.  The prelre
document discusses a /o operator that can be used with s///
(s/PATTERN/REPLACEMENT/) to cause it to only compile once.  The prelre
document refers you to this for "...a description on how to use regular
expressions with matching and substitution...).

So, having said that, can you use /o on a normal expression?  It doesn't
cause me any grief in my code, but I was curious if it had any effect?

The loop looks like this

foreach(@list_of_many_scalars)
{
    if(/sc(\d{3})/
    {
        # Do something useful with $1
    }
}

Will the regex compile for each iteration of my list?  Is it more
efficient to use /sc(\d{3})/o instead?  Am I making any sense?

Thanks in advance for any clarification you can provide.

Jerome O'Neil
Seattle Public Schools
Information Services



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

Date: Fri, 30 Jan 1998 13:40:45 +0000
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: Re: CSV (comma separated, quoted)
Message-Id: <19980130.134045.9L9.rnr.w164w@locutus.ofB.ORG>

ben@eexpc.eee.nott.ac.uk (Ben Evans) writes:

> NOTE: Followup-To: line set to poster above as I felt this post
> was slightly off-topic. B.

I've moved it to c.a.s and CC'd you instead.

>>ie:   "John","Doe", "somestreet","Someplace","25031",  etc etc etc.
>
> Errrm. I've just built a set of tools for handling databases being spat
> out as CSV from various relational DB systems and I thought the format
> for a CSV file only quoted a field if the field contained a comma as a
> normal character.

your statement (`the format') implies there is one format.  this is false.

> Could someone possibly point me (gently, with only the lightest
> touch of a rolled-up newspaper :) ) to where I might find some
> CSV hacking libraries or tools.

for perl, see the perl FAQ, and CPAN for Text:: I think.

also, from the c.a.s FAQ:  (hmm, I don't like that line with `usually'
-- I think it implies a case I don't want it to imply.  I want to imply
that it usually works, but there is broken software that WON'T quote
fields with commas in them -- I've used it.)

12.2 CSV (Comma-Separated Values) format

  Stores:  Values

  http://whatis.com/csvfile.htm

  this is generally not a good format, as it has two special cases
  (commas and quotation marks) that are often misimplemented.  it
  would work very well for pure numeric data, which use neither of
  these two characters -- unless your radix separator is the comma,
  as is still common in some parts of Europe.

  each column is separated by commas.  each row is separated by local
  end-of-line, most commonly ASCII LF (10), ASCII CR (13), or ASCII CRLF
  pair (13,10).

  usually, if a comma is needed, the entire field will be surrounded
  by quotation marks.  some packages enclose any string value (and even
  numeric values) in quotation marks.  to represent a quotation mark
  within a field, double it (don't use `\"') and quote the whole field.

  e.g.,
    First,Second,3,"Fourth, and Second-Last",Fifth
    "First","Second",3,"Fourth, and Second-Last","Fifth"
    "all","fields","are","in","quotes","1","2","3"
    "this field has a ""quoted"" word in it","yes, it does"

-- 
Russell_Schulz@locutus.ofB.ORG  Shad 86c


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

Date: 30 Jan 1998 19:14:15 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Don't use signal handlers (was Re: Child processes)
Message-Id: <6at8q7$f1o$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Chip Salzenberg
<chip@pobox.com>],
who wrote in article <6at69f$b6p$1@cyprus.atlantic.net>:
> According to tchrist@mox.perl.com (Tom Christiansen):
> >In comp.lang.perl.misc, chip@pobox.com writes:
> >:Don't use Perl signal handlers.  Ever.
> >
> >Now, kindly explain to the innocent bystanders 
> >when, where, and why that position is untenable.
> 
> Never.  I'm quite serious.

He *is* quite serious.  Here is the story:

   By adding one-line "voodoo" patch I could make a signal handler
   like

	$a = 0;
	$SIG{ALRM} = sub { $a = 1; return };

   to be safe with a simplest code 

        sub run {$a++}
	run while 1;

   going in the main script (100000 calls without any side effect).
   However, with a more complicated code going in the main script
   (calculating 100-factorial via Math::BigInt) the situation changes
   dramatically: after 100-300 signals one gets a segfault.

   I did manage to reduce the number of wrong answers (as opposed to
   segfault) to 1 per all my experiments (this should be circa
   1/10000), but this is still unacceptable.

   However, note that:

	    a) The voodoo patch is an absolute voodoo.  It just adds
	       an (unused!) local variable to a C subroutine.  It
	       *should not* change anything, and is definitely
	       compiler/system specific;

	    b) All the funny things in the above signal handler
	       (preinitializing $a, empty return) are *necessary*.
	       Without this the handler cannot be safe, period.

	    c) Without voodoo patch already the simplest cycle (`run'
	       as above) is segfaulting circa 1/1000 signals.

Ilya

P.S. Here is the voodoo patch for your viewing pleasure:

diff -pru perl5.004_01.ini/perl.c perl5.004_01/perl.c
--- perl5.004_01.ini/perl.c	Mon Jun  9 16:52:04 1997
+++ perl5.004_01/perl.c	Fri Jul 18 19:21:38 1997
@@ -1008,7 +1008,7 @@ perl_call_sv(sv, flags)
 SV* sv;
 I32 flags;		/* See G_* flags in cop.h */
 {
-    LOGOP myop;		/* fake syntax tree node */
+    LOGOP myop,omop;		/* fake syntax tree node */
     SV** sp = stack_sp;
     I32 oldmark;
     I32 retval;
@@ -1023,6 +1023,7 @@ I32 flags;		/* See G_* flags in cop.h */
 	SAVETMPS;
     }
 
+omop=myop;
     Zero(&myop, 1, LOGOP);
     myop.op_next = Nullop;
     if (!(flags & G_NOARGS))


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

Date: 30 Jan 1998 19:28:47 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Don't use signal handlers (was Re: Child processes)
Message-Id: <6at9lf$f1o$2@mathserv.mps.ohio-state.edu>

 [A complimentary Cc of this posting was sent to Chip Salzenberg
 <chip@pobox.com>],

I wrote

> <chip@pobox.com>],
> who wrote in article <6at69f$b6p$1@cyprus.atlantic.net>:
> > According to tchrist@mox.perl.com (Tom Christiansen):
> > >In comp.lang.perl.misc, chip@pobox.com writes:
> > >:Don't use Perl signal handlers.  Ever.
> > >
> > >Now, kindly explain to the innocent bystanders 
> > >when, where, and why that position is untenable.
> > 
> > Never.  I'm quite serious.
> 
> He *is* quite serious.  Here is the story:

Sorry for followuping myself, but I forgot the story, and was testing
a wrong DLL today...  :-(

Whatever failure are discribed below happen with non-voodoo Perl.  A
version with voodoo patch received 17000 signals while I write this
(I'm a slow typer ;-) - when calculating 10! - and showed no problem.

I will try 100!, and if it fails in reasonable time, I will let you
know (the difference is that with 10!, it receives 1.2 signals per
iteration, with 100! it receives 45).

>    By adding one-line "voodoo" patch I could make a signal handler
>    like
> 
> 	$a = 0;
> 	$SIG{ALRM} = sub { $a = 1; return };
> 
>    to be safe with a simplest code 
> 
>         sub run {$a++}
> 	run while 1;
> 
>    going in the main script (100000 calls without any side effect).
>    However, with a more complicated code going in the main script
>    (calculating 100-factorial via Math::BigInt) the situation changes
>    dramatically: after 100-300 signals one gets a segfault.
> 
>    I did manage to reduce the number of wrong answers (as opposed to
>    segfault) to 1 per all my experiments (this should be circa
>    1/10000), but this is still unacceptable.
> 
>    However, note that:
> 
> 	    a) The voodoo patch is an absolute voodoo.  It just adds
> 	       an (unused!) local variable to a C subroutine.  It
> 	       *should not* change anything, and is definitely
> 	       compiler/system specific;
> 
> 	    b) All the funny things in the above signal handler
> 	       (preinitializing $a, empty return) are *necessary*.
> 	       Without this the handler cannot be safe, period.
> 
> 	    c) Without voodoo patch already the simplest cycle (`run'
> 	       as above) is segfaulting circa 1/1000 signals.
> 
> Ilya
> 
> P.S. Here is the voodoo patch for your viewing pleasure:
> 
> diff -pru perl5.004_01.ini/perl.c perl5.004_01/perl.c
> --- perl5.004_01.ini/perl.c	Mon Jun  9 16:52:04 1997
> +++ perl5.004_01/perl.c	Fri Jul 18 19:21:38 1997
> @@ -1008,7 +1008,7 @@ perl_call_sv(sv, flags)
>  SV* sv;
>  I32 flags;		/* See G_* flags in cop.h */
>  {
> -    LOGOP myop;		/* fake syntax tree node */
> +    LOGOP myop,omop;		/* fake syntax tree node */
>      SV** sp = stack_sp;
>      I32 oldmark;
>      I32 retval;
> @@ -1023,6 +1023,7 @@ I32 flags;		/* See G_* flags in cop.h */
>  	SAVETMPS;
>      }
>  
> +omop=myop;
>      Zero(&myop, 1, LOGOP);
>      myop.op_next = Nullop;
>      if (!(flags & G_NOARGS))




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

Date: 30 Jan 1998 18:53:29 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Enlightenment: regexes: fun with /x
Message-Id: <6at7j9$2u1$1@client3.news.psi.net>

Chipmunk (rjk@coos.dartmouth.edu) wrote on 1613 September 1993 in
<URL: news:34D160DE.2C75D525@coos.dartmouth.edu>:
++ [courtesy CCs to Ilya, Tom P, brian, and Eli]
++ 
++ Question: 
++ Rx is a regex with whitespace and/or comments.
++ R is Rx with the comments and embedded whitespace removed.
++ Find a useful Rx such that /Rx/x works, but /R/ does not.

Oh, if that's your definition of the relation of R and Rx, there's
a much simpler one:

Compare:

    $_ = "aab";
    print "[1] ", pos, "\n" if /a/g;
    print "[2] ", pos, "\n" if / /x;

and:

    $_ = "aab";
    print "[1] ", pos, "\n" if /a/g;
    print "[2] ", pos, "\n" if //;


They will give different results.




Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


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

Date: Fri, 30 Jan 1998 14:44:01 -0500
From: Steven Tolkin <steve.tolkin@fmr.com>
To: steve.tolkin@fmr.com
Subject: How to set return code for warnings and errors: maybe $rc |= n; ?
Message-Id: <34D22D7F.21424F25@fmr.com>

What is the "best" way to set a return code for a warning message?
I know many scripts return 1 for anything other than complete success,
but I do not want to do this.  There really is a semantic difference
between warnings and errors; as usual a warning means something is
technically correct, but suspicious, whereas an error must be fixed.
Often my perl scripts process lines from a file and emit warning
messages and/or error messages as needed, but then keep going, so the
user can get them all from one pass of the file.  The last line is
typically
exit $rc;
Assume for now I want to return 0 for success, 1 for any warnings but no
errors, and 2 for any errors.  I wind up coding:
if ( some warning condition) {
    warn "Warning: foo\n";
    $rc = 1 if $rc < 1;  # I type this line a lot
}
 ...
if ( some error condition) {
    warn "Error: bar\n";
    $rc = 2; # error
}
To save typing I am tempted to replace the first commented line above
with
$rc |= 1;
and the second with
$rc = 3;
and document that an error returns 3.  But part of me feels that this is
to much of a hack.
Is there any real reason to prefer 2 to 3 for an error status?  Perhaps
I could use |= and then end the script with:
$rc =2 if $rc > 2;
exit $rc;

Another approach would be something like: $rc = max($rc,1);
What I really want is an operator max= analagous to |= so I could code:
$rc max= 1;
(This thinking is how I arrived at trying |=.  This approach can be
extended to a larger set of possible return code values, with the next
being 7, 15, and to allow for a "really major error" I could code
vanilla errors with: $rc |= 3;)

If I am willing to have $rc be global I suppose I could create warn()
and error()
and this prevents magic numbers in the code.   But I don't like globals.

How have other people solved this problem?

Steve
--
Steven Tolkin          steve.tolkin@fmr.com      617-563-0516
Fidelity Investments   82 Devonshire St. R27C    Boston MA 02109
There is nothing so practical as a good theory.  Remarks are mine.



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

Date: Fri, 30 Jan 1998 19:08:27 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: howto find out if $x is a blessed reference (object)
Message-Id: <6at8is$bfn$1@cyprus.atlantic.net>

According to marc@offline.be (Marc Duponcheel):
>I wonder if there is a simple foolproof way to know if
>$x is a blessed reference (in other words an object).

   index(ref $x, '=') >= 0

should do.
-- 
Chip Salzenberg               - a.k.a. -                <chip@pobox.com>
    Like Perl?  Want to help out?  The Perl Institute: www.perl.org
           ->  Ask me about Perl training and consulting  <-
             "It's the lemon zester of death!!"   // MST3K


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

Date: Fri, 30 Jan 1998 11:31:22 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Marc Duponcheel <marc@offline.be>
Subject: Re: howto find out if $x is a blessed reference (object)
Message-Id: <Pine.GSO.3.96.980130111932.1584V-100000@user1.teleport.com>

On 30 Jan 1998, Marc Duponcheel wrote:

> I wonder if there is a simple foolproof way to know if
> $x is a blessed reference (in other words an object).

Under recent versions of Perl, this seems to work for me. (And it's
entertaining to watch along Les Champs-Elysees. :-) 

    sub isobject ($) {
        eval { $_[0]->can("can") } and ref $_[0]
    }

There's also reported to be a (more efficient) function much like this in
a module called 'builtin', which may be found on CPAN. Hope this helps! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 30 Jan 1998 18:59:25 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: Insecure Path
Message-Id: <6at81r$bde$1@cyprus.atlantic.net>

According to Todd Sprang <tsprang@mercury.net>:
>I get this error:
>--
>Insecure $ENV{PATH} while running setuid at /root/umerc.pl line 5.
>	[line 5 is actually line 2 above--I edited]
>--
>
>I'm at a complete loss.  Any help would be appreciated.  Thanks in
>advance! 

The right info is:  read perlsec.

>Reply to: mailto:tsprang@mercury.net?subject:pppd%20Problem please.

Oh well, I guess you'll never know.

(How impolite is it to not even bother to read followups?!)
-- 
Chip Salzenberg               - a.k.a. -                <chip@pobox.com>
    Like Perl?  Want to help out?  The Perl Institute: www.perl.org
           ->  Ask me about Perl training and consulting  <-
             "It's the lemon zester of death!!"   // MST3K


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

Date: Fri, 30 Jan 1998 19:30:32 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: Really Stupid Question
Message-Id: <6at9s9$bil$1@cyprus.atlantic.net>

According to tmagnum@coredcs.com-nospam (John Doen):
>I'm working on a form where the user submits info a perl script
>processes their choice and outputs the appropriate page.  Easy right?
>Yes it should be.  I'm having problems getting the script, contacted
>below, to get through the If statement.  When I run it in debug mode I
>get a "Use of Uninitialzed Variable" error on the line with the If
>statement.

Well, then maybe it's using an uninitialized variable?

"Hello?  McFly?!"

CGI, CGI, CGI.  Will no one rid me of this accursed CGI?
-- 
Chip Salzenberg               - a.k.a. -                <chip@pobox.com>
    Like Perl?  Want to help out?  The Perl Institute: www.perl.org
           ->  Ask me about Perl training and consulting  <-
             "It's the lemon zester of death!!"   // MST3K


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

Date: 30 Jan 1998 19:22:37 GMT
From: sitaram@diac.com (Sitaram Chamarty)
Subject: Re: regex with variables?
Message-Id: <slrn6d45e7.141.sitaram@ltusitaram.diac.com>

On 29 Jan 1998 21:17:12 GMT, Eli the Bearded <*@qz.to> wrote:
>Doug <doug@1dlabs.com> wrote:
>> $searchaarea = "http:\/\/webserver\/home\/usr1";
>
>Don't bother with those backslashes:
>
>:r! perl -e 'print ($searchaarea = "http:\/\/webserver\/home\/usr1"),"\n";'
>http://webserver/home/usr1
>
>> @linesfromfile = grep /^$searcharea/, <INPUTFILE>;
>
>Well, first off, you set "$searchaarea" and used "$searcharea". Second I

A clear case for switching to VIM :-).  The Ctrl-N and Ctrl-P (auto complete
keyword) functions are a strong incentive to use nice long variable names
without having to trip up like this!

(Yes, I realise it's off topic!  But not that much, since I'm talking about
how you can avoid mistakes in Perl programs :-)


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

Date: Fri, 30 Jan 1998 19:01:29 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: removing a line from a file
Message-Id: <6at85q$be2$1@cyprus.atlantic.net>

According to Chad R Cordero <ccordero@wiley.csusb.edu>:
>I am trying to remove a name from a list of names separated by newline
>in a file.

Apparently you're trying to do it the hard way:  Without having read
the FAQ.  Bad choice.
-- 
Chip Salzenberg               - a.k.a. -                <chip@pobox.com>
    Like Perl?  Want to help out?  The Perl Institute: www.perl.org
           ->  Ask me about Perl training and consulting  <-
             "It's the lemon zester of death!!"   // MST3K


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

Date: Fri, 30 Jan 1998 18:33:53 GMT
From: gml4410@ggr.co.uk (Lack Mr G M)
To: "David Rayner" <david@thames.com>
Subject: Re: require "./setup.pl" # never works for me
Message-Id: <1998Jan30.183353@ukwit01>

In article <886173955.9946.0.nnrp-02.9e9837ac@news.demon.co.uk>, "David Rayner" <david@thames.com> writes:
|> require "./setup.pl" # never works for me
|> 
|> I always have to put the full path in such
|> 
|> require "/home/www/cgi/setup.pl" # is fine
|> 
|> I 've come across this on a variety of servers and Perl versions
|> 
|> Que????

   Well, the obvious question is, when this script *starts* (ie.  not
when you write it) are you sure that '.' is '/home/www/cgi'? 

-- 
----------- Gordon Lack ----------------- gml4410@ggr.co.uk  ------------
The contents of this message *may* reflect my personal opinion.  They are
*not* intended to reflect those of my employer, or anyone else.


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

Date: Fri, 30 Jan 1998 13:14:48 -0500
From: Chad Baker <cmbaker@fedex.com>
To: nNature_Boy@earthling.net
Subject: Re: sed2perl conversion?
Message-Id: <34D21898.F7B2AE39@fedex.com>

Check s2p in your distribution bin directory.
Chad


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

Date: Fri, 30 Jan 1998 18:54:30 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: Seeking Search Engine Code
Message-Id: <6at7o9$bbr$1@cyprus.atlantic.net>

According to badger@infinet.com (Steven Savage):
>I am seeking out free, pre-existing PERL code for a simple CGi search 
>engine.

On a clear disk you can seek forever.
Head on over to comp.infosystems.www.authoring.cgi.
-- 
Chip Salzenberg               - a.k.a. -                <chip@pobox.com>
    Like Perl?  Want to help out?  The Perl Institute: www.perl.org
           ->  Ask me about Perl training and consulting  <-
             "It's the lemon zester of death!!"   // MST3K


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

Date: Fri, 30 Jan 1998 19:07:07 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: Weird error for beginner
Message-Id: <6at8gb$beo$1@cyprus.atlantic.net>

According to devin@premier1.net:
>1) I originally tried to use gethostbyaddr() to resolve the hostnames,
>with very undependable success (worked perhaps 1 out of ten calls, if
>that).  It didn't matter which machine I ran this on.  Now that I've
>figured out the Net::DNS::Resolver stuff, I much prefer that anyway, but
>what was I overlooking?

Nothing in Perl.  Perl's gethostby*() functions are very thing
wrappers around the corresponding C functions.

>2) I'm using a hash, keyed by the IP address, to store the number of
>times each IP address occurs in the input file.  I do this because the
>input file I was using contians an ipconfig and arp command for each IP
>address, and all I really want is a simple list of IPs with no
>duplicates.  However, I got curious about the values in this hash and
>added an extra scalar to the printout to show this value.  Most of them,
>as I expected, were 2, but in one case I had 213, and others showed much
>higher values than they should have.  Is it possible to tell what coding
>mistake I made?  The data file is attached below script 1.

Perhaps you forgot that some IP addresses are textually substrings
of other IP addresses?  If you search for /$ip/ you'll get false
positives.  Searching for /\b\Q$ip\E\b/ is probably good enough.
-- 
Chip Salzenberg               - a.k.a. -                <chip@pobox.com>
    Like Perl?  Want to help out?  The Perl Institute: www.perl.org
           ->  Ask me about Perl training and consulting  <-
             "It's the lemon zester of death!!"   // MST3K


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

Date: Fri, 30 Jan 1998 11:16:55 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "Devin L. Ganger" <devin@premier1.net>
Subject: Re: Weird error for beginner
Message-Id: <Pine.GSO.3.96.980130104524.1584U-100000@user1.teleport.com>

On 30 Jan 1998, Devin L. Ganger wrote:

> 1) I originally tried to use gethostbyaddr() to resolve the hostnames,
> with very undependable success (worked perhaps 1 out of ten calls, if
> that).  It didn't matter which machine I ran this on.  Now that I've
> figured out the Net::DNS::Resolver stuff, I much prefer that anyway, but
> what was I overlooking? 

That call should be simply asking your system to do the resolving, so
failures shouldn't be Perl's fault. Can you make a small script which can
"reliably fail" when it shouldn't? (Of course, as I'm sure you know, that
call is supposed to fail for some parameters.) 

> 	last if ($goon eq "y" || $goon eq "Y");

I'd probably write this like this:

    last if $goon =~ /^y/i;

Which allows "Yes" as well. (Note that this makes the "default", of merely
pressing return, to mean "not yes". I think that's what you want.) 

> while (<SOURCE>) {
> 	/\Q$sourceip\E\.\d{1,3}/;
> 	$foundaddr{$&} ++;
> }

This may be a bug, since the pattern isn't sure to match. (That may
account for the erroneous counts you were seeing.) Also, generally, Perl
programmers try to avoid using $& (for efficiency reasons).  Finally,
since $sourceip seems to be constant over the span of the program, I think
you can use the /o modifier for better efficiency. So I'd write this
something like this: 

    while (<SOURCE>) {
	$foundaddr{$1}++ if /(\Q$sourceip\E\.\d{1,3})/o;
    }

Does that improve anything for you? Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/




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

Date: 30 Jan 1998 19:22:44 GMT
From: sitaram@diac.com (Sitaram Chamarty)
Subject: Re: Why can't I unzip?
Message-Id: <slrn6d49i2.1ah.sitaram@ltusitaram.diac.com>

On 29 Jan 1998 05:28:27 GMT, PaulJCase <pauljcase@aol.com> wrote:
>I just downloaded latest.tar and I can't for the life of me get it open? why?
>Thank you

You cannot unzip a tar file.  Only a zip file (and some kinds of clothing :-)

Try
    tar -xvf latest.tar


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

Date: Fri, 30 Jan 1998 19:27:56 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: Working directory when exec. Perl w/ Netscape Server
Message-Id: <6at9n8$bhv$1@cyprus.atlantic.net>

According to pat.coutu@entrust.com:
>... the default current working directory to that of the directory which
>contains the executiing script?

Not immediately.  If you play around with $0, s///, and chdir(), you
can do it (if $0 is a full path, which is not guaranteed).
-- 
Chip Salzenberg               - a.k.a. -                <chip@pobox.com>
    Like Perl?  Want to help out?  The Perl Institute: www.perl.org
           ->  Ask me about Perl training and consulting  <-
             "It's the lemon zester of death!!"   // MST3K


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

Date: Fri, 30 Jan 1998 13:10:19 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: Working directory when exec. Perl w/ Netscape Server
Message-Id: <34D2259B.9F888A48@houston.Geco-Prakla.slb.com>

pat.coutu@entrust.com wrote:
> 
> When shell CGI perl scripts are executed on my server which is running
> Netscape Enterprise 3.0, the current working directory is set to the
> location of the perl interpreter executable (c:\perl\bin\).  This
> requires that any scripts referencing  files within the same directory as
> the executing script must use absolute paths.  Is there any way to change
> the default current working directory to that of the directory which
> contains the executiing script?
> 
> Thanks for any help,
> 
How about:
#!/usr/local/bin/perl -w
#
use File::Basename;		# part of std dist should be available.
$programName = basename($0);	# basename is func. from File::Basename
$curdir = dirname($0);		# dirname is func. from File::Basename
print $curdir, "\n";
print $programName, "\n";
__END__

HTH.

Dave

-- 
"Security through obscurity is no security at all."
		-comp.lang.perl.misc newsgroup posting

------------------------------------------------------------------------
* Dave Barnett               U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng  U.K.: barnett@gatwick.Geco-Prakla.slb.com *
------------------------------------------------------------------------


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

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 1772
**************************************

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