[13062] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 472 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 12 00:07:28 1999

Date: Wed, 11 Aug 1999 21:05:09 -0700 (PDT)
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, 11 Aug 1999     Volume: 9 Number: 472

Today's topics:
    Re: 'use strict' - what will I lose if I forgo the prag <ltl@rgsun40.viasystems.com>
    Re: Another quick question...Arrays...testing against (Larry Rosler)
    Re: Another quick question...Arrays...testing against (BXTC)
        Are Perl/Windows Sockets only for WIN NT? <thecure1@mediaone.net>
    Re: Browser detection - write different html (Donovan Rebbechi)
    Re: Browser detection - write different html (Abigail)
    Re: Can I Pass Object refs as parameters to a new objec (Donovan Rebbechi)
    Re: CHMOD function <stirling@banet.net>
    Re: CHMOD function (Martien Verbruggen)
    Re: How to delete an element from an array (Charles DeRykus)
    Re: How to delete an element from an array (Larry Rosler)
    Re: Improving speed of a sub <dhill@sunbeach.net>
    Re: is our reese the author of mysql book? <uri@sysarch.com>
    Re: is our reese the author of mysql book? <markm@nortelnetworks.com>
    Re: is our reese the author of mysql book? <ltl@rgsun40.viasystems.com>
    Re: JavaScript recieving variables from Perl <rootbeer@redcat.com>
    Re: lock_nb <rootbeer@redcat.com>
    Re: Looking for a good Perl Book <uri@sysarch.com>
    Re: Looking for a good Perl Book (Abigail)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 12 Aug 1999 02:28:44 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: 'use strict' - what will I lose if I forgo the pragma?
Message-Id: <7otbgs$873$1@rguxd.viasystems.com>

Tom Christiansen <tchrist@mox.perl.com> wrote:

:>In comp.lang.perl.misc, 
:>    Phil Voris <pvoris@earthlink.net> writes:
:>:I 'use strict;' because I think it makes for better programs.  However, I
:>:am currently working on a program for which I have the option to use a .rc
:>:config file containing executable Perl code (actually a large
:>:configuration hash).  In order to add this functionality, I would have to
:>:forgo the strict pragma because I cannot my the configuration hash.  

:>Huh?  What does that have to do with anything?  

[snip explanation of lexical scoping of "use strict"]

Allow me to interpret. He wants his "required" file to set variables
in his namespace.  But since the required file is in a different
lexical scope, it can't affect lexically scoped variables in 
his main program file.


:>:What sort of performance hit should I expect if all code -- excepting this
:>:one configuration hash -- complies to strict, but the strict pragma is not
:>:used?

:>Performance is the wrong question; sanity and correctness are what it
:>will get you. :-)

So the presumed (my presumption) right question is "how can I use
strict and still set variables in my program from a configuration
file written in perl?"

Global variables aren't necessarily evil and the "use strict"
pragma just needs to be told which global variables you intend to use.  
For example:

use strict;
use vars qw/ %config_hash $debug_level /;
require "myconfigfile"; # @INC issues ignored
# myconfigfile is expected to set the global variables %config_hash
# and $debug_level


Lexically scoped variables are supposed to be slightly faster than
dynamically scoped ones and this may be what led Phil to ask about
efficiency, but in this case the difference is lost in the noise.

There are several useful recipes for configuration files 
in the Perl Cookbook.

I wish I could point you at the best documentation to reinforce
your understanding of scoping, but it took so many different
texts (and repeated readings) to sink into my own skull...

Also, "perldoc script" for how to adjust the restrictions to
suit your needs.

HTH

-- 
// Lee.Lindley   /// Programmer shortage?  What programmer shortage?
// @bigfoot.com  ///  Only *cheap* programmers are in short supply.
////////////////////    50 cent beers are in short supply too.


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

Date: Wed, 11 Aug 1999 19:53:06 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Another quick question...Arrays...testing against
Message-Id: <MPG.121bd6ecbd1c2192989e42@nntp.hpl.hp.com>

In article <r9ls3.98$1B5.7574@monger.newsread.com> on Wed, 11 Aug 1999 
20:36:39 GMT, (BXTC) <bxtc@forfree.at> says...
 ... 
> $target  =  9 (and it is actually the number of elements in another
> array....$#target)

Along with all the other bobbles already noted, let me just observe that 
if there is another array, @target, then $#target is not the number of 
elements in that array (unless someone has played with $[, which they 
damned well oughtn't have).

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 12 Aug 1999 03:55:23 GMT
From: "(BXTC)" <bxtc@forfree.at>
Subject: Re: Another quick question...Arrays...testing against
Message-Id: <LArs3.422$1B5.21226@monger.newsread.com>

Thanks for all of the replies, because of them I was able to figure a much
better method.

<SNIP>
>Along with all the other bobbles already noted, let me just observe that
>if there is another array, @target, then $#target is not the number of
>elements in that array (unless someone has played with $[, which they
>damned well oughtn't have).


Thanks for pointing that out, at the time(early in the morning) I misread
"Learning Perl"....it stated  ."You can use $#fred to get the index value of
the last element" which I misinterprited as the reference number [*].

Thanks again to all who responded.






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

Date: Wed, 11 Aug 1999 23:33:47 -0400
From: "CL" <thecure1@mediaone.net>
Subject: Are Perl/Windows Sockets only for WIN NT?
Message-Id: <Sfrs3.2778$5E3.105399@ndnws01.ne.mediaone.net>

Can one use perl to write sockets for the Win95 version of Perl???
Or does it only work for NT Win32???
Thanks




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

Date: 11 Aug 1999 22:43:03 -0400
From: elflord@news.newsguy.com (Donovan Rebbechi)
Subject: Re: Browser detection - write different html
Message-Id: <slrn7r4d5m.7p8.elflord@panix3.panix.com>

On Tue, 10 Aug 1999 06:58:30 -0700, Robert wrote:
>What we are looking for is a perl/cgi script or a java script that will
>accomplish the following...When a user comes to our page, the script will

DO NOT USE PERL/CGI TO DO THIS.

This is an expensive an inneficient way to do it. 

There are a few better ways:

*	SSI ( much simpler and cleaner. See mod_include docs if you have apache ) 
I'm pretty certain that this would be better perf wise, but how much 
I don't know. ( does apache need to fork() to handle an SSI directive
that just involves testing the client and possibly inserting a file ? ) 

*	Just use javascript ( which runs on the client )

*	Use gracefully degrading HTML code ( such as CSS ) that works 
with any browser.

-- 
Donovan


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

Date: 11 Aug 1999 22:56:16 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Browser detection - write different html
Message-Id: <slrn7r4hed.d88.abigail@alexandra.delanet.com>

Frank Krul (fkrul@acc.com) wrote on MMCLXXI September MCMXCIII in
<URL:news:37B1AA6D.D90C61D4@acc.com>:
<> Robert,
<> 
<> First of all let me apologize for most of these respondents.  Truly this
<> newsgroup does have a few helpful souls.
<> 
<> #1:  Even though some people say otherwise, since 94 my stats from a number o
<> different servers have never had problem identifying the HTTP_USER_AGENT
<> environment variable from any client.   Any browser that does not follow the
<> HTTP1.0 or 1.1 protocol and identify itself is non-standardized, and I've nev
<> see one.  Even home made browsers have IDs (it's the ego at work).  Web
<> anonymizers are out there, that will downgrade their browsers in the eyes of
<> your code logic...but they can always press a link to get the "high bandwidth
<> button if they so choose on your page.

Just because there were stupid document authors out there that made
their page only accessable for a few browsers, browsers started lying
in their User-Agent field. Yeah, sure, I believe you that since 94,
the HTTP_USER_AGENT contains *A* value. However, I don't believe it
means anything. And I don't believe you can prove it does.

Now, what does "high bandwidth" have to do with "shockwave capable"?

<> #2 Do this is in Javascript.  It's easy, your server is less utilized allowin
<> it to dessiminate pages instead of making decisions for those who don't know
<> what browser they have.  (Are you providing an elegant solution or assuming y
<> demographic are morons who can't id their software's capabilities?)

Not everyone has Javascript. Or has Javascript enabled. The entire reason
for the existence of the WWW was to *AVOID* having to make more than one
format of a document. You truly believe the old days were good, don't you?

<> #3 This is a perl newsgroup, go here:
<> http://developer.netscape.com
<> to get the code and get lost. ;)

Netscape is most evilish thing that happened to the computer world since
1666. I don't think you'll find an unbiased discussion at that site.


[Followups set]


Abigail
-- 
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 11 Aug 1999 22:50:43 -0400
From: elflord@news.newsguy.com (Donovan Rebbechi)
Subject: Re: Can I Pass Object refs as parameters to a new object?
Message-Id: <slrn7r4dk2.7p8.elflord@panix3.panix.com>

On Sat, 7 Aug 1999 09:13:07 -0700, Tom Phoenix wrote:
>On Fri, 6 Aug 1999, Madness wrote:

>BTW, you do know that you don't have to use objects in Perl to make a
>program efficient, don't you? Quite the opposite. Don't tell any

To me it's more about maintainability, coherence and reusability.

I've found that the OO code works very nicely when writing modules:
 * 	partly because OO and modularity are compatibe concepts, 
 
 * 	 partly because when you say 
 	my $ftp=new Net::FTP; 
	$ftp->login(@login_args);
	...
it's clear that you really are calling methods on a Net::FTP
object. 

I've also found that when you want some chunks of code that don't 
know about each others internals ( ie you want to seperate the UI 
from the main body of code ), it works nicely.

Of course, OO is not the be all and end all, and probably isn't 
useful with small programs. But with larger programs, I've found it
a godsend. YMMV

-- 
Donovan


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

Date: Wed, 11 Aug 1999 22:16:24 -0400
From: <stirling@banet.net>
Subject: Re: CHMOD function
Message-Id: <37b22ce2@news1.us.ibm.net>


Tom Briles wrote in message <37B17DF4.6B896B55@texas.net>...
>stirling@banet.net wrote:
>>
>> >Your solution is *only* different from the original poster's in that
>> >it's slower.
>> >
>> >It doesn't fix anything.
>
>> ----And yet the funny thing is, it works.
>
>You're missing the point.  Let's start over.
>
>The original poster stated that this did not work for him/her:
>
>$OrignialLogFile = 'sample.txt';
>
>You recommended:
>
>$orig="sample.txt";
>
>1) The only difference is single quotes vs. double.
>2) If one works, both work.  Yours is slower because Perl has to look
>for things to interpolate.
>
>As has been stated in replies to the original post, the problem lies
>elsewhere.
If you don't believe me try my testing methods as described in my last
follow up to Malcom Ray.  Then instead of posting the same argument over and
over again, you will see that I'm right or if doesn't work for you, you will
see that I am wrong instead of just theoritically *supposing* that I am
wrong.

--
Stirling





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

Date: Thu, 12 Aug 1999 03:34:58 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: CHMOD function
Message-Id: <Chrs3.240$gi1.46481@nsw.nnrp.telstra.net>

In article <37b22ce2@news1.us.ibm.net>,
	<stirling@banet.net> writes:

> If you don't believe me try my testing methods as described in my last
> follow up to Malcom Ray.

The last response of you to Malcolm Ray is a reference to your
response to Tom Briles. You're really into recursion, aren't you?

Do you really believe that you would know better than people who
actually read the source of perl? Why are you so stubborn? You could
have tested this yourself, you know?

# ls -l foo
-rwxr-xr-x   1 mgjv     staff        241 Jul 26 14:00 foo*
# perl 
$orig = 'foo';
chmod 0700, $orig;
# ls -l foo
-rwx------   1 mgjv     staff        241 Jul 26 14:00 foo*
# perl
$orig = "foo";
chmod 0755, $orig;
# ls -l foo
-rwxr-xr-x   1 mgjv     staff        241 Jul 26 14:00 foo*
# perl
$OrignialLogFile = 'foo';
chmod 0700, $OrignialLogFile;
# ls -l foo
-rwx------   1 mgjv     staff        241 Jul 26 14:00 foo*
# perl
$OrignialLogFile = "foo";
chmod 0755, $OrignialLogFile;
# ls -l foo
-rwxr-xr-x   1 mgjv     staff        241 Jul 26 14:00 foo*

I think that both you, and the original poster just made a type in
that $OrignialLogFile variable name.

Martien

PS. *plonk*
-- 
Martien Verbruggen                  | 
Interactive Media Division          | This matter is best disposed of from a
Commercial Dynamics Pty. Ltd.       | great height, over water.
NSW, Australia                      | 


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

Date: Thu, 12 Aug 1999 01:41:53 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: How to delete an element from an array
Message-Id: <FGBwpt.F0x@news.boeing.com>

In article <FGBM18.6B6@news.boeing.com>,
Charles DeRykus <ced@bcstec.ca.boeing.com> wrote:
>In article <37b1d968.8951042@news.attcanada.net>,
>Dico Reyers <dico@internetworks.ca> wrote:
>>Hello there,
>>
>>Could someone please let me know if it is possible to delete an
>>element from an array in perl?
>>
>>@array = ("one","two and three",4,"five");
>>
>>how do I delete '4' and be left with...
>>
>>@array = ("one","two and three","five");
>>
>
>@array = map {$_ == 4 ? () : $_} @array; 
>

Hm, not -w clean though so perhaps:  

  @array = map { /^4$/ ? () : $_ } @array;   # or C<grep>  


or, if that's too short and ugly, maybe you'd like
something longer, slower: 

use  POSIX 'isdigit'; 
@array = map { isdigit($_) and $_ == 4  ? () : $_ } @array; 


And, you just know there are other ways.


hth,
--
Charles DeRykus


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

Date: Wed, 11 Aug 1999 19:22:00 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to delete an element from an array
Message-Id: <MPG.121bcf9e1d5c1249989e41@nntp.hpl.hp.com>

In article <tTms3.1383$8X1.126085@PM01NEWS> on Wed, 11 Aug 1999 22:34:01 
GMT, Monty Scroggins <Monty.Scroggins@mci.com> says...
> > Could someone please let me know if it is possible to delete an
> > element from an array in perl?
> >
> > @array = ("one","two and three",4,"five");
> 
> I think:
> splice(@array,3,1);

You think wrong.  And you didn't test what you thought.

Readers of this newsgroup don't benefit from random unfounded 
conjectures.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 11 Aug 1999 23:00:06 -0400
From: Duncan Hill <dhill@sunbeach.net>
Subject: Re: Improving speed of a sub
Message-Id: <Pine.LNX.4.10.9908112255390.24975-100000@bajan.pct.edu>

On 12 Aug 1999, Sam Holden wrote:

> On Wed, 11 Aug 1999 07:59:34 -0400, Duncan Hill <dhill@sunbeach.net> wrote:
> >required the copyright to be read.  Now, lets assume that there are 40
> >such scripts running on the server, and some of the forms are (for
> >some reason) 40K+.  It adds up after a while.
> 
> 40K * 40 => 1600K => about 1.5M

Ok, you can hit me over the head.. I tacked an extra 0 on by mistake
when I did the calculation.  Ah well, my boss will dictate in the end.
I will say, the scalar method is much faster (4 vs 45 wallclocks /
1000o iterations).  Another day, another trick learnt.

ObPerl (?) - why is it that whether the file I'm reading in is 80
bytes or 8K, the scalar method seems to stick at 4 wallclock secs (for
10000 iterations)?  I can understand why the while takes longer as the
file size increases, but not why the scalar method doesn't change.

-- 

Duncan Hill			Sapere aude
One net to rule them all, One net to find them,
One net to bring them all, and using Unix bind them.




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

Date: 11 Aug 1999 22:20:43 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: is our reese the author of mysql book?
Message-Id: <x74si591tw.fsf@home.sysarch.com>

>>>>> "A" == Abigail  <abigail@delanet.com> writes:

  A> Uri Guttman (uri@sysarch.com) wrote on MMCLXXI September MCMXCIII in
  A> <URL:news:x74si69shc.fsf@home.sysarch.com>:
  A> --
  A> -- why initialize aggregates when they don't cause warnings when using them
  A> -- uninitialized?

  A> Have you ever wondered about this? Why is it that scalars being used 
  A> unitialized cause a warning, but aggregates don't?

yes. perl's choice for warning makes sense to me.

  A> Haven't you ever wondered whether that might be a bug, and that Perl
  A> actually should issue a warning? This gives a warning:

  A>     my $foo;
  A>     my $bar =  $foo + 1;

  A> but this doesn't:

  A>     my @foo;
  A>     my @bar = (@foo, 1);

  A> But aren't they very similar in nature? Why does "my $foo; my $bar
  A> = $foo + 1" give a warning? Answer, because it's very likely you
  A> assume $foo contains a value, and if it's uninitialized you
  A> probably made a mistake. Very well then. Why doesn't the same
  A> argument hold for "my @foo; my @bar = (@foo, 1)"?  I find that
  A> inconsistent. Either make both a warnable offense, or allow both
  A> under -w. But allowing one, and not the other makes we wonder
  A> wether coins were flipped. "Do we make $bar = $foo + 1" a warnable
  A> offensive?  *coin toss* "It's head, it's warnable". Ok, flip the
  A> coin for "@bar = (@foo, 1)". *toss*. "It's tails, so it's
  A> allowable".  And I didn't even mention "my $foo; $foo = $foo + 1;"
  A> vs "my $foo; $foo ++;"

there is no coercion of an aggregate when is is used and it is empty.

my @foo ;

@bar = @foo ;

is fine. @foo is () which is a legitimate list value to assign.

what about $foo = [] ; push @$foo, blah?

how can you init that anymore than what my @foo does?

whereas, using a scalar value of undef can work as perl will auto coerce
it to '' or 0 as needed. that is an implied corecion that can be wrong
if you don't know what youare doing. hence the warnings if you use it as
avalue in a calculation (broad meaning of that term).

my $foo ;
$bar = $foo ;

will not warn, nor should it.

but using the undef to mean 0 or '' is a modification of that value which
you should conciously do. so you init it to 0 or '' as needed.

  A> Well, you can add and concatenate to uninitialized scalars as well. Isn't
  A> turning on warnings just a waste of text and electrons?

well, with lexical warnings you can select the level of warnings you want.

  A> I think people should use '-w'. I hope that it teaches people to write
  A> better Perl. But if people do things just to avoid warnings, and don't
  A> do other, similar things, just because it doesn't give a warning, then
  A> -w has failed on them.

  A> Getting your code to run such that no warnings are generated isn't the
  A> ultimate goal.

true but it doesn't hurt. i even hate to see c code compile with
warnings. i build gnu/public stuff with has warnings and i get pissed
off. they should know better.

no warnings should not be the goal but a side effect of quality
coding. i use it to make sure i don't assume coercion of undef. also i
use strict to make sure i don't have typos. i like the warning about a
var only used once. that either means a typo or i have some implied
thing that i should make explicit.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: 11 Aug 1999 22:45:18 -0400
From: Mark Mielke <markm@nortelnetworks.com>
Subject: Re: is our reese the author of mysql book?
Message-Id: <lq1btcdd8e9.fsf@bmers31f.ca.nortel.com>

abigail@delanet.com (Abigail) writes:
> Uri Guttman (uri@sysarch.com) wrote on MMCLXXI September MCMXCIII in
> <URL:news:x74si69shc.fsf@home.sysarch.com>:
> Haven't you ever wondered whether that might be a bug, and that Perl
> actually should issue a warning? This gives a warning:
>     my $foo;
>     my $bar =  $foo + 1;
> but this doesn't:
>     my @foo;
>     my @bar = (@foo, 1);

"undef() + 1" should definately give a warning. "((), 1)" shouldn't.

mark

-- 
markm@nortelnetworks.com/mark@mielke.cc/markm@ncf.ca __________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | CUE Development    (4Y21)
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Nortel Networks
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, Ontario, Canada

  One ring to rule them all, one ring to find them, one ring to bring them all
                       and in the darkness bind them...

                           http://mark.mielke.cc/


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

Date: 12 Aug 1999 02:51:54 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: is our reese the author of mysql book?
Message-Id: <7otcsa$8g8$1@rguxd.viasystems.com>

Uri Guttman <uri@sysarch.com> wrote:
:>>>>>> "A" == Abigail  <abigail@delanet.com> writes:

:>  A> Uri Guttman (uri@sysarch.com) wrote on MMCLXXI September MCMXCIII in
:>  A> <URL:news:x74si69shc.fsf@home.sysarch.com>:
:>  A> --
:>  A> -- why initialize aggregates when they don't cause warnings when using them
:>  A> -- uninitialized?

:>  A> Have you ever wondered about this? Why is it that scalars being used 
:>  A> unitialized cause a warning, but aggregates don't?

:>yes. perl's choice for warning makes sense to me.

[snip logical and rational point by counterpoint debate]

I doubt that my vote counts for much, but I'm with Steve and Abigail
on this one.  I'll take as much help from the "compiler" as I can
get.  

But from what I read about the future lexical warnings, we will
someday be able to have our cake and eat it too. (As Uri also
pointed out).


-- 
// Lee.Lindley   /// Programmer shortage?  What programmer shortage?
// @bigfoot.com  ///  Only *cheap* programmers are in short supply.
////////////////////    50 cent beers are in short supply too.


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

Date: Wed, 11 Aug 1999 20:27:27 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: JavaScript recieving variables from Perl
Message-Id: <Pine.GSO.4.10.9908112024460.7774-100000@user2.teleport.com>

On Wed, 11 Aug 1999, David Yang wrote:

> Newsgroups: comp.lang.java.javascript, comp.lang.javascript,
>     comp.lang.perl, comp.lang.perl.misc

If your news administrator still carries comp.lang.perl, please let him
or her know that that newsgroup has not existed since 1995. If you
have such an outdated newsgroup listing, you are probably missing out
on many other valid newsgroups as well. You'll be doing yourself and
many others a favor to use only comp.lang.perl.misc (and other valid
Perl newsgroups) instead.

> how do I have JavaScript read variables from a Perl file.  

What's a Perl file? If you mean you want to parse Perl _source_ code,
though, that's not easy to do - especially from JavaScript! Better to make
a general data file that (even) JavaScript can read. Good luck with it!

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



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

Date: Wed, 11 Aug 1999 20:57:26 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: lock_nb
Message-Id: <Pine.GSO.4.10.9908112033240.7774-100000@user2.teleport.com>

On Wed, 11 Aug 1999, Troy Knight wrote:

> I have read the faq's and docs but still don't exactly understand
> lock_nb. What does it do?, What is the syntax for it? and Do you use
> after or before flocking with lock_sh/lock_ex or with?

Normally, when you request a lock on a file, you're telling the system
that if the lock can't be granted at once, your program is willing to wait
for it. Conceptually, your process is put into a queue, where it waits its
turn on the relevant file. While blocking (in the queue), your process
uses the minimum of system resources, so this is kindest to other
processes. And it's fair, since it's first come, first served. Usually, it
is just a short wait, often under a second, when everything is running
properly.

But it could be arbitrarily long, and your program could perhaps do
something else while it's waiting. If you add the LOCK_NB constant to
either LOCK_SH or LOCK_EX (whichever is appropriate), your process won't
block when the lock isn't available. Instead, flock() will return at once
- and its return value will be false, instead of true. (To distinguish
this return value from other possible failure modes of flock, the special
$! variable is set to a system-dependant constant such as EWOULDBLOCK. See
your system's manpage for the underlying flock/lockf/fcntl function, if
appropriate.)

Of course, this means that your process isn't going to be waiting in the
queue, either. So, when you've tried some other processing and you come
back to try again to get the lock, someone else may have taken your place.
Eventually, when you've run out of other tasks to do, you'll generally ask
for a lock without blocking, and then you'll (probably) get it.

Having read all that, you can probably now forget it. I've never seen or
heard of a real-world Perl program which has needed to use LOCK_NB as I've
just described it. More than 99.9% of the time (no exaggeration!) when you
need a lock, you need the lock, and it would be a waste of both programmer
and processor time to use LOCK_NB.

Okay, there's one possible exception. What if some other process has the
lock and you are worried that the other process has hung? If it's hung,
it'll never release the lock, your process will hang, and pretty soon your
sysadmin (you?) will have three or thirty or three hundred hung processes
all waiting for a lock they're never going to get. Well, you should send a
SIGKILL to the programmer of the hung process, first. 

But maybe in this case you'll want to implement your locking by using
LOCK_NB and a busy-wait loop, in which you try again and again to get the
lock until either it's granted or N seconds have elapsed. This isn't kind
to other processes - You're using processor cycles for no good reason
during those N seconds. And if the other process really is hung, you're
not going to have any better situation after N seconds, anyway. And
finally, if several processes are each trying to get a turn, yours may not
be served in fair order. In general, it's the worst way to do this. But if
you really want to do that, Perl gives you the power.

Have fun with it!

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



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

Date: 11 Aug 1999 22:10:32 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Looking for a good Perl Book
Message-Id: <x77ln192av.fsf@home.sysarch.com>

>>>>> "A" == Abigail  <abigail@delanet.com> writes:

  A> Elaine -HFB- Ashton (elaine@chaos.wustl.edu) wrote on MMCLXXI September
  A> MCMXCIII in <URL:news:37B1966D.772CD4BB@chaos.wustl.edu>:
  A> ;; Abigail wrote:
  A> ;; > [] 3) get any unix book from O'Reilly
  A> ;; > 
  A> ;; > I'd trade all Unix books from O'Reilly for any book written by Kernighan
  A> ;; > or Pike.
  A> ;; 
  A> ;; abigail++ :) Marry me darling. 

  A> Sure. How about Friday, Aug 20, around 3ish?
  A> You'd think Kernighan would like to be the best man?

i can't make it. i'll be flying to monterey that day. :-)

where will you be registered? i can send a copy of OO Perl to you!

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: 11 Aug 1999 21:48:03 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Looking for a good Perl Book
Message-Id: <slrn7r4dam.d88.abigail@alexandra.delanet.com>

Ala Qumsieh (aqumsieh@matrox.com) wrote on MMCLXXI September MCMXCIII in
<URL:news:x3yr9la9ola.fsf@tigre.matrox.com>:
'' 
'' > [] The best reference on Perl would be "Programming Perl" (aka the Camel)
'' > [] written by L. Wall, T. Christiansen and R. Shwartz, published by
'' > [] O'Reilly.
'' > 
'' > Weird. The most recent version of that book has "5.003" on the cover.
'' > The current version of Perl is 5.005, and was released a year ago.
'' > Perl 5.6 might be out before the end of the year. A lot of things have
'' > changed. While PP contains a lot of information, I hestitate to say it's
'' > the best reference.
'' 
'' Again, there is an implicit assumption here. No book is ever
'' up-to-date with it's topic. But the Camel is one of the best
'' references I found in terms of technicality and presentation of
'' information. I think it should be the standard by which technical
'' books are judged.

Perhaps it's my scientific heritage, but one of the keys things I
judge technical/scientific works by is the quality of the references
section. There is no references section in the Camel.

Mind, I am not claiming that the Camel is a bad book. Not at all.
But anything that comes from O'Reilly seems to have this "holy aura"
(not only the Perl books). I've no idea why. O'Reilly has produced
some good books, and I've somewhere between 15 and 20 O'Reilly books
myself. But I've yet to see any really outstanding book from O'Reilly,
and in my opinion, O'Reilly books are highly overrated. There is too
much "The author(s) is God, what (s)he says are facts, that don't
have to be motivated" (paraphrasing Jeffrey Friedl).

''                   The only thing that beats the Camel in describing
'' the latest version of Perl is the on-line docs that come with the
'' latest version of Perl.

True. Which is worse than it sounds, as the online docs are not very
good in crossreferencing, there isn't a extensive index, and in places
it heavily relies on Unix and C knowledge. The on-line docs are great if
you know your way around in them. They hardly leave a topic uncovered,
but it takes an efford to find things. And while I can use grep almost
as easily as Tom can, I don't think the necessity to grep through the
pods is a feature.

We all whine about the people asking question here that are found in the
faq, or the manual. But sometimes we should realize it isn't easy to
find things.

Take for instance "BEGIN". First of all, "BEGIN" usually not preceded
with "sub", so you might go to "man perlsyn" to find out about "BEGIN".
Well, you won't find it there. But perhaps you picked up somewhere that
"BEGIN" is actually a sub. So, you go to "man perlsub". It briefly
discusses "BEGIN", in its discussion it isn't mentioned that the keyword
"sub" is optional; only later on, when discussing constant functions,
"BEGIN" is used without a "sub" keyword. But that doesn't get any explaination.
Now, there is a reference to perlmod, that that tells us more about the
"BEGIN function". (function? Is that different from a sub?). And why is
it in the section about package constructors/destructors? Eventually, you
get there, and "BEGIN" is explained fairly well in the section about
package constructors and destructors. Of course, that leaves the beginner
who saw BEGIN in a program that doesn't have a package statement still
wondering about the connection.

But then, there's the little cousin of BEGIN, INIT. Want to make a guess
where INIT is described? "man perldelta". Not perlsyn, not perlsub, not
perlmod, no, perldelta. And don't use grep to find where INIT is discussed,
or you'll find yourself reading "man perlxs".

I have mixed feelings about the documentation. Its size is impressive.
Perl is a large language when it comes to language constructs, amount of
functions and operators, and the size of the standard library. Yet you'll
have to come up with something pretty obscure, or highly experimental,
to not have any documentation about it. It's a reference guide, *and*
a tutorial. It's monumental. But it is also a maze, and it sometimes
assumes quite a lot from a reader.

I wish there was something better than the online documentation. We
need something better. But I also realize it's damn near impossible to
create something better.

And while I think that the excuses "I don't have time to read the docs",
or "the docs are just too large" are lame, and should not be used, we
should keep in mind that the online docs aren't the be-all, end-all.

'' > [] As for learning Unix, then I say:
'' > [] 1) get Linux
'' > [] 2) install it
'' > 
'' > That's like saying "for learning how to drive a car, get the parts and
'' > assemble it".
'' 
'' When was the last time you installed Linux? I installed the latest
'' version of RedHat around a month ago, and it was a breeze. Much faster
'' and simpler than winblows. It even recognizes ADSL modems with
'' absolutely no effort on the user's side. That impressed me!

Oh, a few months ago. It's almost as easy as installing Solaris. For me.
And for you. But we're experienced users. We don't count if you want to
find out how ot _learn_ Unix. Besides, even if in a few weeks, there's
an "easy-install-linux", where all you have to do is unwrap the CD, and
everything else is handled automatically, what have you learned about
Unix from the installation process?

That's my point. Building a car from the spare parts, doesn't help you
a bit on learning how to drive.

'' OTOH, assembling a car would take me about as much time as it would
'' take me to uninstall Internet Explorer ;)

So, given that it was a breeze to install RedHat, assembling a car is
a breeze for you?

'' > [] 3) get any unix book from O'Reilly
'' > 
'' > I'd trade all Unix books from O'Reilly for any book written by Kernighan
'' > or Pike.
'' 
'' I agree there. But are they geared towards beginners?

Well, when I started my CS degree at the university, back in the first
half of the '80s, we were supposed to learn Unix from Kernighan and Pikes
"The UNIX Programming Environment". The book is geared towards beginners,
and I've found it a very useful book. It's almost falling apart, it's by
far the most worn out book in my technical bookcase, and if it wasn't
for the fact I started to learn Perl a couple of years ago, I'd still
be using it on a regular basis.



Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

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

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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu. 

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


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