[18058] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 218 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 5 18:10:59 2001

Date: Mon, 5 Feb 2001 15:10:19 -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: <981414619-v10-i218@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 5 Feb 2001     Volume: 10 Number: 218

Today's topics:
    Re: Perl Puzzle! wtf is going on here... cookconsulting@my-deja.com
    Re: Radical readdir suggestion <mischief@velma.motion.net>
    Re: Socket held open indefinitely by server nobull@mail.com
        Syntax and new lines (BUCK NAKED1)
    Re: System call correct? <mischief@velma.motion.net>
    Re: This is driving me nuts and I need a guru <jdf@pobox.com>
    Re: This is driving me nuts and I need a guru <jwgws@hotZEROSPAMmail.com>
    Re: update page <mischief@velma.motion.net>
    Re: Using Braces (David H. Adler)
    Re: Using Braces (Abigail)
    Re: Using global var in subroutine <steve@teamITS.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 05 Feb 2001 19:34:07 GMT
From: cookconsulting@my-deja.com
Subject: Re: Perl Puzzle! wtf is going on here...
Message-Id: <95mv7f$bvb$1@nnrp1.deja.com>

Thanks guys for your help!
hope you enjoyed the puzzle ;)


Sent via Deja.com
http://www.deja.com/


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

Date: Mon, 05 Feb 2001 22:01:48 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Radical readdir suggestion
Message-Id: <t7u8mcejgcbhb0@corp.supernews.com>

Ilmari Karonen <iltzu@sci.invalid> wrote:
> In article <3a7e6526.4cce$d8@news.op.net>, Mark Jason Dominus wrote:
>>In article <ldo-BD3CE2.16005405022001@news.wave.co.nz>,
>>Lawrence D?Oliveiro  <ldo@geek-central.gen.new_zealand> wrote:
>>
>>>is there any reason why the semantics of readdir should not be 
>>>changed so it never returns "." and ".."? 
>>
>>Because if you want that behavior, it is trivial to write a subroutine
>>that does it the way you want?

> I think he does have a point, though -- such a subroutine would almost
> certainly end up doing the Wrong Thing on platforms where ".." is not
> special in any way.

A point, yes. Portability of incorrect behavior in Perl should not
be a goal, though. Perl itself would have to decide (probably at
Perl's build time, not the program's) whether or not to include
'.' and '..' in the directory listing if they were not reported
on the systems that treat them specially.

Those directory entries should show up on systems that have them.
The programmer can take steps such as checking $^O to see whether
or not '.' and '..' should be treated specially. This is better
than Perl deciding if they will be treated specially. Perl should
interact with everyone's file system equally.

If we make it so that Unix/Linux and DOS/Windows can't see their
special directory entires, what's next? Do we make Perl itself
translate between short and long filenames on Microsoft's
operating systems? Do we make Perl find a way to differentiate
between pipes and regular files on systems with broken file
systems that don't report the difference? Should Perl
automatically know, without the ability to use binmode(), that
it needs to adjust or not adjust the OS and FS ideas about line
endings?

> Please ignore Godzilla and its pseudonyms - do not feed the troll.

But I've got a plump, juicy billygoat! ;)

Chris
-- 
Christopher E. Stith

Disclaimer: Actual product may not resemble picture in ad in any way.



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

Date: 05 Feb 2001 18:53:34 +0000
From: nobull@mail.com
Subject: Re: Socket held open indefinitely by server
Message-Id: <u9n1c1dkr5.fsf@wcl-l.bham.ac.uk>

"Porphyrion" <Info@Porphyrion.com> writes:

> Any suggestions on how to break out of a socket that is held indefinitely?

FAQ: "How do I timeout a slow event?"

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Mon, 5 Feb 2001 14:47:52 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Syntax and new lines
Message-Id: <4238-3A7F1178-62@storefull-241.iap.bryant.webtv.net>

Though, these are discussed already in different places throughout the
perl documentation, it would be a great help in writing perl code, if
all of the below were together in one place, and  included in the
perlsyntax manpage (or even the FAQ). I don't know enough to do it
myself, but here's what I'm thinking.

The addition copy would explain when to use quotes, backticks, parens,
braces, brackets, commas, semi-colons, etc... and explain when to use a
new line (\n), and when to use \n\n. This would really help some of us
beginners overcome some of the minor obstacles in writing perl syntax...
and maybe some of the more experienced users too. :)

What do you think?

--Dennis




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

Date: Mon, 05 Feb 2001 20:40:24 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: System call correct?
Message-Id: <t7u3torgkqn042@corp.supernews.com>

Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
> I was shocked! How could John Boy Walton <johngros.NOSPAM@bigpond.net.au>
> say such a terrible thing:
>>Could some one tell me if this is a correct system call?
>>system ("C:/Program Files/Junker/junk.exe") || die "can't start proxy $!";
>>My understanding of the docs is yes but it is not working.

> Your understanding is wrong. The return value of system signifies an
> error occured if it is non-zero, therefore a correct usage is more
> likely:

In practice this will almost always be the case. What system
really returns is the return code of the program it ran. By
convention, programs return 0 for success, nonzero for error.
An oddball program from an oddball programmer might do this
backwards.

> system("some-pgogram") = 0
>     or die "Error: $?";

You have a typo there. The above ends up being an assignment
instead of a test.

        system("program") == 0 || die "Error: $?";

Otherwise, you're right on.

Chris

-- 
Christopher E. Stith

It's not the U in UBE that pisses people off. It's the B.
-- Martien Verbruggen in clp.misc



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

Date: 05 Feb 2001 14:05:08 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: This is driving me nuts and I need a guru
Message-Id: <u269hrx7.fsf@pobox.com>

"John W" <jwmsng@greatNOSPAMwebsolutions.com> writes:

> Just curious, what's Jeopardy style?
[snip classic Jeopardy post]

It's the crazy-making practice of writing your response at the top of
your post, followed by the original post to which you're responding.
In other words, the answer is followed by the question.  Usually the
question is unedited, with signature and all intact.

This is considered anti-social behavior, and it's why you've been
killfiled.  That's what *plonk* means.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Mon, 5 Feb 2001 17:39:32 -0500
From: "John W" <jwgws@hotZEROSPAMmail.com>
Subject: Re: This is driving me nuts and I need a guru
Message-Id: <3a7f29ae_4@goliath2.newsfeeds.com>

> This is considered anti-social behavior, and it's why you've been
> killfiled.  That's what *plonk* means.

Actually, where I come from, killfiling somebody simply for asking an
innocent question isn't exactly considered the height of sociability and
good grace...

It's not even like I'm a newsgroup newbie. This is the first newsgroup I've
run across (of many I've participated in) where "Jeopardy-style" was such an
"issue" it had a name. And a knee-jerk reaction.





-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: Mon, 05 Feb 2001 22:54:45 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: update page
Message-Id: <t7ubpl26h4ef2c@corp.supernews.com>

Hans <hkamp1@hotmail.com> wrote:
> Problem is following:

> Person A visits my page generated with database stuff.

> Person B drops some stuff in the database.

> When B drops stuff the page by A must be updated.

Short answer: You can't do that.
#############

Medium answer:
##############
You can't that without client-side scripting, and Perl
isn't available on the client-side. (In some nonstandard
environments it could be but I don't know of any, or you
may have access to PerlScript, which isn't Perl but is
in some browsers. I wouldn't count on having either.
Java or JavaScript are more likely candidates.)



The long answer gets pretty long...
##############################################

This can't be done asynchronously on "The Web". HTTP is
stateless. HTTP is a transport protocol, not a
synchronozation protocol. If you had some Java or
Javascript (or maybe Perlscript, which is not the same
as Perl) loading on the client side, you could have that
connect to the server and check for an update or have it
wait for a UDP packet from the server saying that there
is an update, and have the server contact recent page
views via UDP packets if there is an update.

> The solution of refreshing the page every x seconds I know.

This is your best bet for a solution using only HTML, HTTP,
CGI and Perl.

[below paragraph is line-length adjusted]
> From A and B I know how to get their session_id and their
> ip_address, but I do not know how, by example thescript
> activated by person B can update the page by person A.

It can't, see above. 

[below paragraph is line-length adjusted]
> I do not know this is possible, or has somebody an other
> solution? May also in php.


<DISCLAIMER>
The following paragraph was written as a blazing fast and
really filthy "what-if" type of conversation with myself.
Please disregard it unless you find humor in such things
or need a masochistic programming idea to implement.
</DISCLAIMER>

You may be able to (if you can count on the users having frames)
refresh just one frame with a nominal amount of content (maybe none)
every few seconds, and make the frame include a one-second refresh
for the whole page (all frames) if and only if there has been an
update on the server. This is a filthy and disgusting hack, and I
should probably have my caffeine withheld for a day for mentioning
it. This paragraph is a rambling "what if", and is not a suggestion
to do such a thing. For one, how long to make the frame's update
include the full-page refresh would be a magic number with which
to twiddle, since multiple users at multiple sites should all
get the refresh, but none of them should get it twice for one
update. For another, refreshing even a contentless frame uses
some bandwidth and web server time, and this can be a sloppilly
wasteful way to use bandwidth. This whole thing, then, would be
unreliable, wasteful, and sloppy. I shouldn't have mentioned it
for those reasons, but I'm in a peculiar mood today and I find
this concept somewhat humorous.

<DISCLAIMER>
The preceding paragraph was written as a blazing fast and
really filthy "what-if" type of conversation with myself.
Please disregard it unless you find humor in such things
or need a masochistic programming idea to implement.
It is not a suggestion to implement a solution as is mentioned
in the text of the paragraph!
</DISCLAIMER>


What is really needed if you want to keep state between the
server and the client is a stateful protocol. You can use
HTTP to send a client-side script to a browser which then
implements the client side of astateful protocol, or you
could develop an application which takes the place of the
browser and maintains the state of its connections and
updates.

A web browser codebase which has been modified to still
render HTML (better yet XML, or maybe even SGML) and
objects within it (such as images, sounds, etc.) but to
optionally use a transport protocol other than HTTP would
be a cool project. If we had a web look and feel but could
maintain state and do a push update of pages, we could
write bunches of really interesting things on the server
side without as much client-side code. Lots of projects
have done things like this (NetZero among them), but few
have been open source and none of them have become any type
of widespread standard. This is, of course, completely
off-topic in a Perl group, but it could make Perl even more
useful than it already is for "Web" development, if it would
still be called that. All that would really be needed is for
the browser to register with the server when it is done with
a page, and the server being able to publish whether or not
it has something to update in some way the browser can
understand without the browser having to request a refresh
or a brand new page. It's not conceptually that difficult
and wouldn't be too difficult for skilled programmers to
implement, but it may never catch on, especially since there
are client-side scripting languages available in most browsers.

Perl can't by itself overcome all the shortcomings and
limited focus of other software. A program in Perl on
a web server can't make the browser understand an
asynchronous update between page loads. HTTP is based
around only request->serve->request->serve usage. Even
in a timed page refresh, the browser is doing the
resfresh by requesting the same page again.


Chris
-- 
Christopher E. Stith

It's not the U in UBE that pisses people off. It's the B.
-- Martien Verbruggen in clp.misc



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

Date: 5 Feb 2001 21:05:03 GMT
From: dha@panix2.panix.com (David H. Adler)
Subject: Re: Using Braces
Message-Id: <slrn97u5bv.t4i.dha@panix2.panix.com>

On 30 Jan 2001 19:00:11 GMT, Rich Lafferty <rich@bofh.concordia.ca> wrote:
>In comp.lang.perl.misc,
>jlamport@calarts.edu <jlamport@calarts.edu> wrote:
>> 
>> Read the docs a little more carefully.  The "quote like" operators
>> ( q qq qx qw s m tr ) can use *any* set of delimiters you choose.  The
>> following are all equivalent:
>> 
>> $sql=q{select sysdate from dual};
>> $sql=q(select sysdate from dual);
>
>[etc]
>
>You left out my favorites: q`` qw'' qx""   :-)

Personally, my reaction to that first one is "Gah!"

I don't like the idea that there are wild backticks roaming the
prairie if you lose that q through some horrible text editor
accident...

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Any sufficiently advanced technology is compatible with magic.
	- The Doctor, Seeing I


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

Date: 5 Feb 2001 21:57:10 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Using Braces
Message-Id: <slrn97u8dm.nrl.abigail@tsathoggua.rlyeh.net>

David H. Adler (dha@panix2.panix.com) wrote on MMDCCXV September MCMXCIII
in <URL:news:slrn97u5bv.t4i.dha@panix2.panix.com>:
-- On 30 Jan 2001 19:00:11 GMT, Rich Lafferty <rich@bofh.concordia.ca> wrote:
-- >In comp.lang.perl.misc,
-- >jlamport@calarts.edu <jlamport@calarts.edu> wrote:
-- >> 
-- >> Read the docs a little more carefully.  The "quote like" operators
-- >> ( q qq qx qw s m tr ) can use *any* set of delimiters you choose.  The
-- >> following are all equivalent:
-- >> 
-- >> $sql=q{select sysdate from dual};
-- >> $sql=q(select sysdate from dual);
-- >
-- >[etc]
-- >
-- >You left out my favorites: q`` qw'' qx""   :-)
--
-- Personally, my reaction to that first one is "Gah!"
--
-- I don't like the idea that there are wild backticks roaming the
-- prairie if you lose that q through some horrible text editor
-- accident...


I'm partially to q"" and qq''.

Specially if your not-so-perl-savvy PFY is going to maintain it.

But that's ok, I'm just cruel.


Abigail
-- 
$_ = "\x3C\x3C\x45\x4F\x54";
print if s/<<EOT/<<EOT/e;
Just another Perl Hacker
EOT


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

Date: Mon, 5 Feb 2001 16:38:20 -0600
From: "Steve Yates" <steve@teamITS.com>
Subject: Re: Using global var in subroutine
Message-Id: <t7uap627c0p697@corp.supernews.com>

"Wyzelli" <wyzelli@yahoo.com> wrote in message
news:rome6.18$G%5.4053@vic.nntp.telstra.net...
> >     If I simply declare $userCode == "" at the beginning of the script
> that will force it to be global right?
>
> Yes, though you would probably be better off declaring it just before it
> is used, outside the sub.

    It wasn't obvious from the snippit I posted, but the sub is called at
the beginning of the script so we're talking about the same thing.

    Interestingly, this still didn't work!  If I declare $userCode as
global, when it is set in the sub the value doesn't carry over outside the
sub...i.e., it's not behaving as global.  The global value which I set ahead
of time does appear within all subs however.  Plus, a test program I put
together works fine, so it's something in the large file that's the problem.

> The other alternative is to declare the
> variable as part of the main package, by

    OK, and thanks for the reference.  Unfortunately it points out what I
thought, that variables are global unless declared with "my" or a "package"
is declared.  So I'm not sure why I'm seeing what I'm seeing.  :(

Steve




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

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 V10 Issue 218
**************************************


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