[7306] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 931 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 27 12:17:23 1997

Date: Wed, 27 Aug 97 09: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           Wed, 27 Aug 1997     Volume: 8 Number: 931

Today's topics:
     Re: 'abandon' hope (was: Re: Need help: how to exit a s <rootbeer@teleport.com>
     Re: (stupid) pattern matching question <rootbeer@teleport.com>
     Re: [Q] Awk's "s in A" Hash Test In Perl? <rootbeer@teleport.com>
     Re: [Q] Awk's "s in A" Hash Test In Perl? <tom@mitra.phys.uit.no>
     Automata states limits in Perl <koutnik@pdb.pdb.bnl.gov>
     Re: Calling URL inside PERL <burleigh@hackberry.chem.niu.edu>
     Re: cardinality of an array given a reference <rootbeer@teleport.com>
     Re: cardinality of an array given a reference <tom@mitra.phys.uit.no>
     cgi and stdout <year9313@club.innet.be>
     Re: cgi and stdout <mturk@globalserve.net>
     complex pattern?!? it shouldn't be, i think :) jonathan.hulatt@unilever.com
     Re: complex pattern?!? it shouldn't be, i think :) <trandell@clark.net>
     Re: complex pattern?!? it shouldn't be, i think :) (Greg Bacon)
     Re: HELP! WinNT/perl cgi newbie (Marty Blase)
     Re: HELP!! Installing Perl 5.003 on DGUX (Greg Bacon)
     Re: How to print a PDF file automatically ? <rootbeer@teleport.com>
     Loop until a key is pressed? <espen.bjarno@myres.no>
     NO, you SHAN'T INTERPRET them no!no!no!no..no.....nooo. <markus.moll@off1.siemens.de>
     Re: perl and afs <bbense+comp.lang.perl.misc@telemark.stanford.edu>
     Re: perl extension in tcl lvirden@cas.org
     Re: perldb.pl not in @INC <bsugars@sunpub.com>
     Re: perldb.pl not in @INC <rootbeer@teleport.com>
     Re: Returning a hash list (associative array) (SJK)
     Re: Returning a hash list (associative array) (Mike Stok)
     SSI in SSI.. <fhurtubi@videotron.net>
     Re: Web PG Generator <rootbeer@teleport.com>
     Re: When to use "use strict" <rootbeer@teleport.com>
     which way is more efficient? <delaneys@worldnet.att.net>
     www.perl.com ? <dturley@rocketmail.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 27 Aug 1997 07:40:25 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Damian Conway <damian@cs.monash.edu.au>
Subject: Re: 'abandon' hope (was: Re: Need help: how to exit a sub)
Message-Id: <Pine.GSO.3.96.970827073556.1757G-100000@julie.teleport.com>

On 27 Aug 1997, Damian Conway wrote:

> You can get pretty close with:
> 
> 	open(FILE, $file) or
> 		return !warn "couldn't open $file: $!\n";

Not bad, but I'd probably use this.

	open FILE, $file or
	    (warn "couldn't open file '$file': $!" and return);

No, really, I'd use an unless statement in this case. No point in
confusing my maintenance programmer any further. Especially since I
usually have to be my own maintenance programmer. :-) 

> 	sub abandon
> 	{
> 		warn shift;
> 		goto &return;		# PROPOSED NEW goto MAGIC
> 	}
> 
> The logic is that "magic goto" replaces the call to its enclosing
> subroutine with a call to the goto's argument. If you replace a call
> to "abandon" with a call to "return" that ought to cause the
> subroutine that originally called "abandon" to immediately return. :-)

Hmmm....

    sub abandon {
	goto sub { warn shift; return }
    }

This is getting scary. :-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 27 Aug 1997 08:21:48 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: denis@mathi.uni-heidelberg.de
Subject: Re: (stupid) pattern matching question
Message-Id: <Pine.GSO.3.96.970827082033.1757L-100000@julie.teleport.com>

On Wed, 27 Aug 1997 denis@mathi.uni-heidelberg.de wrote:

> i am trying to find "IN A" in a line. with maybe more than one 
> space or tab between in and a. so i tried:
> 
> 	/IN\s+A/
> 
> but this didn't work. why?

Because of some error in the code you didn't show us. :-)  If you can make
a small (say, five line) script which doesn't do what you expect, please
post again. Thanks!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 27 Aug 1997 08:13:29 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: [Q] Awk's "s in A" Hash Test In Perl?
Message-Id: <Pine.GSO.3.96.970827081308.1757J-100000@julie.teleport.com>

On Wed, 27 Aug 1997, Eric Bohlman wrote:

> TMTOWTDI, but "defined($words{$name})" should do it.

I prefer exists to defined, in this case. Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 27 Aug 1997 17:31:33 +0200
From: Tom Grydeland <tom@mitra.phys.uit.no>
Subject: Re: [Q] Awk's "s in A" Hash Test In Perl?
Message-Id: <nqon2m3ve0a.fsf@mitra.phys.uit.no>

Tom Phoenix <rootbeer@teleport.com> writes:

> On Wed, 27 Aug 1997, Eric Bohlman wrote:
> > TMTOWTDI, but "defined($words{$name})" should do it.

> I prefer exists to defined, in this case. Hope this helps!

Perhaps a2p should be doctored to use exists over defined for this?

> Tom Phoenix           http://www.teleport.com/~rootbeer/

-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


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

Date: Wed, 27 Aug 1997 10:01:26 -0400
From: Jiri Koutnik <koutnik@pdb.pdb.bnl.gov>
Subject: Automata states limits in Perl
Message-Id: <34043335.E971BFE8@pdb.pdb.bnl.gov>

Hello !

I have trouble with matching very long regular expression in Perl and
Lex, because of
implementation of automata has too smal space of states.
The error is  "regexp too big" !

If anybody knows about some tools with no (or wide) limitations , let me
know please.
Any ideas would be greatly appreciated.

    Thanks
                Jiri

--

______________________________________
                                      |
 Jiri Koutnik                         |
 Protein Data Bank                    |
                                      |
 koutnik@pdb.pdb.bnl.gov              |
______________________________________|





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

Date: Wed, 27 Aug 1997 10:38:01 -0500
From: Darin Burleigh <burleigh@hackberry.chem.niu.edu>
Subject: Re: Calling URL inside PERL
Message-Id: <340449D9.7F93@hackberry.chem.niu.edu>

Lennie Jarratt wrote:
> 
> I am trying to have Perl call another URL and exit after some
> processing.  I am using IIS under Windows NT and full Perl.  I needed
> to read and write to a file.  Using
> 
>    print "Location: $URL"
> 
> just prints the line on my current page.  What do I need?  How do I do
> this?
> 
> Thanks,
> 
> Lennie


YACNPQ (yet another CGI not Perl question)....

a) you need to read the FAQ
b) you might want a content-type in there...
-- 
==========================================================
 - darin
burleigh@hackberry.chem.niu.edu
\\//\\//.\\//\\//.\\//\\//. http://hackberry.chem.niu.edu/HOME/dcb/
 '2 kinds of green, look out!' - dieter rot


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

Date: Wed, 27 Aug 1997 08:12:31 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Tom Grydeland <tom@mitra.phys.uit.no>
Subject: Re: cardinality of an array given a reference
Message-Id: <Pine.GSO.3.96.970827080354.1757I-100000@julie.teleport.com>

On 27 Aug 1997, Tom Grydeland wrote:

> For those just joining us, the heart of this thread is how and why
> 
> perl -le '$a=[1..100];print $#{@$a}'
> 
> works.
> 
> Tom Phoenix <rootbeer@teleport.com> writes:
> > [ To those reading along at home: Notice that @$a seems to be
> > automatically dereferenced here. Odd, isn't it? ]
> 
> Now, before terminology gets out of hand here, let me share with you
> some words from the mouth of the camel (p.245)
> 
> "To *reference* a variable, in the terminology of this chapter, is to
> create a hard reference to the thingy underlying the variable. [...]
> To *dereference* this scalar value is to use it to refer back to the
> original thingy, as you must do when reading or writing to the
> thingy."

Oops! You're right; I got my words backwards. (And I thought this was
confusing enough already! :-)

> perl -wle '$a=[1..10];print @{@$a}'	# prints nothing,
> 
> The following shouldn't work either (but do)
> 
> perl -wle '$a=[1..10];print ${@$a}[5]'	# prints 6
> perl -wle '$a=[1..10];print $#{@$a}'	# prints 9

As you've pointed out, we can also use %{ SOMEHASH } instead of 
%{ HASHREF }, at least in some cases. But you can't use ${ SCALAR } in
place of ${ SCALARREF } anyplace I've tried. Oh, well!

But you've convinced me that at least some of this behavior is a bug.
(It's still an open question IMHO just what the bug is. Arguably, it's the
use of undocumented syntax. :-)

> A second (and perhaps more compelling) argument: If somebody is
> passing a dereferenced <something> to an operator expecting a
> <something> it probably indicates a programmer error or a deeper
> misunderstanding of what is happening.

> IMHO, all of the above examples should give the error message:
> Not an ARRAY reference at -e line 1.

Agreed. I'd like to see Perl catch and outlaw this, or at least give a
warning when -w is on. 

> As for curious error messages, try this:
> perl -wle '$a={1..10};print $#{%$a}'
> Can't use an undefined value as an ARRAY reference at -e line 1.
> 
> It may not be the obvious ARRAY reference, but it's not undefined
> either, or is it?  Can somebody explain?

Itzabug. :-)

I think it's time to run perlbug and see what the developers have to say
about this. Since you discovered this phenomenon, would you like to do the
honors? 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 27 Aug 1997 17:41:18 +0200
From: Tom Grydeland <tom@mitra.phys.uit.no>
Subject: Re: cardinality of an array given a reference
Message-Id: <nqolo1nvdk1.fsf@mitra.phys.uit.no>

Tom Phoenix <rootbeer@teleport.com> writes:

> But you've convinced me that at least some of this behavior is a bug.
> (It's still an open question IMHO just what the bug is. Arguably, it's the
> use of undocumented syntax. :-)

[...]

> Itzabug. :-)

I'm glad you agree.

> I think it's time to run perlbug and see what the developers have to say
> about this. Since you discovered this phenomenon, would you like to do the
> honors?

Done.

> Tom Phoenix           http://www.teleport.com/~rootbeer/

-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


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

Date: Wed, 27 Aug 1997 17:03:15 +0200
From: tom van mierlo <year9313@club.innet.be>
Subject: cgi and stdout
Message-Id: <340441B3.273D@club.innet.be>

i'm writing an e-mail gateway with the cgi.pm library.
I'm writing this mail because i'm just a beginner.

the program i'm using is postmail for windows 95 and windows nt
When this program send the mail with success it doesn't return any
output and when it can't send the mail it does returns output.

I want to use this in my perl scrip but i can't check wether the program
sends any output back or not.

it tried the following : 

if (STDOUT) {
 ...
}

but this checking doesn't work

is there a way that this works, and so how do you use it ?
also i'm interested in redirecting the STDOUT.

Please help me


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

Date: Wed, 27 Aug 1997 10:59:12 -0400
From: Mike Turk <mturk@globalserve.net>
Subject: Re: cgi and stdout
Message-Id: <340440C0.1217@globalserve.net>

tom van mierlo wrote:
> 
> is it possible to check if a program returns an output
> and if so, can you redirect it to a file ?

Yes....., and yes.


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

Date: Wed, 27 Aug 1997 09:21:25 -0600
From: jonathan.hulatt@unilever.com
Subject: complex pattern?!? it shouldn't be, i think :)
Message-Id: <872691211.8014@dejanews.com>

hi.

I have an scalar srting with lines of an html file in. I would really
like to chop the tags out. I've had success using split etc. but isn't
there a pattern that would do it? I tried several ideas, but just end
up pulling out everything from first < to the last >.

ie

<body>
<h1>this is some text</h1>
</body>

should be cut down to 'this is some text'

Thanks a lot.

Jon Hulatt

PS. Response via email greatly appreciated

slippy@mailexcite.com

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


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

Date: Wed, 27 Aug 1997 11:01:43 -0400
From: "Terrence J. Randell" <trandell@clark.net>
To: slippy@mailexcite.com
Subject: Re: complex pattern?!? it shouldn't be, i think :)
Message-Id: <34044155.668F@clark.net>

Quick and dirty way to do it is:

  #!/wherever/you/have/perl
  $infile = "file you want to work on";
  $outfile = "file to save plaintext output";

  open HTMLFILE, "<$infile";
  open TEXTFILE, ">$outfile";
  while($line = <HTMLFILE>) {
    if($line =~ /<\/*\w+>/) {
       $line =~ s/<\/*\w+>//g;
       print TEXTFILE $line;
    }
  }
  close TEXTFILE;
  close HTMLFILE;
  exit;

This won't work for complex tags such as <a href="..."> or <meta
name="..." content="..."> but you get the idea of how to procede.  The
meat of it is the search and replace s/<\/*\w+>//g.  \/* matches 0 or
more /.  \w+ matches 1 or more word characters a-z, A-Z, _, or 0-9.

To get rid of href or meta tags just write a little more specialized
pattern match.

Terrence Randell
trandell@clark.net

jonathan.hulatt@unilever.com wrote:
> 
> hi.
> 
> I have an scalar srting with lines of an html file in. I would really
> like to chop the tags out. I've had success using split etc. but isn't
> there a pattern that would do it? I tried several ideas, but just end
> up pulling out everything from first < to the last >.
> 
> ie
> 
> <body>
> <h1>this is some text</h1>
> </body>
> 
> should be cut down to 'this is some text'
> 
> Thanks a lot.
> 
> Jon Hulatt
> 
> PS. Response via email greatly appreciated
> 
> slippy@mailexcite.com
> 
> -------------------==== Posted via Deja News ====-----------------------
>       http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 27 Aug 1997 15:36:44 GMT
From: gbacon@adtran.com (Greg Bacon)
To: slippy@mailexcite.com
Subject: Re: complex pattern?!? it shouldn't be, i think :)
Message-Id: <5u1hic$t89$2@info.uah.edu>

[Posted and mailed]

In article <872691211.8014@dejanews.com>,
	jonathan.hulatt@unilever.com writes:
: I have an scalar srting with lines of an html file in. I would really
: like to chop the tags out. I've had success using split etc. but isn't
: there a pattern that would do it? I tried several ideas, but just end
: up pulling out everything from first < to the last >.

You want Tom Christiansen's "striff tummel" script which lives at

    http://www.perl.com/CPAN/authors/id/TOMC/scripts/striphtml.gz

Hope this helps,
Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Wed, 27 Aug 1997 10:28:52 +0000
From: mblase@ncsa.uiuc.edu (Marty Blase)
Subject: Re: HELP! WinNT/perl cgi newbie
Message-Id: <mblase-2708971028520001@mblase.ncsa.uiuc.edu>

Thanks to everyone for their help! I thought I'd just summarize the
comments I'd gotten for anyone else needing this info:


> - what do filenames look like? (Just C:\dir\dir\file.txt, right?)

Apparently, backslashes work just fine under the perl interpreter, unless
you're running native NT commands - in which case double-frontslashes are
needed to escape them properly under perl.

> - what's the NT equivalent of sendmail, and how to I call it?

Blat 1.5 comes well-recommended for WinNT, apparently.
(http://gepasi.dbs.aber.ac.uk/softw/Blat.html) I also found something
called Windmail 2.0, which is basically a port of UNIX sendmail, but it's
a commercial product. (http://www.geocel.com/windmail/)

> - what do I put at the top instead of #!/usr/local/bin/perl ?

Looks like I don't have to put anything up there at all; the WinNT
registry identifies the .pl extension as a perl script automagically.

Thanks for everyone's help!


               Marty Blase - mblase@ncsa.uiuc.edu
        =================================================
          The Unofficial Handbook to the X-Men Universe
                  http://x-page.com/Handbook/


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

Date: 27 Aug 1997 15:17:22 GMT
From: gbacon@adtran.com (Greg Bacon)
To: "Leigh Carpenter" <leighc@mincom.com>
Subject: Re: HELP!! Installing Perl 5.003 on DGUX
Message-Id: <5u1ge2$t89$1@info.uah.edu>

[Posted and mailed]

In article <01bcb279$0a3a2160$68b537c0@herne.mincom_oz>,
	"Leigh Carpenter" <leighc@mincom.com> writes:
: I am in desperate need of help. I am trying to build perl 5.003 on a DGUX
: AViion.

You won't find many people who are willing to help you install 5.003.
The latest and greatest perl (usually) lives at

     http://www.perl.com/CPAN/src/latest.tar.gz

This link will (as of this writing) retrieve perl5.004_01.tar.gz.

Hope this helps,
Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Wed, 27 Aug 1997 08:17:21 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Pascal AMRAM <pascal_amram@ml.com>
Subject: Re: How to print a PDF file automatically ?
Message-Id: <Pine.GSO.3.96.970827081527.1757K-100000@julie.teleport.com>

On Wed, 27 Aug 1997, Pascal AMRAM wrote:

> How to print a pdf file with perl ?

I'd have perl fire up your pdf viewer, using some command line option to
ask it to print. But there's not much perl in this answer, is there?  :-)
Hope this helps! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 27 Aug 1997 16:25:27 +0200
From: "Espen Bjarnx" <espen.bjarno@myres.no>
Subject: Loop until a key is pressed?
Message-Id: <5u1dhc$qij@daneel.sds.no>

 All,

I'm trying to make a script that dump some information until a key is
pressed.
Ie. the key 'q' is pressed for quit aso. (It works with CTRL-C but.. :-))

How?

-Espen.






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

Date: Wed, 27 Aug 1997 16:18:01 +0200
From: Markus Moll <markus.moll@off1.siemens.de>
Subject: NO, you SHAN'T INTERPRET them no!no!no!no..no.....nooo.....
Message-Id: <34043718.70F1765E@off1.siemens.de>


--------------E79D4736671A7AB5F44887B5
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I'm having the same problem as Kirk L. Israel had.
I want my Perlscript not to interpret the backslashes,dollar chars etc.
In fact, I got little help by Andrew M. Langmead, who proposed :

          Andrew M. Langmead wrote:

    >  kisrael@allegro.cs.tufts.edu (Kirk L. Israel) writes:
    >
    >  >Now if only I could get blockquoting WITH variable
    >  interprolation and
    >  >WITHOUT interpreting \n and \'
    >
    >  How about if you do the variable interpolation yourself?
    >
    >  $var = 'val';
    >
    >  $here = <<'END_OF_HERE_DOCUMENT';
    >  This is the point where I want to interpolate $var\n
    >  END_OF_HERE_DOCUMENT
    >
    >  $here =~ s/\$(\w+)/${$1}/g;
    >  print $here;
    >  --
    >  Andrew Langmead



Actually, this works great with all those $.  But I don't manage to get
the same with \ !
I thought it was code like this : $text =~ s/\\(\w+)/\{$1}/g  But for
any reason this doesn't work !
Help me quick or I'll become insane
(You'd better not risk that o.k. ... I mean ... I'll find your house ...
hehehe ...)

--------------E79D4736671A7AB5F44887B5
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
I'm having the same problem as Kirk L. Israel had.
<BR>I want my Perlscript not to interpret the backslashes,dollar chars
etc.
<BR>In fact, I got little help by Andrew M. Langmead, who proposed :
<UL>
<DD>
<FONT SIZE=-1>Andrew M. Langmead wrote:</FONT></DD>

<BLOCKQUOTE TYPE=CITE><FONT SIZE=-1>kisrael@allegro.cs.tufts.edu (Kirk
L. Israel) writes:</FONT>

<P><FONT SIZE=-1>>Now if only I could get blockquoting WITH variable interprolation
and</FONT>
<BR><FONT SIZE=-1>>WITHOUT interpreting \n and \'</FONT>

<P><FONT SIZE=-1>How about if you do the variable interpolation yourself?</FONT>

<P><FONT SIZE=-1>$var = 'val';</FONT>

<P><FONT SIZE=-1>$here = &lt;&lt;'END_OF_HERE_DOCUMENT';</FONT>
<BR><FONT SIZE=-1>This is the point where I want to interpolate $var\n</FONT>
<BR><FONT SIZE=-1>END_OF_HERE_DOCUMENT</FONT>

<P><FONT SIZE=-1>$here =~ s/\$(\w+)/${$1}/g;</FONT>
<BR><FONT SIZE=-1>print $here;</FONT>
<BR><FONT SIZE=-1>--</FONT>
<BR><FONT SIZE=-1>Andrew Langmead</FONT></BLOCKQUOTE>
<FONT SIZE=-1>&nbsp;</FONT></UL>
Actually, this works great with all those $.&nbsp; But I don't manage to
get the same with \ !
<BR>I thought it was code like this : $text =~ s/\\(\w+)/\{$1}/g&nbsp;
But for any reason this doesn't work !
<BR>Help me quick or I'll become insane
<BR>(You'd better not risk that o.k. ... I mean ... I'll find your house
 ... hehehe ...)</HTML>

--------------E79D4736671A7AB5F44887B5--



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

Date: 27 Aug 1997 14:27:44 GMT
From: <bbense+comp.lang.perl.misc@telemark.stanford.edu> ;
Subject: Re: perl and afs
Message-Id: <5u1dh0$ok7$1@nntp.Stanford.EDU>



In article <3404195C.F06FB85@absyss.fr>, Doug Seay  <seay@absyss.fr> wrote:
>Nick Weavers wrote:
>> 
>> I have a perl script that attempts to ensure that it's input file
>> (passed in by the user) exists and is readable so I use the -e and
>> -r filetest operators. However, we work under AFS and I am finding that
>> if my token has expired the -r does not tell me that I cannot read the.
>> 
>> This is probably because -r reads the unix file permission bits and
>> doesn't know anything about AFS.
>> 
>> Is there someway I can make perl AFS aware, or is there perhaps a module
>> that might help me. (I took a look in the module list but could not see
>> anything published).
>
>Did you switch to AFS since you last built perl?  Or did you build on a
>non-AFS system?  I'm asking this because when building perl, there is a
>bit about AFS.  Since I don't use AFS, I don't remember the details. 
>Maybe you should try rebuilding and see if that helps.
>

- - The questions about AFS are just to help with the install, they don't 
do anything about the real problem. I have yet to find an stat based
solution that works portably across all platforms. The best you can
do is to attempt to open the file and catch the error condition. Another
trick that seems to work for me is to use -r on the directory that the
file is in. At this level AFS and Unix permission bits are roughly in
sync. 

- - An even harder problem is deciding whether you can write to a file 
in AFS or not. Here's my last attempt at the problem. 

# return true if kinit not needed
 
sub can_write_file { 
    local($file ) = @_ ; 
    local($w,$open) ; 
    if  (   -w  "$file" ) {     #does not work
        $DEBUG && print "Passed -w\n" ; 
        $w = 1 ; 
    }
    if (   open( FOO ,">> $file" )) {
        # This does not work on ultrix , works on suns though 
        $DEBUG && print "Passed  open \n" ; 
        close FOO; 
        $open = 1 ; 
    } 
    close FOO; 
    if ( $w || $open  ){ 
        return 1 ; 
    } else { 
        return 0 ; 
    }
 
 
}


- - Booker C. Bense : bbense@stanford.edu  




Version: 2.6.2

iQCVAwUBNAQ5WAD83u1ILnWNAQGUEgQA2jwxOoZby2RfgeiZ08Ob9wGfouO0M117
lLCyG2WeorqAAAceEbB4EWbdJpwetYJBT8X2pTByRnEyWZa/edVX5ufSk2sl3sWE
fN78Pg4HMDw3a7OP0WX8gBwlYhfr2MjqVSyLwRyUPe3zILh6jagBdJYxle6S0mdy
ECR+oW7sP5o=
=fdJ8
-----END PGP SIGNATURE-----


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

Date: 27 Aug 1997 14:53:12 GMT
From: lvirden@cas.org
Subject: Re: perl extension in tcl
Message-Id: <5u1f0o$6ek$1@cas.org>


According to Rick Evans  <evans@engineous.com>:
:Has anyone written a perl extension to tcl, so that I could use perl
:commands invoked within a namespace so I do not have name conflicts
:between tcl and tk and do not have to create a separate process by
:invoking perl using the exec command?
:
:I am not refering to PerlTk which allows Tk to be used within
:Perl to build a GUI.  I would like to invoke a perl script that
:parses a file and creates another so I have no global variables
:being passed between tcl and perl.  I merely want to call an existing
:Perl 5 program we have with command line arguments and depending on
:the exit status of the Perl program operate on the file that Perl
:created.


Another way of expressing this is

has anyone tried embedding a perl interpreter into a tcl extension or
in some way (perhaps using SWIG, etc.) tried to make available
(as Tcl commands), the perl interpreter.

I've talked off line to this user and exec is 'too slow' for the application
they have going.

-- 
Larry W. Virden                 INET: lvirden@cas.org
<URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
Unless explicitly stated to the contrary, nothing in this posting should
be construed as representing my employer's opinions.


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

Date: Wed, 27 Aug 1997 11:05:27 -0400
From: Benjamin Sugars <bsugars@sunpub.com>
Subject: Re: perldb.pl not in @INC
Message-Id: <34044237.5476@sunpub.com>

Simon Peate wrote:
> 
> I have installed perl version 4 on two HP-UX systems,  but on one of the
> systems I get the following error message when I invoke the debugger:
> 
>   perl -d <script>
>   Can't locate perldb.pl in @INC

Perl version 4 is dead, dead, dead...

Upgrade to version 5.004.

-Ben

--
Ben Sugars <bsugars@canoe.ca>
Senior Webmaster,
CANOE Canadian Online Explorer,
http://www.canoe.ca/


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

Date: Wed, 27 Aug 1997 08:46:53 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Simon Peate <simon@century.demon.co.uk>
Subject: Re: perldb.pl not in @INC
Message-Id: <Pine.GSO.3.96.970827082258.1757N-100000@julie.teleport.com>

On Tue, 26 Aug 1997, Simon Peate wrote:

> I have installed perl version 4 

Well, there's your problem. :-)  Try installing 5.004. 

> on two HP-UX systems,  but on one of the
> systems I get the following error message when I invoke the debugger:
> 
>   perl -d <script>
>   Can't locate perldb.pl in @INC
> 
> Everything seems to work except the debugger on one of the machines.

Sounds as if either perldb.pl was not installed where it should have been,
or your @INC path (compiled into your perl binary) doesn't include all of
the directories you wanted it to have. If you must use antique software
:-) you may need to re-compile it, or to make sure that perldb.pl is
copied to the right directory. Good luck! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 27 Aug 1997 15:04:33 GMT
From: knetsch@golden.net.no.spam (SJK)
Subject: Re: Returning a hash list (associative array)
Message-Id: <340441d2.8482252@news.golden.net>

On 26 Aug 1997 19:33:59 GMT, news@bofh.com (Jot Powers) wrote:

Program 1
>#!/usr/local/bin/perl -w
>use strict;
>my (%test);
>sub families {
>   my(%name);
>   $name{'Fred'}="Flinstone";
>   $name{'Barney'}="Rubble";
>   return %name;
>}
>%test = &families();
>print "Output was:" . $test{"Fred"} . "\n";
>
>Output was:Flinstone
>
>Now, that appears to solve your problem, but I don't believe it 
>does:
>To quote perlsub:
>     The Perl model for function call and return values is
>     simple: all functions are passed as parameters one single
>     flat list of scalars, and all functions likewise return to
>     their caller one single flat list of scalars.  Any arrays or
>     hashes in these call and return lists will collapse, losing
>     their identities--but you may always use pass-by-reference
>     instead to avoid this.  Both call and return lists may
>

Program 2:

>my ($temp);
>sub families {
>   my(%name);
>   $name{'Fred'}="Flinstone";
>   $name{'Barney'}="Rubble";
>   return \%name;
>}
>$temp = &families();
>print "Output was:" . $temp->{'Fred'} . "\n";

Just a meek little question from a relative newbie to PERL.  (Can you tell from
my posts??)

If the return of a hash is a flat list of scalars, is it not safe to simply
store the list in a ne hash?  ie, if the flat list of scalars is returned in
key,value,key,value,key,value etc. order, is it necessary to be concerned
whether its a hash or a list of scalars being returned?   

If you should not store the returned list in a hash (Program 1)  handling hashes
will cause the calling program to go through convoluted motions (Program 2) to
handle the returned data.  Yuck factor here.

Continually seeking new knowledge....

Sorry about the filling here, my news server requires more new text than
included text.
1
2
3
4
5
6
7
8
9
10


Stuart Knetsch

Remove the you know what from my address to send me E-mail


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

Date: 27 Aug 1997 15:53:36 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Returning a hash list (associative array)
Message-Id: <5u1ii0$e58@news-central.tiac.net>

In article <340441d2.8482252@news.golden.net>,
SJK <knetsch@golden.net.no.spam> wrote:

>If the return of a hash is a flat list of scalars, is it not safe to simply
>store the list in a ne hash?  ie, if the flat list of scalars is returned in
>key,value,key,value,key,value etc. order, is it necessary to be concerned
>whether its a hash or a list of scalars being returned?   

You can populate a hash with a list returned from a subroutine OK, as long
as ther list has an even number of elements.  If the list has been
generated by flattening a hash into a list then it will have an even
number of elements.  When you return a hash it's turned into a list of
scalars, so you needn't be concerned.  One thing returning a reference
buys you (apart from the obvious savings if you're shunting around huge
hashes) is that it's possible to do some kind of type checking at the
receiveing end if you want to be paranoid...

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Wed, 27 Aug 1997 10:38:04 -0400
From: Fred Hurtubise <fhurtubi@videotron.net>
Subject: SSI in SSI..
Message-Id: <34043BCC.18F0@videotron.net>

Hi,

I don't know if you have time to help me out on this...but
I figured I would try! :)

Problem : I have a perl script wich reads a html file 
containing a SSI...does a bunch of things and print 
everything back...What's wrong is while using
Content-type: text-html\n\n, the call to the SSI
(<--#exec cgi="/foo/foo.cgi" -->) is not executed, but
simply printed in the output...

Is there a solution to this SSI in SSI problem?

Please reply via email if possible...
fhurtubi@videotron.net


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

Date: Wed, 27 Aug 1997 08:48:26 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Anagrams of the Word 'A' <jefpin@bergen.org>
Subject: Re: Web PG Generator
Message-Id: <Pine.GSO.3.96.970827084735.1757O-100000@julie.teleport.com>

On Wed, 27 Aug 1997, Anagrams of the Word 'A' wrote:

> >Has anyone built or run accross a CGI/PERL Instant Web Page Generator?
> >Please let me know of any or anyone who can create one.
> 
> Geocities, and many online free w.p. services have one.  I'll make you one
> for free if you want... doesn't take too long.

Post it here, if you do, so that all of us can help you to plug any
security holes. Thanks!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 27 Aug 1997 08:01:36 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Scott  Wimer <scottw@cgibuilder.com>
Subject: Re: When to use "use strict"
Message-Id: <Pine.GSO.3.96.970827074330.1757H-100000@julie.teleport.com>

On Wed, 27 Aug 1997, Scott  Wimer wrote:

> My assumption was that the my variables were in stored internally in
> list format, and would therefore be much faster than haveing to do the
> hash calculations, if you did not have an enormous number of my()'d
> variables in each block.

Even if you do have an enormous number of my() variables, they're faster
than globals. The compiler turns $lexical into code which points right at
it, as I understand. 

> As to `use strict': I turn it on for script development and while I'm
> working on fine tuning stuff, but after that, I turn it off.  That way
> I don't pay the small performance penalty when the code is in
> production.

Do you also carry the baby in the trunk so that you won't pay the
not-so-small performance penalty of strapping it into a car seat? :-) 

Seriously, use strict has three parts. As I understand things, 'vars'
should have essentially no performance penalty, 'subs' should have
essentially no performance penalty, and 'refs' should have essentially no
performance penalty. :-) If you find that 'use strict' slows your
real-world program by enough to notice (say, one-tenth of a second), I'd
say that something is seriously wrong. (If it speeds things up, on the
other hand... :-)

Now, if you're writing CGI scripts and worrying that they may be
called hundreds of times per minute, there might be a reason to want to
shave every millisecond. That is, if it weren't for the excellent mod_perl
for Apache, which eliminates much bigger overhead costs such as loading
delay and internal compile time. From what I've seen, I'd expect it to
make a typical CGI script of mine run on the order of 20 (!) times faster. 

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 27 Aug 1997 10:29:04 -0400
From: "SD" <delaneys@worldnet.att.net>
Subject: which way is more efficient?
Message-Id: <5u1dih$iis@mtinsc05.worldnet.att.net>

Does anyone know which approach is more efficient and uses less memory (and
why?)? I wrapped the times function around the code and in both cases
execution time is reported as 0.00 CPU seconds. Thanks.

 ------ This way?

sub grab_data {

$start = (times)[0];

   open (DB,"<$db") || die "Oops! The read failed: $!\n";
   @listitem = <DB>;
   close(DB);

   foreach $listitem (@listitem) {

($julian,$date,$sponsor,$name,$title,$company,$street,$city,$state,$zipcode,
$country,$email) = split(/\|/,$listitem);

     if ($lastweek =~ /$julian/) {
     print "Date received: $date\n";
     print "Sponsor: $sponsor\n";
     print "Name: $name\n";
     print "Title: $title\n";
     print "Company: $company\n";
     print "Street: $street\n";
     print "City: $city\n";
     print "State: $state\n";
     print "Zipcode: $zipcode\n";
     print "Country: $country\n";
     print "Email: $email\n\n";
     }
  }
   close(DB);

$end = (times)[0];
printf "That took %.2f CPU seconds\n", $end - $start;
 }


------ OR this way?

sub grab_data {

$start = (times)[0];

   open (DB,"<$db") || die "Oops! The read failed: $!\n";
   while (<DB>) {


($julian,$date,$sponsor,$name,$title,$company,$street,$city,$state,$zipcode,
$country,$email) = split(/\|/);

     if ($lastweek =~ /$julian/) {
     print "Date received: $date\n";
     print "Sponsor: $sponsor\n";
     print "Name: $name\n";
     print "Title: $title\n";
     print "Company: $company\n";
     print "Street: $street\n";
     print "City: $city\n";
     print "State: $state\n";
     print "Zipcode: $zipcode\n";
     print "Country: $country\n";
     print "Email: $email\n\n";
     }
  }
   close(DB);
$end = (times)[0];
printf "That took %.2f CPU seconds\n", $end - $start;
 }






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

Date: Wed, 27 Aug 1997 09:41:13 -0600
From: David Turley <dturley@rocketmail.com>
Subject: www.perl.com ?
Message-Id: <872692569.9233@dejanews.com>

Does anybody know what has happened to www.perl.com?

I added the "Programming Republic of Perl" logo to my page and now the
link returns a "Document contains no data" error.

Just what does this error anyway?

cheers,

David
Using RocketMail so the spammers don't get my real address

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


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

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

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