[31009] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2254 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 5 21:14:25 2009

Date: Thu, 5 Mar 2009 18:14:18 -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           Thu, 5 Mar 2009     Volume: 11 Number: 2254

Today's topics:
    Re: Find Windows Compression attribute? <novastaylor@gmail.com>
    Re: Find Windows Compression attribute? <novastaylor@gmail.com>
        good editor for perl <aa@aa.com>
    Re: good editor for perl <null@null.com>
    Re: good editor for perl <tim@burlyhost.com>
    Re: Polling a file without using huge amount of system  <tzz@lifelogs.com>
    Re: Strange system() slowdown when using Inline::C <sisyphus359@gmail.com>
    Re: Strange system() slowdown when using Inline::C <ross.girshick@gmail.com>
    Re: Strange system() slowdown when using Inline::C <ross.girshick@gmail.com>
    Re: Strange system() slowdown when using Inline::C <1usa@llenroc.ude.invalid>
    Re: Strange system() slowdown when using Inline::C <No_4@dsl.pipex.com>
    Re: Strange system() slowdown when using Inline::C <ben@morrow.me.uk>
    Re: Strange system() slowdown when using Inline::C <1usa@llenroc.ude.invalid>
    Re: What-if algorithm <tzz@lifelogs.com>
    Re: What-if algorithm <tzz@lifelogs.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 5 Mar 2009 12:32:53 -0800 (PST)
From: NovasTaylor <novastaylor@gmail.com>
Subject: Re: Find Windows Compression attribute?
Message-Id: <8d96bf98-c672-431e-97be-a9d45179c873@j35g2000yqh.googlegroups.com>

I can retrieve the compression attribute successfully with
Win32::File, but I can not set it. Any ideas why? I can set the
attribute using Windows Explorer. In the following code I successfully
detect that my test file is not compressed.  THe "File is not
compressed..." line prints out and I get no error from teh
SetAttributes command, yet the file remains not compressed.

use strict;
use Win32::File;
my $path=3D"C:\\temp\\Perl\\TestFolder\\TestFile.txt";
my $attr;
Win32::File::GetAttributes($path, $attr);
if ($attr & COMPRESSED)
{
  print "File is compressed\n";
}
else
{
  print "File is not compressed.  I will compress it!!\n";  # this
line prints!
  Win32::File::SetAttributes($path, COMPRESSED ) or die "Can not set
to COMPRESSED: $!";
}


Any help would be greatly appreciated.
Cheers,

Tim

On Mar 5, 11:12=A0am, smallpond <smallp...@juno.com> wrote:
> On Mar 5, 8:43=A0am, NovasTaylor <novastay...@gmail.com> wrote:
>

> > Hi folks,
>
> > Is there a way I can identify the windows compression property
> > "Compress contents to save disk space" on files and folders? I have a
> > large directory structure where I need to find files that have the
> > compression property active and ideally turn that attribute off.
> > Simply identifying the files with that attribute would be a good first
> > step.
>
> > Thanks!
>
> > Tim
>
> I believe that you can get this from Win32::File



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

Date: Thu, 5 Mar 2009 12:43:36 -0800 (PST)
From: NovasTaylor <novastaylor@gmail.com>
Subject: Re: Find Windows Compression attribute?
Message-Id: <2dc6cbc9-7925-4848-aba4-a05aefba1c26@y13g2000yqn.googlegroups.com>

oh, and this also does not work:

Win32::File::SetAttributes($path, $attr| COMPRESSED) or die "Can not
set to COMPRESSED: $!";

What am I missing?

Tim


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

Date: Thu, 5 Mar 2009 22:03:02 +0100
From: "abcd" <aa@aa.com>
Subject: good editor for perl
Message-Id: <gopem5$558$1@news.metronet.hr>

I'am looking for good editor which show parameters of functions.... 




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

Date: Thu, 05 Mar 2009 21:22:58 GMT
From: kdnewton <null@null.com>
Subject: Re: good editor for perl
Message-Id: <SoXrl.16464$PH1.10086@edtnps82>

abcd wrote:
> I'am looking for good editor which show parameters of functions.... 
> 
> 
Scite has grown on me. It's highly-configurable if you don't like the 
colors.

http://www.scintilla.org/SciTE.html


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

Date: Thu, 05 Mar 2009 13:34:08 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: good editor for perl
Message-Id: <kzXrl.72540$uG1.2356@newsfe16.iad>

abcd wrote:

> I'am looking for good editor which show parameters of functions....

What operating system are you using?  This might be an FAQ:

http://perldoc.perl.org/perlfaq3.html#Is-there-an-IDE-or-Windows-Perl-Editor

I like vi/vim, personally (it works on a lot of playforms as well) and
it'll highlight different portions of your code, if you're into that
sort of thing.
-- 
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!


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

Date: Thu, 05 Mar 2009 15:02:23 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Polling a file without using huge amount of system resources
Message-Id: <86tz67adk0.fsf@lifelogs.com>

On Wed, 4 Mar 2009 19:05:01 -0800 (PST) Ishmael <stahl.karl@gmail.com> wrote: 

I> But now I'm curious - when I open, for example, an xterm window, it
I> will wait patiently until I type something, and it knows (instantly!)
I> when I press 'Enter'.  That means that somewhere, it is polling
I> rapidly for keypress events, yet it uses essentially no system
I> resources.

Actually X applications set up an event loop, where they respond to
messages from X.  So for an xterm in particular, when you just start it,
the key press is delivered by a X event and then fed to whatever process
the xterm is running (e.g. a shell).

I> Do you know if that is implemented using the functions you describe
I> (like inotify?)?  Or is there some other secret mechanism?

Look at IO::Select for a simple way to poll multiple filehandles (either
IO::Handle objects or file descriptors).  The examples show how to use
it to check if input is waiting on STDIN, with \*STDIN.

Writing software in a time-sharing environment boils down to either
receiving events or yielding (via sleep/usleep) when there is nothing to
do.  Usually, events are not available in the Unix environment unless
you implement a X event loop or something similar.  So waiting for input
and yielding are the most common choice, and the one that works in
general terms with file or interactive input.

The interactivity of the application in a time-sharing environment
actually *increases* when it idles instead of consuming key presses
immediately.  The reason is that the OS, meanwhile, can get a chance to
do other tasks instead of interfering with the application while the key
presses are handled.  Just don't use sleep(1), that's too long, use
usleep(50) which is usually good enough for interactive use.

Anyhow, if you want good responsiveness in Perl programs, use
Term::ReadKey for single-key presses (it will tell you if a key press is
waiting) and Term::ReadLine::Gnu for line-based editing.  Don't try to
be too clever with handling input, because you never know if you're
running in a local xterm or in a remote shell over a 9600 baud modem.

I'm sure much more can be said on this topic...

Ted


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

Date: Thu, 5 Mar 2009 15:18:13 -0800 (PST)
From: sisyphus <sisyphus359@gmail.com>
Subject: Re: Strange system() slowdown when using Inline::C
Message-Id: <9312b87e-eedf-4cf6-a86a-01b0def237f7@f1g2000prb.googlegroups.com>

On Mar 6, 4:24=A0am, rbg <ross.girsh...@gmail.com> wrote:

> You can see that in test 2, foo() is roughly 10x faster.

What happens if hello() is written as a perl sub (and Inline::C is not
used at all) - something like (untested):

use constant LEN =3D> 1<<26;

sub hello {
    my $i;
    my @foo;
    print "hello world\n";
    for($i =3D 0; $i < LEN; $i++) {
       $foo[$i] =3D chr(0);
    }
}

Does the speed with which foo() executes still vary in the same way,
depending upon the value of LEN ?
Or does the variation occur *only* when hello() is written as an
Inline::C sub ?

Cheers,
Rob




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

Date: Thu, 5 Mar 2009 15:21:21 -0800 (PST)
From: rbg <ross.girshick@gmail.com>
Subject: Re: Strange system() slowdown when using Inline::C
Message-Id: <4eeea107-69d5-4e3d-9610-7792ca1d14e4@c11g2000yqj.googlegroups.com>

Continuing the discussion with myself, it seems that the problem is
really much more basic.

This script:
--------
use strict;
my $bf = 'a' x (1<<26);

sub foo {
  for my $i (1..1000) {
    system('date > /dev/null');
  }
}
foo();
--------

is much slower than this one than this one:

--------
use strict;
my $bf = 'a' x (1<<10);

sub foo {
  for my $i (1..1000) {
    system('date > /dev/null');
  }
}
foo();
--------.

I can reproduce this issue ubuntu with perl 5.10.0 (and debian with
perl 5.8.8), but *not* on OS X with perl 5.8.8.  It seems like it has
something to do with how the perl interpreter is cloned when system()
is called (seems that it isn't actually doing copy-on-write forking).
Anyone have a deeper understanding of this issue?


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

Date: Thu, 5 Mar 2009 15:22:50 -0800 (PST)
From: rbg <ross.girshick@gmail.com>
Subject: Re: Strange system() slowdown when using Inline::C
Message-Id: <56efe4d7-5447-49c8-8c09-3867293916cc@j8g2000yql.googlegroups.com>

On Mar 5, 5:21=A0pm, rbg <ross.girsh...@gmail.com> wrote:
> Continuing the discussion with myself, it seems that the problem is
> really much more basic.

Oops, I wrote that before I noticed someone else had replied!  I
didn't intend to be rude :-).


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

Date: Thu, 05 Mar 2009 23:46:06 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Strange system() slowdown when using Inline::C
Message-Id: <Xns9BC5BEE911DB6asu1cornelledu@127.0.0.1>

rbg <ross.girshick@gmail.com> wrote in news:4eeea107-69d5-4e3d-9610-
7792ca1d14e4@c11g2000yqj.googlegroups.com:

> Continuing the discussion with myself, it seems that the problem is
> really much more basic.
> 
> This script:
> --------
> use strict;
> my $bf = 'a' x (1<<26);
> 
> sub foo {
>   for my $i (1..1000) {
>     system('date > /dev/null');
>   }
> }
> foo();
> --------
> 
> is much slower than this one than this one:
> 
> --------
> use strict;
> my $bf = 'a' x (1<<10);
> 
> sub foo {
>   for my $i (1..1000) {
>     system('date > /dev/null');
>   }
> }
> foo();
> --------.

I don't see that.

This is perl, v5.10.0 built for MSWin32-x86-multi-thread
(with 5 registered patches, see perl -V for more detail)

Binary build 1004 [287188] provided by ActiveState 

C:\DOCUME~1\asu1\LOCALS~1\Temp\q> cat t.pl
use strict;
my $bf = 'a' x (1<<26);

sub foo {
  for my $i (1..1000) {
    system('date /t > NUL');
  }
}
foo();

TimeThis :  Command Line :  t.pl
TimeThis :    Start Time :  Thu Mar 05 18:39:11 2009
TimeThis :      End Time :  Thu Mar 05 18:40:11 2009
TimeThis :  Elapsed Time :  00:01:00.078

C:\DOCUME~1\asu1\LOCALS~1\Temp\q> cat s.pl
use strict;
my $bf = 'a' x (1<<10);

sub foo {
  for my $i (1..1000) {
    system('date /t > NUL');
  }
}
foo();

TimeThis :  Command Line :  s.pl
TimeThis :    Start Time :  Thu Mar 05 18:41:35 2009
TimeThis :      End Time :  Thu Mar 05 18:42:34 2009
TimeThis :  Elapsed Time :  00:00:59.640

C:\DOCUME~1\asu1\LOCALS~1\Temp\q> cat z.pl
use strict;

sub foo {
  for my $i (1..1000) {
    system('date /t > NUL');
  }
}
foo();

TimeThis :  Command Line :  z.pl
TimeThis :    Start Time :  Thu Mar 05 18:43:11 2009
TimeThis :      End Time :  Thu Mar 05 18:44:10 2009
TimeThis :  Elapsed Time :  00:00:59.015

C:\DOCUME~1\asu1\LOCALS~1\Temp\q> cat u.pl
use strict;
my $bf = 'a' x (1<<26);

TimeThis :  Command Line :  u.pl
TimeThis :    Start Time :  Thu Mar 05 18:45:05 2009
TimeThis :      End Time :  Thu Mar 05 18:45:06 2009
TimeThis :  Elapsed Time :  00:00:00.390

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/


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

Date: Thu, 05 Mar 2009 23:56:45 +0000
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: Strange system() slowdown when using Inline::C
Message-Id: <dcmdnUrh15Yg-y3UnZ2dnUVZ8rCWnZ2d@pipex.net>

rbg wrote:
> 
> I can reproduce this issue ubuntu with perl 5.10.0 (and debian with
> perl 5.8.8), but *not* on OS X with perl 5.8.8.  It seems like it has
> something to do with how the perl interpreter is cloned when system()
> is called (seems that it isn't actually doing copy-on-write forking).
> Anyone have a deeper understanding of this issue?

The size of the process is *much* greater in the 1<<26 case, so there will be a much greater process 
space to create (it may not copy the pages, but it has to create page table entries for it?).

Looking at top when these run:

1<<10  VIRT=20848, RES=2060
1<<26  VIRT=148m. RES=130m

If you undef $bf after setting it to the long string you'll find that, for the 1<<26 case you end up 
with something in between, both in timing and size.

VIRT=86388, RES=66m

-- 
              Just because I've written it doesn't mean that
                   either you or I have to believe it.


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

Date: Fri, 6 Mar 2009 00:12:47 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Strange system() slowdown when using Inline::C
Message-Id: <vc6686-it1.ln1@osiris.mauzo.dyndns.org>


Quoth "A. Sinan Unur" <1usa@llenroc.ude.invalid>:
> 
> I don't see that.
> 
> This is perl, v5.10.0 built for MSWin32-x86-multi-thread
> (with 5 registered patches, see perl -V for more detail)

Well, no. Since this is probably a problem with fork(2) of a large
address space, and Win32 doesn't use fork(2), you wouldn't.

Ben



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

Date: Fri, 06 Mar 2009 01:03:40 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Strange system() slowdown when using Inline::C
Message-Id: <Xns9BC5CC1003B02asu1cornelledu@127.0.0.1>

Ben Morrow <ben@morrow.me.uk> wrote in news:vc6686-it1.ln1
@osiris.mauzo.dyndns.org:

> 
> Quoth "A. Sinan Unur" <1usa@llenroc.ude.invalid>:
>> 
>> I don't see that.
>> 
>> This is perl, v5.10.0 built for MSWin32-x86-multi-thread
>> (with 5 registered patches, see perl -V for more detail)
> 
> Well, no. Since this is probably a problem with fork(2) of a large
> address space, and Win32 doesn't use fork(2), you wouldn't.

OK then ... I tried it on my Eee PC 701 with ArchLinux using the stock 
perl v5.10.0 while downloading system updates.

time shows:

real 0m37.892s
user 0m17.959s
sys  0m17.882s

For control, omitting the large assignment to $bf yields

real 0m24.965s
user 0m17.586s
sys  0m6.416s

On the other hand, using 

my $bf = 'a' x (1 << 10);

yields 

real 0m24.748s
user 0m17.322s
sys  0m6.526s

Clearly, there is a slowdown with the larger $bf, but there is not a 10x 
difference.

PS: Apologies for not copying and pasting. 

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/


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

Date: Thu, 05 Mar 2009 14:21:04 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: What-if algorithm
Message-Id: <86eixbbu1b.fsf@lifelogs.com>

On Wed, 4 Mar 2009 01:11:20 +0100 gamo <gamo@telecable.es> wrote: 

g> But I'm unable to discern if root-finding methods are aplicable 
g> to the generic case of non-continous, non-derivable functions. 

Look at glpk, http://www.gnu.org/software/glpk/

Depending on your particular data it may be useful; at least you can
learn about the methods it uses to solve a LP problem.

Ted


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

Date: Thu, 05 Mar 2009 14:36:14 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: What-if algorithm
Message-Id: <864oy7btc1.fsf@lifelogs.com>

On Thu, 05 Mar 2009 14:21:04 -0600 Ted Zlatanov <tzz@lifelogs.com> wrote: 

TZ> On Wed, 4 Mar 2009 01:11:20 +0100 gamo <gamo@telecable.es> wrote: 
g> But I'm unable to discern if root-finding methods are aplicable 
g> to the generic case of non-continous, non-derivable functions. 

TZ> Look at glpk, http://www.gnu.org/software/glpk/

TZ> Depending on your particular data it may be useful; at least you can
TZ> learn about the methods it uses to solve a LP problem.

(I hit "Send" too soon)

You can always break a function into continuous chunks and derive in
that interval.  In other words, if your discontinuity is at 5, you can
analyze (-inf, 5), 5 itself, and (5, inf).  But this has been solved
many times, don't waste your time trying to reinvent the wheel.

You should start at

http://en.wikipedia.org/wiki/Numerical_analysis

then look at the software section

http://en.wikipedia.org/wiki/Numerical_analysis#Software

Depending on your resources and abilities, MATLAB or Mathematica may be
more appropriate than a home-grown solution, but as you'll see this is a
well-researched field with many available solutions.

Ted


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

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 V11 Issue 2254
***************************************


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