[25078] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7328 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 27 21:10:35 2004

Date: Wed, 27 Oct 2004 18:10:10 -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, 27 Oct 2004     Volume: 10 Number: 7328

Today's topics:
    Re: list vs array <usa1@llenroc.ude.invalid>
    Re: list vs array <matthew.garrish@sympatico.ca>
    Re: MAIL recommendation <nospam@nospam.com>
    Re: MAP question <usa1@llenroc.ude.invalid>
    Re: Newbie needs help with forking <odyniec-usenet@odyniec.net>
        Newbie question on regex. (SomeDeveloper)
    Re: Parallel/ Multithreading /Forking? ctcgag@hotmail.com
        Scary IPC::Open3 filehandle difference <mhunter@berkeley.edu>
        What are these extra spaces in my registry? (joe)
    Re: What are these extra spaces in my registry? <usa1@llenroc.ude.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 27 Oct 2004 23:13:30 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: list vs array
Message-Id: <Xns958FC39178743asu1cornelledu@132.236.56.8>

"daniel kaplan" <nospam@nospam.com> wrote in
news:1098912235.555848@nntp.acecape.com: 

> especially for when you are new to a language, being in a visual
> debuger, where you can just grab a variable and play with how you cast
> it, till you get it right is very usefull....

Have you looked at:

http://search.cpan.org/~aepage/Devel-ptkdb-1.1091/ptkdb.pm

You can install it via ppm on Windows and seems to work fine. I 
occasionally use it in conjunction with perl's built-in debugger, the 
command line, and gvim (gvim gives you nice syntax highlighting and 
indenting by the way).

Sinan.




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

Date: Wed, 27 Oct 2004 19:06:46 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: list vs array
Message-Id: <8SVfd.13034$Qs6.1247812@news20.bellglobal.com>


"Michele Dondi" <bik.mido@tiscalinet.it> wrote in message 
news:u01tn05hel3jbsnk5p4mof7v2olel9ttt0@4ax.com...
> On Mon, 25 Oct 2004 20:01:32 -0400, "Matt Garrish"
> <matthew.garrish@sympatico.ca> wrote:
>
>>> I *think* that "ActiveState took forever to load on my machine" means
>>> that AS Perl's installation is a lenghty process: yes, it is! So what?
>>
>>I've never found the actual perl installation to be lengthy, what can take
>>forever on a Windows install is the html documentation generation that AS
>>performs at the end. I've had that process take 10-20 minutes on older
>
> I was loosely speaking: of course the html documentation generation is
> the time consuming part of installation.
>

I know, I just felt like venting a bit about AS. I suppose they generate the 
documentation on the fly like that to avoid the bandwidth cost of including 
pre-compiled docs. I would hope it's not because they're too lazy to compile 
the documentation for each release (and the releases aren't that often that 
it would horribly inconvenience them). If nothing else it would be nice if 
you had the option of skipping that process entirely. Most machines I've 
installed Perl on have not been used by people who will ever work with the 
language.

But I guess I should really be venting to AS, and not here...

Matt 




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

Date: Wed, 27 Oct 2004 19:22:20 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: MAIL recommendation
Message-Id: <1098919568.640497@nntp.acecape.com>

"Michele Dondi" <bik.mido@tiscalinet.it> wrote in message
news:ut00o0lrtj4qcjptgc7crms7r792d7808v@4ax.com...

> And an opinion is a personal thing. If you *really* want to use an
> IDE, then to find the one best suited for *you*, *you* have to try
> some out. I suppose that most experienced users don't use an IDE at
> all...

i ask around, then try a few recommended

> "offers upload"?!? (Are you talking about CGI et similia?) "is
> slow"/"is buggy"? These are other subjective charachteristics. What is
> slow for someone may be acceptably fast for others, and what some
> consider to be a bug may be a feature for someone else. So which is
> the point in asking for a personal opinion at all, *about such a
> thing*?

just general overall discussion where people might come out and say....need
somethign that uploads your code to server?  don;t even bother with
Open-Perl-IDE....and staements such as that

> I haven't checked carefully, but it seems to me that in the best case
> only a minority of those regulars whose opinion I would value as
> precious (those from which I *have* learnt) did give their opinion.

but they did, and they were usefull....

> Oh no! Godwin's law again... bleach!!
wow!  thanks!  i had NO IDEA what this was so i googled it....and what a way
to put me in my place AND make me laugh at the same time.  wow.  here i am
thinking , i am me, i am special, most of my thoughts and ations are
original because i am after all me!  and then i read this and find, i am
merely a pawn in the game of life.  i fall into the same old thinking
patterns as millions before me, i am unoriginal, and just one of the masses
being rustled into the factories....."moo"





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

Date: 27 Oct 2004 23:08:21 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: MAP question
Message-Id: <Xns958FC2B1B14DBasu1cornelledu@132.236.56.8>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in
news:clomen$b2a$3@mamenchi.zrz.TU-Berlin.DE: 

> While the effect is the same, the correct way of writing
> this is to leave all elements unspecified:
> 
>     @allReleases{@_tem} = ();

When I re-read my post, I realized that I did not make it clear that 

@allReleases{@_tem} = undef;

was setting only one element to undef. Thanks for the clarification.

Sinan


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

Date: Thu, 28 Oct 2004 01:51:23 +0200
From: Michal Wojciechowski <odyniec-usenet@odyniec.net>
Subject: Re: Newbie needs help with forking
Message-Id: <87wtxbk9dw.fsf@orion.odyniec.net>

ms7530@yahoo.com (Michael Smith) writes:

> Start a perl script which first forks a process that runs own it's
> own.  This child process will be a Oracle sqlldr job.  This job will
> run for about 30 mintes
>
> While the sqlldr job is running return to the parent thread and
> start running a bunch of database selects and OS commands to give me
> statistics on the overall performance.
>
> Once the sqlldr job completes stop collecting statistics and end the
> script.

Assuming you know how to run the sqlldr job and how to generate the
statistics, the general scheme is quite simple:

  use POSIX ":sys_wait_h";      # for WNOHANG
  
  my $pid;
  
  if ($pid = fork) {
      # parent process
  
      # repeatedly check if the child process is still running
      while (waitpid($pid, WNOHANG) != $pid) {
          #
          # insert your statistics routines here
          #
      }
  }
  else {
      die "Can't fork: $!" unless defined $pid;
  
      # child process
  
      #
      # run sqlldr
      #
  }

You might want to put a sleep() call inside the while (waitpid...)
loop, to prevent it from being executed too often (and thus wasting
precious CPU cycles and making the whole operation slower).

HTH,
-- 
Michal Wojciechowski : for(<>){/\s/,$l{$m=$`}=$'}$_ : 10 PRINT "Yet another"
odyniec()odyniec;net : =$l{$c},/O\s/?$c=$'-1:y/"//d : 20 PRINT "Perl hacker"
 http://odyniec.net  : ,/T\s/?print$':0while$c++<$m : 30 GOTO 10


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

Date: 27 Oct 2004 17:31:08 -0700
From: somedeveloper@hotmail.com (SomeDeveloper)
Subject: Newbie question on regex.
Message-Id: <f530002d.0410271631.3337c7b@posting.google.com>

I'm unable to understand the following statement from
http://search.cpan.org/dist/perl/pod/perlretut.pod.

    "Because, for example, \d and \w are sets of characters, it is
incorrect to think of [^\d\w] as [\D\W];"

Of course, being subsumed by \w, \d is clearly redundant. But
redundancy aside, aren't [^\d\w] and [\D\W] still mathematically
equivalent?

Tia (for responding to my possible ignorance),
Some Developer.


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

Date: 27 Oct 2004 22:10:23 GMT
From: ctcgag@hotmail.com
Subject: Re: Parallel/ Multithreading /Forking?
Message-Id: <20041027181023.843$gk@newsreader.com>

Prab_kar@hotmail.com (Prabh) wrote:
> Hi,
> My task involves searching a huge number of files on filesystem and
> based on the filetype perform some function. e.g. if file is ".java"
> perform a particular routine, if its ".pl" perform another.
>
> As the no. of files is quite huge, I thought it'd be most efficient if
> I used any parallel-processing techinique.

The easiest way to parallel process directory tree is just to run
the program multiple times independently, each one operating from
a different root node.

perl do_stuff.pl /opt/partition1/mystuff &
perl do_stuff.pl /opt/partition1/yourstuff &
perl do_stuff.pl /opt/partition2 &

etc.

But that doesn't do load balancing very well (if one program finishes much
ealier than the others, it will just exit, rather that start working on
whatever the slower ones haven't gotten to yet.)

>
> Some've advised me to use forking, some parallel processing, some
> others multi-threading. Needless to say, I'm confused.

forking and multi-threading are two different ways to do parallel
processing.

> Are these terms being interchangeably used?
> How are they diff. from one another?

In very, very brief and lying more than a little: in Perl forking is
usually for unix/linux and threading is usually for Windows.  For more
honest and accurate descriptions, see "perldoc perlfork" and "perldoc
perlthrtut"


> Could anyone give me a clue what would be a good fit for my task.
> Should I be downloading any CPAN modules and such?

Look at Parallel::ForkManager.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Thu, 28 Oct 2004 00:23:14 +0000 (UTC)
From: Mike Hunter <mhunter@berkeley.edu>
Subject: Scary IPC::Open3 filehandle difference
Message-Id: <slrnco0err.259.mhunter@celeste.net.berkeley.edu>

Hi,

I was experimenting with Open3 and wrote the following two programs:

======buggy.pl:
#!/usr/local/bin/perl -w

use strict;

foreach my $i (1 .. 100)
{
        print STDERR "STDERR $i\n";
        print "STDOUT $i\n";
}

======buggy.pl:
#!/usr/local/bin/perl -w

use strict;
use IPC::Open3;
use IO::Select;

print "starting wrapper...\n";

my $pid = open3(\*WTRFH, \*RDRFH, \*ERRFH, @ARGV);

my $s = IO::Select->new();

#$s->add($wtrfh);
$s->add(\*RDRFH);
$s->add(\*ERRFH);

my $timeout = 1;
my $first_timeout = 3600;
my @ready = $s->can_read($first_timeout);

print "scalar @ready = ".(scalar @ready)."\n";

my $timeouts = 0;
while (scalar @ready)
{
        print "on timeout $timeouts\n";
        $timeouts++;
        my $i = 0;
        foreach my $fh (@ready)
        {
                my $result;

                my $j = 0;
                while ($result = <$fh>)
                {
                        print "read $j:  fh_$i #$fh# says: #".$result."#\n";
                        $j++;
                }
                $i++;
        }
        @ready = $s->can_read($timeout);
        print "scalar @ready = ".(scalar @ready)."\n";
}
print "wrapper finished\n";

Ok, so I run the following:

 ./wrapper.pl ./buggy.pl

and I get 

starting wrapper...
scalar GLOB(0x805cba4) GLOB(0x805cb44) = 2
on timeout 0
read 0:  fh_0 #GLOB(0x805cba4)# says: #STDOUT 1
#
read 1:  fh_0 #GLOB(0x805cba4)# says: #STDOUT 2
#
read 2:  fh_0 #GLOB(0x805cba4)# says: #STDOUT 3
#
read 3:  fh_0 #GLOB(0x805cba4)# says: #STDOUT 4
#
read 4:  fh_0 #GLOB(0x805cba4)# says: #STDOUT 5
#
read 5:  fh_0 #GLOB(0x805cba4)# says: #STDOUT 6
#
read 6:  fh_0 #GLOB(0x805cba4)# says: #STDOUT 7
#
read 7:  fh_0 #GLOB(0x805cba4)# says: #STDOUT 8
#
read 8:  fh_0 #GLOB(0x805cba4)# says: #STDOUT 9
#
read 9:  fh_0 #GLOB(0x805cba4)# says: #STDOUT 10
#
read 0:  fh_1 #GLOB(0x805cb44)# says: #STDERR 1
#
read 1:  fh_1 #GLOB(0x805cb44)# says: #STDERR 2
#
read 2:  fh_1 #GLOB(0x805cb44)# says: #STDERR 3
#
read 3:  fh_1 #GLOB(0x805cb44)# says: #STDERR 4
#
read 4:  fh_1 #GLOB(0x805cb44)# says: #STDERR 5
#
read 5:  fh_1 #GLOB(0x805cb44)# says: #STDERR 6
#
read 6:  fh_1 #GLOB(0x805cb44)# says: #STDERR 7
#
read 7:  fh_1 #GLOB(0x805cb44)# says: #STDERR 8
#
read 8:  fh_1 #GLOB(0x805cb44)# says: #STDERR 9
#
read 9:  fh_1 #GLOB(0x805cb44)# says: #STDERR 10
#
 ...

(still need to write the code to close-out properly)

Anyway, my frist draft had wrapper.pl with the following slightly-different
opening lines:

my ($wtrfh, $rdrfh, $errfh);
my $pid = open3($wtrfh, $rdrfh, $errfh, @ARGV);

my $s = IO::Select->new();

#$s->add($wtrfh);
$s->add($rdrfh);
$s->add($errfh);

And I get the following nutz-oid output:

starting wrapper...
scalar GLOB(0x805cb2c) = 1
on timeout 0
read 0:  fh_0 #GLOB(0x805cb2c)# says: #STDERR 1
#
read 1:  fh_0 #GLOB(0x805cb2c)# says: #STDERR 2
#
read 2:  fh_0 #GLOB(0x805cb2c)# says: #STDERR 3
#
read 3:  fh_0 #GLOB(0x805cb2c)# says: #STDERR 4
#
read 4:  fh_0 #GLOB(0x805cb2c)# says: #STDERR 5
#
read 5:  fh_0 #GLOB(0x805cb2c)# says: #STDERR 6
#
read 6:  fh_0 #GLOB(0x805cb2c)# says: #STDERR 7
#
read 7:  fh_0 #GLOB(0x805cb2c)# says: #STDERR 8
#
read 8:  fh_0 #GLOB(0x805cb2c)# says: #STDERR 9
#
read 9:  fh_0 #GLOB(0x805cb2c)# says: #STDERR 10
#
read 10:  fh_0 #GLOB(0x805cb2c)# says: #STDOUT 1
#
read 11:  fh_0 #GLOB(0x805cb2c)# says: #STDOUT 2
#
read 12:  fh_0 #GLOB(0x805cb2c)# says: #STDOUT 3
#
read 13:  fh_0 #GLOB(0x805cb2c)# says: #STDOUT 4
#
read 14:  fh_0 #GLOB(0x805cb2c)# says: #STDOUT 5
#
read 15:  fh_0 #GLOB(0x805cb2c)# says: #STDOUT 6
#
read 16:  fh_0 #GLOB(0x805cb2c)# says: #STDOUT 7
#
read 17:  fh_0 #GLOB(0x805cb2c)# says: #STDOUT 8
#
read 18:  fh_0 #GLOB(0x805cb2c)# says: #STDOUT 9
#
read 19:  fh_0 #GLOB(0x805cb2c)# says: #STDOUT 10
#

So somehow, it does 20 reads on the same filehandle, which has magically gotten
STDOUT and STDERR of buggy.pl....

???

Oh perl gods, reveal unto me my wickedness.

Mike

BTW this is perl 5.8.2 on fbsd 5.3-beta5


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

Date: 27 Oct 2004 15:24:58 -0700
From: joez3@yahoo.com (joe)
Subject: What are these extra spaces in my registry?
Message-Id: <5619c20c.0410271424.6bc3f80a@posting.google.com>

Hi all,
I am writting a perl script to check my windows 2000 registry to make
sure some keys were added after I installed some software. In my
script I use:
system "regedit \e ....
To dump the registry to a file, I then open this file and do following
to see if
my key is in the file:
       while (<fhTestFile>) {
		if (index ($_, $testValue) > -1) {
			close (fhTestFile);
			return ("TRUE");
		}
	}

The problem I have is that the registry file looks like there are
space between
each char in it. So I maybe looking for:
LOCAL_MACHINE_SOFTWARE
The file contains:
L O C C L _ M A C H I N E _ S O F T W A R E
So my match does not work, also I don't thing the blank spaces are
just extra spaces. Because I added spaces to $testValue and it still
didn't match. Does anyone have any idea what this extra char is? And
how I can get ride of it? I already tried addind chomp $_ before the
if and that didn't help.

Thanks,
Zim





zzzz


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

Date: 27 Oct 2004 22:51:21 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: What are these extra spaces in my registry?
Message-Id: <Xns958FBFCFB10EBasu1cornelledu@132.236.56.8>

joez3@yahoo.com (joe) wrote in 
news:5619c20c.0410271424.6bc3f80a@posting.google.com:

> Hi all,
> I am writting a perl script to check my windows 2000 registry to make
> sure some keys were added after I installed some software. In my
> script I use:
> system "regedit \e ....

 ...

> The problem I have is that the registry file looks like there are
> space between
> each char in it. So I maybe looking for:
> LOCAL_MACHINE_SOFTWARE
> The file contains:
> L O C C L _ M A C H I N E _ S O F T W A R E

Uhm ... Please do not retype this sort of information. It would have been 
best if you had given us a hex dump of the data.

My gues, under the circumstances, is that there is a 0 byte between each 
ASCII character because the native character set of Win2K is 16 bits wide 
(I do not think it is UTF-16, if such a thing exists).

> So my match does not work, also I don't thing the blank spaces are
> just extra spaces. Because I added spaces to $testValue and it still
> didn't match. Does anyone have any idea what this extra char is? And
> how I can get ride of it? 

I don't think I know _the_ right way of dealing with that.

Sinan.


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

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


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