[13953] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1363 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 12 18:08:53 1999

Date: Fri, 12 Nov 1999 15:05:20 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <942447919-v9-i1363@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 12 Nov 1999     Volume: 9 Number: 1363

Today's topics:
    Re: @ISA <@mdo.net>
    Re: Aack Auto-Responder... (David H. Adler)
    Re: calling a script <cassell@mail.cor.epa.gov>
    Re: Calling cgi from file <cassell@mail.cor.epa.gov>
        CGI.pm and Netscape 4.x <@mdo.net>
        Conditionally use modules (use constant) <moseley@best.com>
    Re: documentation or resource for learning Perl to SQL  <sariq@texas.net>
        documentation or resource for learning Perl to SQL data <cprey@netway.com>
    Re: documentation or resource for learning Perl to SQL  (Andrew Johnson)
    Re: FAQ 4.58: How can I always keep my hash sorted? <cassell@mail.cor.epa.gov>
    Re: freeing memory <aqumsieh@matrox.com>
    Re: function: full(\*FILEHANDLE) <jeffp@crusoe.net>
    Re: function: full(\*FILEHANDLE) <jeffp@crusoe.net>
    Re: function: full(\*FILEHANDLE) <dan@tuatha.sidhe.org>
    Re: funny behaviour of Perl (Randal L. Schwartz)
    Re: funny behaviour of Perl (Bart Lateur)
    Re: Generating pi (Yanick Champoux)
    Re: Help needed fast please <aqumsieh@matrox.com>
    Re: Help with Stoopid Nutscrape (Netscape) <cassell@mail.cor.epa.gov>
    Re: how to parse dir recursively for files? (Kazz Asher)
    Re: How to use range operators with s/// <cassell@mail.cor.epa.gov>
    Re: Installing new modules <cassell@mail.cor.epa.gov>
    Re: list (array) programming question (Bart Lateur)
        microtime? <ccunning@math.ohio-state.edu>
    Re: microtime? <emschwar@rmi.net>
    Re: microtime? <sariq@texas.net>
    Re: Module File:Find problem <cassell@mail.cor.epa.gov>
        Need help understanding directory structure (NEWBIE) <Grizlow@yahoo.com>
    Re: Need help with editing a word in a flat text file.. <cassell@mail.cor.epa.gov>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 12 Nov 1999 16:33:58 -0500
From: "CS" <@mdo.net>
Subject: Re: @ISA
Message-Id: <9G%W3.2271$YI2.121308@typ11.nn.bcandid.com>


Thanks for the info.

I'll look again.  I am somehow creating the darned things (objects) and
inheriting them, I just wanted to know more about them.

Regards, Chris S.




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

Date: 12 Nov 1999 14:06:22 -0500
From: dha@panix.com (David H. Adler)
Subject: Re: Aack Auto-Responder...
Message-Id: <slrn82op9d.d8v.dha@panix.com>

On Fri, 12 Nov 1999 09:30:18 -0600, Lee Sharp <lee@insync.net> wrote:

>   Of all the groups I read, only the Perl folks will spend so much
> energy being completely unhelpful.

Funny, of all the groups *I* read, only clpmisc gets so many
inappropriate postings.  :-/

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"Chicken Wire?" - Lou Marini


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

Date: Fri, 12 Nov 1999 14:34:12 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: calling a script
Message-Id: <382C95E4.1E5B48FB@mail.cor.epa.gov>

Kevin wrote:
> 
> how do you call an ssi command via Javascript

Umm, Kevin, I believe you're asking this in the wrong newsgroup.
Perl is not CGI, and I am proud and relieved that it is not 
Javascript.  You'll do much better asking this in

comp.lang.javascript
comp.infosystems.www.authoring.cgi

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 12 Nov 1999 13:49:54 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Calling cgi from file
Message-Id: <382C8B82.26291BF@mail.cor.epa.gov>

Madone wrote:
> 
> OK, So the answer would be to edit the original cgi file.
> 
> Now  not being a cgi/perl programmer how would I make it activate the other
> cgis, one just before the txt file call and one directly after?
> 
> Below is the cgi i am using to instert the html from txt file.                ^^^
s/cgi/code/;

CGI is just the interface protocol.  What you have here is code.
A 'snippet'.  I know this is picky, but if you want experts to
tell you what you need to know, you have to explain the 
problem *precisely*, in words which mean the same thing that
they do as far as the experts are concerned.  It also makes
you look smarter, and you can lord it over your friends who
haven't learned this yet.

Also, CGI is not Perl.  CGI, which you now know to be merely
a protocol, is not at all like Perl, which is an entire
programming language.  CGI just lets anyone write code in
any language they want to do the same things.

> Basically i
> need it to call the other SSI commands e.g <!--#exec
> cgi="/cgi-bin/file.cgi"-->

Umm, SSI is not CGI either.  They are often interchangeable, 
though.

Now, as to your problem.  This could actually be due to a
large number of things, since I don't have all the info.
I would suggest walking through Eric Wienke's "Debugging
CGI SCripts 101" at 
http://www.liquidsilver.com/scripts/debug101.html

But you may need to generate the HTML as a here-doc in
Perl and then shove that in.  Otherwise, you'll have a
hard time getting the interpolation you appear to want.

> Any help will get themselves a credit on the site.

No, that's not why we're here.  Well, it's not why I'm
here, anyway.  Thanks anyway.
 

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 12 Nov 1999 16:39:13 -0500
From: "CS" <@mdo.net>
Subject: CGI.pm and Netscape 4.x
Message-Id: <3L%W3.2281$YI2.122079@typ11.nn.bcandid.com>

Greetings,

whenever I send output to an MS Internet Explorer browser, things turn out
fine, but when the same text is sent to a Netscape browser, this is what
happens:

print $q->header,$q->start_html;
print $q->h1('Blah');
print $q->end_html;

And this is what is displayed (in the browser, not the source):

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML><HEAD><TITLE>Untitled Document</TITLE>
</HEAD><BODY><H1>Blah</H1></BODY></HTML>

Does CGI.pm need to do something different to get it to work?

Regards, Chris S.




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

Date: Fri, 12 Nov 1999 11:37:52 -0800
From: Bill Moseley <moseley@best.com>
Subject: Conditionally use modules (use constant)
Message-Id: <MPG.12960c6e958207b6989865@nntp1.ba.best.com>

This is one of those DOH! questions:

I want to set some constants, but only if I can't import them.

I may or may not have Apache::Constants installed (this is an 
Apache::Registry script than can be run under mod_perl or mod_cgi).


BEGIN {
    unless ( eval "use Apache::Constants qw/OK HTTP_NOT_MODIFIED/;" ) {
        use constant OK => 0;
        use constant HTTP_NOT_MODIFIED => 1;
    }
}

Results in:
Constant subroutine OK redefined at Constants.pm line 0
Prototype mismatch: sub LII::OK () vs none at Constants.pm line 0
Constant subroutine HTTP_NOT_MODIFIED redefined at Constants.pm line 0
Prototype mismatch: sub LII::HTTP_NOT_MODIFIED () vs none at 
Constants.pm line 0

Ok, then how 'bout this?

BEGIN {
    unless ( eval "use Apache::Constants qw/OK HTTP_NOT_MODIFIED/;" ) {
        eval "use constant OK => 0;";
        eval "use constant HTTP_NOT_MODIFIED => 0;";
    }
}

Returns:
Prototype mismatch: sub LII::OK vs () at constant.pm line 161.
Prototype mismatch: sub LII::HTTP_NOT_MODIFIED vs () at constant.pm line 
161.

BTW -- Any reason to use a BEGIN block if this code is at the top of a 
module?

Thanks,

-- 
Bill Moseley mailto:moseley@best.com
Don't bother with this .sig: All the interesting stuff is above.


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

Date: Fri, 12 Nov 1999 15:14:49 -0600
From: Tom Briles <sariq@texas.net>
Subject: Re: documentation or resource for learning Perl to SQL database  interaction
Message-Id: <382C8349.503CC4DF@texas.net>

"Chad A. Prey" wrote:
> 
> I would be indebted to anyone that could recommend a resource that explains
> Perl to SQL database interaction such as insert, update, select, etc. 

Did you miss the Perl FAQ?  Specifically, perlfaq8.

There's a nice intro to DBI at:

http://www.symbolstone.org/technology/perl/DBI/doc/tpj5/index.html

- Tom


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

Date: Fri, 12 Nov 1999 15:41:30 -0500
From: "Chad A. Prey" <cprey@netway.com>
Subject: documentation or resource for learning Perl to SQL database interaction
Message-Id: <jX_W3.36737$oa2.150346@iad-read.news.verio.net>

I would be indebted to anyone that could recommend a resource that explains
Perl to SQL database interaction such as insert, update, select, etc. I am
unable to find even decent literature on this subject and have a feeling
that I am not looking in the right place.

--
Chad A. Prey
Cprey@netway.com
23 Burr St. #3
Jamaica Plain, MA. 02130





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

Date: Fri, 12 Nov 1999 20:51:13 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: documentation or resource for learning Perl to SQL database interaction
Message-Id: <55%W3.1944$Zu4.31285@news1.rdc1.mb.home.com>

In article <jX_W3.36737$oa2.150346@iad-read.news.verio.net>,
 Chad A. Prey <cprey@netway.com> wrote:
! I would be indebted to anyone that could recommend a resource that explains
! Perl to SQL database interaction such as insert, update, select, etc. I am
! unable to find even decent literature on this subject and have a feeling
! that I am not looking in the right place.

You can find a good introduction to the subject in the article
by Mark-Jason Dominus at:

http://www.perl.com/pub/1999/10/DBI.html

regards
andrew

-- 
Andrew L. Johnson   http://www.manning.com/Johnson/
      They're not soaking, they're rusting!
          -- my wife on my dishwashing habits
      


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

Date: Fri, 12 Nov 1999 14:41:21 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: FAQ 4.58: How can I always keep my hash sorted?
Message-Id: <382C9791.9DC35C37@mail.cor.epa.gov>

Martin wrote:
[snip]
> But my original question was how to sort two (or more) tied hashes
> differently, when I need them at the same time. Is this possible, and if
> it is: how?

It is possible, but I still don't see what you're trying to do.
Can you show some code you've written, so we can see how this
is supposed to work?  And tell us what you expect to get, also.
Are you trying to compare hashes?  Merge them?

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 12 Nov 1999 14:38:56 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: freeing memory
Message-Id: <x3yn1sjqz3j.fsf@tigre.matrox.com>


timfi@my-deja.com writes:
> In article <80gnsa$qqj$1@pegasus.csx.cam.ac.uk>,
>   mjtg@cus.cam.ac.uk (M.J.T. Guy) wrote:
> >
> > With one small qualification:   Garbage collection won't retrieve
> > looped data structures, such as
> >
> >       $hash{key} = \%hash;
> >
> > But you're probably not doing that.
> >
> > Mike Guy
> >
> Actually, that is what I am doing.  That is what I meant by "hash of
> hashes of hashes".  A complex data structure of nested hashes.

No. This is not what you're doing. Mike was trying to show you how a
*circular* data structure looks like. In this case, one of the values
of the hash (%hash) is a reference to the hash itself (\%hash).

You can nest as many hashes as you want, and everything will be
fine. But if you have a *circular* data structure, garbage collection
won't work.

--Ala



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

Date: Fri, 12 Nov 1999 14:39:56 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: function: full(\*FILEHANDLE)
Message-Id: <Pine.GSO.4.10.9911121407350.24181-100000@crusoe.crusoe.net>

[posted & mailed]

> I prefer this function call to that of the subject line:
> 
>     full FILEHANDLE;  # let the prototype do its job

Ah, yes.  I'd been having some problems under 'use strict', but the
prototype sorts those out.  That method of calling full() works fine.

Before I consider your $/ queries, here is a mildly rewritten version:

    sub full (*) {
        local *FH = shift;
        return scalar <FH> if tell(FH) == 0;
        seek FH, -length($/), 1;
        return +(scalar <FH>, scalar <FH>)[1];
    }

Now, let's examine your program first...

> The following function accounts for the different meanings of $/.  It is
> untested and may or may not work.

Ooh, please test it, then.  I see one glaring error.

  length('\n\n') == 4;
  length("\n\n") == 2;

 ... unless I am sorely mistaken.


> sub full (*) {
>     my $fh = shift;
>     my $mark = tell $fh;
>     return scalar <$fh> unless $mark;
>     if (not defined $/) {
>         seek $fh, 0, 2;
>     } elsif ($/ eq "") {
>         seek $fh, -4, 1;  # length("\n\n") <= 4       # XXX see above
>         <$fh> until tell $fh >= $mark;

You should only need to <$fh> ONCE, if you seeked backwards correctly
(that is, seek($fh,-2,1)).  You can't go back more than one paragraph in
paragraph mode if you go back only two bytes.

>     } elsif (ref $/ eq 'SCALAR') {
>         my $size = ${$/} + 0;
>         if ($size) {
>             seek $fh, $size - $mark % $size, 1;
>         } else {
>             # $/ = \0 currently works like $/ = ""

If $/ is a reference to a constant less than 1 (not just 0), it acts like
$/ = "".  It's an obscure case, yes, but it happens.  And I'm not sure
your seek($fh, $size - $mark % $size, 1) is correct... that's going
backwards to the beginning of the record.  Why do that if you're then
going to seek forward to the next record?  Why not seek forward?

>             seek $fh, -4, 1;       # XXX, see above
>             <$fh> until tell $fh >= $mark;
>         }
>     } else {
>         seek $fh, -(length $/), 1;
>         <$fh>
>     }
>     scalar <$fh>;
> }

Here's my corrected version, which I have tested.  I include it as an
entire program.  Make your own file to test it on.


#!/usr/bin/perl -w

use strict;
use vars qw( $full *FH );
sub full (*);

die << "USAGE" if @ARGV != 2;
usage: fulltest FILE OFFSET
  FILE     filename to seek in
  OFFSET   offset in bytes

USAGE


# $/ = ???
# set $/ to whatever you'd like


open FOO, $ARGV[0] or die "can't open ;
seek FOO, $ARGV[1], 0;

if ($full = full FOO) { print $full }
else { print "no line found\n" }

close FOO;


sub full (*) {
	local *FH = shift;
	warn("full() on unopened filehandle"), return if !fileno(FH);
	my $pos = tell(FH);

	return scalar <FH> if tell(FH) == 0;

	if (not defined $/) {
		seek FH, 0, 0;
	}
	elsif (ref $/ eq 'SCALAR' and my $size = ${$/}) {
		seek FH, $size % $pos, 1;
	}
	elsif ($/ eq "" or (ref $/ eq 'SCALAR' and ${$/} < 1)) {
		seek FH, -2, 1;
		<FH>;
	}
	else {
		seek FH, -length($/), 1;
		<FH>;
	}

	return scalar <FH>;
}

> Hmm... maybe I should error check all those seeks.

That's probably not a bad idea, for the both of us.

-- 

  MIDN 4/C PINYAN, USNR, NROTCURPI     http://www.pobox.com/~japhy/
  jeff pinyan: japhy@pobox.com     perl stuff: japhy+perl@pobox.com
  "The Art of Perl"               http://www.pobox.com/~japhy/book/      
  CPAN ID: PINYAN  http://www.perl.com/CPAN/authors/id/P/PI/PINYAN/
  PerlMonth - An Online Perl Magazine     http://www.perlmonth.com/



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

Date: Fri, 12 Nov 1999 14:48:41 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: function: full(\*FILEHANDLE)
Message-Id: <Pine.GSO.4.10.9911121446230.24181-100000@crusoe.crusoe.net>

I found an error in my code after further testing.  Below find a
correction to full().

> #!/usr/bin/perl -w
> 
> use strict;
> use vars qw( $full *FH );
> sub full (*);
> 
> die << "USAGE" if @ARGV != 2;
> usage: fulltest FILE OFFSET
>   FILE     filename to seek in
>   OFFSET   offset in bytes
> 
> USAGE
> 
> 
> # $/ = ???
> # set $/ to whatever you'd like
> 
> 
> open FOO, $ARGV[0] or die "can't open ;
> seek FOO, $ARGV[1], 0;
> 
> if ($full = full FOO) { print $full }
> else { print "no line found\n" }
> 
> close FOO;
> 
> 
> sub full (*) {
> 	local *FH = shift;
> 	warn("full() on unopened filehandle"), return if !fileno(FH);
> 	my $pos = tell(FH);
> 
> 	return scalar <FH> if tell(FH) == 0;
> 
> 	if (not defined $/) {
> 		seek FH, 0, 0;
> 	}
> 	elsif (ref $/ eq 'SCALAR' and my $size = ${$/}) {
### > 		seek FH, $size % $pos, 1;
		seek FH, $size - ($pos % $size), 1 if $pos % $size;
> 	}
> 	elsif ($/ eq "" or (ref $/ eq 'SCALAR' and ${$/} < 1)) {
> 		seek FH, -2, 1;
> 		<FH>;
> 	}
> 	else {
> 		seek FH, -length($/), 1;
> 		<FH>;
> 	}
> 
> 	return scalar <FH>;
> }

That correction advances to the next record ONLY if you're not at the
beginning of a record.

-- 

  MIDN 4/C PINYAN, USNR, NROTCURPI     http://www.pobox.com/~japhy/
  jeff pinyan: japhy@pobox.com     perl stuff: japhy+perl@pobox.com
  "The Art of Perl"               http://www.pobox.com/~japhy/book/      
  CPAN ID: PINYAN  http://www.perl.com/CPAN/authors/id/P/PI/PINYAN/
  PerlMonth - An Online Perl Magazine     http://www.perlmonth.com/



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

Date: Fri, 12 Nov 1999 19:55:42 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: function: full(\*FILEHANDLE)
Message-Id: <2h_W3.3153$c06.28574@news.rdc1.ct.home.com>

Jeff Pinyan <jeffp@crusoe.net> wrote:

> If $/ is a reference to a constant less than 1 (not just 0), it acts like
> $/ = "".  It's an obscure case, yes, but it happens.

Actually, if $/ is a reference to something that doesn't evaluate to an
integer greater than zero, then its behaviour is undefined. Currently that
means it falls through into the paragraph-slurp code, but that's
definitely not any guarantee of what it does next week. You could make a
legit case that if the number's negative then it should read the prevous
record, and if zero should always return the empty string, though it
doesn't do that now.

						Dan


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

Date: 12 Nov 1999 11:06:58 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: funny behaviour of Perl
Message-Id: <m1bt8zpm0d.fsf@halfdome.holdit.com>

>>>>> "Larry" == Larry Rosler <lr@hpl.hp.com> writes:

Larry> Perl programs invoked as:

Larry>     perl foobar

Larry> need to be readable.

I don't know.  I've seen some pretty unreadable Perl programs.  Even
written a few myself.  And they still executed just fine with "perl
foobar".  Well, provided they are named "foobar", which rules out
nearly everything I've written. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Fri, 12 Nov 1999 20:18:42 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: funny behaviour of Perl
Message-Id: <382c75e9.1029129@news.skynet.be>

Randal L. Schwartz wrote:

>Well, provided they are named "foobar", which rules out
>nearly everything I've written. :)

It then probably needs to be changed to:

	perl fredbarney

;-)

-- 
	Bart.


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

Date: Fri, 12 Nov 1999 22:57:52 GMT
From: yanick1@sympatico.ca (Yanick Champoux)
Subject: Re: Generating pi
Message-Id: <QX0X3.50774$up3.78461@news21.bellglobal.com>

In article <80gfho$ou0$1@charm.magnus.acs.ohio-state.edu>,
	ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
>> 	Drat! Writing that module would have been fun. Oh well.. 
>> Maybe I'll have better luck with 'e'. :)
> 
> Hmm, e looks harder:
> 
>   perl -MMath::Pari=:prec=32000,:int -wle "print exp 1"
> 
> took more than 5 min on my machine.

	Double drat! Hmm... The choice of interesting constants is running thin.

	I know! I got it! I bet there is no module to compute '1' to 
an arbitrary precision. ;) 

Joy,
Yanick

-- 
#! /usr/bin/perl
##############  Email: champoux@iro.umontreal.ca
##############  Web:   http://www.iro.umontreal.ca/~champoux
$_ = 'Oxsgnm0qtkdr0nudq0C`fna`g+0ats0nm0S`snhmd0sgd0B`ldk0hr'
 .'0jhmf-';s,(.),!$1?' ':chr(ord($1)+1),eg;print;


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

Date: Fri, 12 Nov 1999 14:33:47 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Help needed fast please
Message-Id: <x3yogczqzc5.fsf@tigre.matrox.com>


"Randy Smith" <randys@NOSPAMamigo.net> writes:

> Chris <chris@chrismail.connectfree.co.uk> wrote in message
> news:382a87d4.0@news2.cluster1.telinco.net...

> : $ENV{qw(PATH IFS)} = '' x 2;
> Did you forget a " in this line?

No he didn't. Those are two single quotes. Not one double quote. You'd
better change your newsreader's font to differentiate between the two.

(I had this problem before).
--Ala



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

Date: Fri, 12 Nov 1999 13:55:37 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Help with Stoopid Nutscrape (Netscape)
Message-Id: <382C8CD9.79DE4E75@mail.cor.epa.gov>

Andrew Broadley wrote:
> 
> Hi all,

Howdy,
 
> When i print out on my perl script... IE is fine.. but Netscape only
> prints the HTML code... why is that ?

This is usually caused when the HTML or the header info 
(whether generated or not) is slightly malformed, to the extent
that Nyetscape Nauseator regards it as non-compliant.
Internet Exploder tries to display it anyway, unless it is 
irreparably munged.

So there's probably a small error in your code.

> ALL Help muchly appreciated!!

Okay, then:
Please do not submit 28-line sigs, or non-text components
when posting to Usenet [except in the binaries groups,
where they want binaries].  It will make others more
receptive to helping you in future.

Thanks in advance,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 12 Nov 1999 21:42:57 GMT
From: kazz@ashernet.net (Kazz Asher)
Subject: Re: how to parse dir recursively for files?
Message-Id: <382c8999.159086824@news.pajo.com>

>This is bad advice.

Kragen, perhaps you should take your medication. 90% of your posts are
merely to be an asshole. Refrain - is your keyword of the day.


><kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
>The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!
><URL:http://www.pobox.com/~kragen/bubble.html>



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

Date: Fri, 12 Nov 1999 14:53:03 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: How to use range operators with s///
Message-Id: <382C9A4F.6581F80F@mail.cor.epa.gov>

Keith Lee wrote:
> 
> I want to search through a file and strip a range of lines beginning with a
> start and end pattern. I understand how to use the range operators to
> extract these lines and maybe print them out, but I do not quite get how to
> use this in combination with a substitution to strip them away. I have tried
> this:
> 
> $_ =~ s//pattern1/ ... /pattern2/\b//g;
> 
> and naturally it does not work because I do not fully understand all the
> syntaxes. Is the a 'legal' approach, and could someone post a few pointers?

Legal syntax?  No.

If you already know how to extract those lines and print them,
then you have seen something like:

print if /pattern1/ .. /pattern2/;

Now consider what would happen if you replace 'if' with
'unless'.

Then read the perlop pages on the subject of 'range operators'.
For more info on using .. and ... , search the deja.com
archives of this newsgroup for posts using them.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 12 Nov 1999 14:39:18 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Installing new modules
Message-Id: <382C9716.39971164@mail.cor.epa.gov>

Johnny 'Loopy' Ooi wrote:
> 
> I have a Windows Version of Perl and I've got a pile of CPAN modules.
> How do I install them into Perl? I've got nmake15.exe from Microsoft's
> site. PPM only seems to get the ones from activestate.com and it doesn't
> have any modules that I want.

Well, remember that ppm can also access other sources of PPD
files.  Read the HTML docs which come with ActiveState Perl,
and you'll see a whole section on ppm.  So you can check some
other repositories first, before going this route.

Next, get the CPAN module working first.  You'll have to
answer some questions, and you'll want to snag copies of
tar and gzip off the net first.  And you'll need to run
nmake15.exe to unzip nmake.  Then let the CPAN module
do the install work for you on all those new modules.  
It's a lot easier than the alternative.

Also, some modules will require a C compiler.  nmake won't
do for that.  If you want the module to work with ActiveState
Perl, you'll probably want to get Microsoft's compiler.
Sorry.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 12 Nov 1999 20:47:54 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: list (array) programming question
Message-Id: <38307ca9.2756740@news.skynet.be>

Kevin Campbell wrote:

>the following works for me

Here's my version. It looks to me like it's basically the same algorythm
(although developed independently), and it uses the most obvious
approach: using recursion.

It's not obvious me how this is garanteed to work correctly. So I've
done my own version, using the most obvious approach: recursion.

Making sure sets are unique can easily be garanteed by keeping the
contents of each set in order.

Taking as an example the initial set qw(one two three four), each
possible set either contains 'one', or it doesn't. But the rest of the
set constitutes of a set picked out of qw(two three four) anyway.

So I combine () and ('one') with each item in the superset of qw(two
three four).

The net effect is pretty much like a binary counter.

	sub superset {
	    @_ or return []; 
	    my $first = shift;
	    return map { $_, [ $first, @$_ ] } superset(@_);
	}
	$, = "\n"; $\ = "\n";
	print map { "@$_" } superset(qw'one two three four');

-- 
	Bart.


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

Date: Fri, 12 Nov 1999 15:38:26 -0500
From: Chad <ccunning@math.ohio-state.edu>
Subject: microtime?
Message-Id: <382C7ABA.8E127F1B@math.ohio-state.edu>


How can I get a microtime or time more accurate than whole seconds in
perl? I'm trying to time various operations in a program and would like
to get better answers than 0 or 1 seconds... The benchmark stuff and
time() just do whole seconds, and I don't see any modules that look like
they can do better. I know there has to be a way!

-- 

Chad Cunningham
ccunning@math.ohio-state.edu


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

Date: 12 Nov 1999 14:03:47 -0700
From: Eric The Read <emschwar@rmi.net>
Subject: Re: microtime?
Message-Id: <xkf1z9v5sng.fsf@valdemar.col.hp.com>

Chad <ccunning@math.ohio-state.edu> writes:
> How can I get a microtime or time more accurate than whole seconds in
> perl? I'm trying to time various operations in a program and would like
> to get better answers than 0 or 1 seconds... The benchmark stuff and
> time() just do whole seconds, and I don't see any modules that look like
> they can do better. I know there has to be a way!

Try consulting the FAQ.

perlfaq8: "How can I measure time under a second?"

-=Eric
-- 
"Cutting the space budget really restores my faith in humanity.  It
eliminates dreams, goals, and ideals and lets us get straight to the
business of hate, debauchery, and self-annihilation."
                -- Johnny Hart


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

Date: Fri, 12 Nov 1999 15:17:56 -0600
From: Tom Briles <sariq@texas.net>
Subject: Re: microtime?
Message-Id: <382C8404.7F857719@texas.net>

Chad wrote:
> 
> How can I get a microtime or time more accurate than whole seconds in
> perl?

Perhaps someone has asked this question before.  In fact, perhaps this
Question is Asked Frequently.

- Tom


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

Date: Fri, 12 Nov 1999 14:25:18 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Module File:Find problem
Message-Id: <382C93CE.E4D0944B@mail.cor.epa.gov>

Abigail wrote:
> David Cassell (cassell@mail.cor.epa.gov) wrote on MMCCLXIV September
> MCMXCIII in <URL:news:382B604D.6B10375@mail.cor.epa.gov>:
[snip]
> ;; [3] checks whether symlinks have put you in an infinite loop
> ;;     of dirs;
> 
> Why? There are heaps of Unix utilities that can be forced to follow
> symlinks, and happily go into infinite loops if there is one. Why
> should a utility written in Perl be any different?

heh.  I just wanted to point out some of the inherent risks.
I didn't say I was re-writing File::Find .

> ;; [4] has a way to get back to your previous branching point
> ;;     if following a symlink puts you in a dir which has a
> ;;     totally different parent;
> 
> You really would have to write some twisted, ugly code to make this
> a problem. Any decently written program with properly scoped variables
> won't have this problem.

But I'm not giving this advice to you, or any other person
I know to have a background in CS and algorithms and Perl.
I thought it was important to point out this potential flaw,
given the apparent lack of Perl or CS background of the querent.
 
> ;; [5] copes with symlinks to dirs on other machines, some of which
> ;;     may not be accessible now; and
> 
> That's a problem not reserved for symlinks.

Oh yeah.  Tell me about it.  Why can't NFS be more robust?
Wait, that's a rhetorical question.  We're already far enough
off-topic here [one of my many gifts].
 
> ;; [6] all the other things I haven't remembered off the top of
> ;;     your head.
> 
> Are you also argueing that the -r option of rm is wrong, because
> someone could do 'rm -r /' ?

No, I think the -r option of rm is *right*, because I can
say 'rm -rf /' if I need to.  Just because someone can misuse
a tool doesn't make the tool bad.  I can shove a metal ladder
into a high-power line too, but that doesn't mean I'm going 
to start B.A.L.L. [Ban All Lethal Ladders]  :-)

> ;; Why do you think that you really *need* to follow all symlinks?
> 
> Why do you think a symlink is there in the first place?

No, my question was supposed to be "for the given app, is
there actually a need to follow symlinks, or can this be
done in other ways?"  I believe you misunderstood my intent.
If so, then maybe I wasn't clear to the querent either.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 12 Nov 1999 16:46:37 -0500
From: Grizlow <Grizlow@yahoo.com>
Subject: Need help understanding directory structure (NEWBIE)
Message-Id: <382C8ABD.50D91C4C@yahoo.com>

If I have a perl script in my cgi-bin directory on my server
and I want to write to a file that i keep in a diretory files
how do i reference this file..?  Is this the proper structure ?

When I try to do this with        --- open MYFILE,
"../files/myfile.data" I get an error.
When I do it with a direct path --- open MYFILE,
"c:/server/files/myfile.data"
 it works but I dont believe this is the correct way to do it....

Next question .....
If I want my script to send the browser to another html page
how do I do this with the Location header.....

I tried print "Location: /website1/index.html"  - this doesnt work
do I need to print anything before this first
and do I need to set a response code???

Thanks for your time and Patience



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

Date: Fri, 12 Nov 1999 14:45:03 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Need help with editing a word in a flat text file...
Message-Id: <382C986F.F932C833@mail.cor.epa.gov>

Slim wrote:
> 
> Hey!
> I'm trying to make a flat file database... text file"
> I want to let the users change thier info... it needs to work on win95

Umm, Slim, you've been referred to the FAQ, but...

Isn't this a massive security hole?  On win95, how will you
[1] keep a user from peeking in the file and seeing everyone
else's password and info?
[2] keep two users from trying to write to the file at the
same time and corrupting the file beyond repair?

#2 is solved by file locking on better OSes, including NT.
But win95 doesn't have file locking, or much else in the
way of security.  You may want to re-think your design here.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 1363
**************************************


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