[26705] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8805 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 28 14:05:14 2005

Date: Wed, 28 Dec 2005 11:05:06 -0800 (PST)
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, 28 Dec 2005     Volume: 10 Number: 8805

Today's topics:
    Re: "local @_ = @_;" for "pass-by-value"? <abigail@abigail.nl>
    Re: "local @_ = @_;" for "pass-by-value"? <noreply@gunnar.cc>
    Re: 'file changed'-event (Anno Siegel)
    Re: 'file changed'-event <news2132@8439.e4ward.com>
    Re: 'file changed'-event (Anno Siegel)
    Re: unable to get all html code on Yahoo <glex_no-spam@qwest-spam-no.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 28 Dec 2005 16:40:20 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: "local @_ = @_;" for "pass-by-value"?
Message-Id: <slrndr5fvk.c1.abigail@alexandra.abigail.nl>

Mihail (issakov@t-online.de) wrote on MMMMDII September MCMXCIII in
<URL:news:dou2ss$497$01$1@news.t-online.com>:
@@  Hello,
@@  
@@  again about sub{} behavior and "pass-by-call"/"pass-by-value".
@@  Is it clean and recommended to use local @_ ?
@@  
@@  sub {
@@  local @_ = @_;
@@  ...
@@  }
@@  
@@  I do not like the way of fantasy arrays:
@@  
@@  sub {
@@  my @pass_by_value_workaround = @_;
@@  ...
@@  }
@@  
@@  It is ugly. But i still don't see clear advice how to do
@@  "call-by-value"? And "local" things seems to change from
@@  version to version.


I would use

    my @arg = @_;

myself, but if you like 'local @_', I don't have any problems with it.
Not that me having problems with it is important - it's your code, if
you are comfortable with it, use it.



Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"


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

Date: Wed, 28 Dec 2005 18:49:12 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: "local @_ = @_;" for "pass-by-value"?
Message-Id: <41g1kkF1b5bt8U1@individual.net>

Abigail wrote:
> Mihail wrote:
> @@  again about sub{} behavior and "pass-by-call"/"pass-by-value".
> @@  Is it clean and recommended to use local @_ ?
> @@  
> @@  sub {
> @@  local @_ = @_;
> @@  ...
> @@  }
> @@  
> @@  I do not like the way of fantasy arrays:
> @@  
> @@  sub {
> @@  my @pass_by_value_workaround = @_;
> @@  ...
> @@  }
> @@  
> @@  It is ugly. But i still don't see clear advice how to do
> @@  "call-by-value"? And "local" things seems to change from
> @@  version to version.
> 
> I would use
> 
>     my @arg = @_;
> 
> myself, but if you like 'local @_', I don't have any problems with it.
> Not that me having problems with it is important - it's your code, if
> you are comfortable with it, use it.

To me, doing so (or doing '@_ = @_;', which serves the same purpuse) is 
obfuscation.

When I see a line such as

     $_[0] *= 8;

I'm automatically assuming that the passed-in variable gets changed. If 
somebody else but the OP would later read or maintain the code, 
explicitly assigning to @_ might cause confusion.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 28 Dec 2005 16:09:19 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: 'file changed'-event
Message-Id: <doudbf$s1a$1@mamenchi.zrz.TU-Berlin.DE>

Michael Goerz  <news2132@8439.e4ward.com> wrote in comp.lang.perl.misc:
> Hi,
> 
> I'm trying to execute a sub whenever a certain file on the disk changes.
> Currently, I'm doing this with an infinite loop that checks the modify
> time (stat("$file"))[9]. While this works in principle, the infinite
> loop drives the CPU crazy and speeds up the fan (very annoying).
> 
> Can I implement this with an event-based approach that doesn't drive up
> my CPU? How?

Unless your file system supports events you'll ultimately have to watch
the file.  However, doing so in a tight loop is useless.  Presumably the
file system's resolution is one second, so you should only stat the file
once a second.  If you don't need maximum resolution make the intervals as
long as reasonable.  That will make the load tolerable.

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: Wed, 28 Dec 2005 17:29:22 +0100
From: Michael Goerz <news2132@8439.e4ward.com>
Subject: Re: 'file changed'-event
Message-Id: <41fsr2F13jpr2U1@uni-berlin.de>

Anno Siegel wrote:
> Unless your file system supports events you'll ultimately have to watch
> the file.  However, doing so in a tight loop is useless.  Presumably the
> file system's resolution is one second, so you should only stat the file
> once a second.  If you don't need maximum resolution make the intervals as
> long as reasonable.  That will make the load tolerable.

putting 'sleep 1;' in the loop's body solved the problem. I could have
thought about that! Was this what you had in mind?

Thanks!

Michael Goerz


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

Date: 28 Dec 2005 17:17:41 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: 'file changed'-event
Message-Id: <douhbl$124$3@mamenchi.zrz.TU-Berlin.DE>

Michael Goerz  <news2132@8439.e4ward.com> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> > Unless your file system supports events you'll ultimately have to watch
> > the file.  However, doing so in a tight loop is useless.  Presumably the
> > file system's resolution is one second, so you should only stat the file
> > once a second.  If you don't need maximum resolution make the intervals as
> > long as reasonable.  That will make the load tolerable.
> 
> putting 'sleep 1;' in the loop's body solved the problem. I could have
> thought about that! Was this what you had in mind?

Precisely.

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: Wed, 28 Dec 2005 10:48:50 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: unable to get all html code on Yahoo
Message-Id: <Tlzsf.16$M27.397@news.uswest.net>

tmp1235711@yahoo.com wrote:

>  How do I call these
> external JS files so I can capture the data?  I mean I can see the
> call "<script language="JavaScript" src="http:", how can I have Perl
> automatically execute the call?

It's being included into the page, via Javascript, that doesn't
mean it's Javascript.  Look at the src="...".  That's what you
want to call to get the data.  With a file name of 'get.jsp' it
would likely not have anything to do with Javascript, and much
more to do with Java.  Try it and see.

You could use a regular expression to find the line with 'get.jsp'
in it, and pull out the value for the src attribute, or, if it doesn't
change, just cut & paste it from the HTML source, into your script,
with all of the name=value pairs, and you hopefully will get HTML.

It'd be even easier if they provided a Web service to get the data,
but you'd need to talk to them about that.


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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