[28160] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9524 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 26 00:05:54 2006

Date: Tue, 25 Jul 2006 21:05:06 -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           Tue, 25 Jul 2006     Volume: 10 Number: 9524

Today's topics:
    Re: Capture a image on client machine <mgarrish@gmail.com>
    Re: Capture a image on client machine <benmorrow@tiscali.co.uk>
    Re: counting number of uniques in a multidimensional ar <DJStunks@gmail.com>
        dumb question about whether hashes get cleared from mem <jack_posemsky@yahoo.com>
    Re: dumb question about whether hashes get cleared from <David.Squire@no.spam.from.here.au>
    Re: dumb question about whether hashes get cleared from <David.Squire@no.spam.from.here.au>
    Re: dumb question about whether hashes get cleared from <David.Squire@no.spam.from.here.au>
    Re: dumb question about whether hashes get cleared from <jgibson@mail.arc.nasa.gov>
    Re: FAQ 4.60 How can I always keep my hash sorted? <ced@blv-sam-01.ca.boeing.com>
    Re: Handling KILL signal in a perl script <benmorrow@tiscali.co.uk>
    Re: Handling KILL signal in a perl script <ced@blv-sam-01.ca.boeing.com>
        is perl a mess as it scales, and is it really hard to d <bootiack@yahoo.com>
    Re: is perl a mess as it scales, and is it really hard  xhoster@gmail.com
    Re: Pass hash to subroutine? <zhushenli@gmail.com>
        Problem starting a new thread from another thread tzhong98-101@yahoo.com
    Re: Problem starting a new thread from another thread <benmorrow@tiscali.co.uk>
    Re: Problem starting a new thread from another thread xhoster@gmail.com
    Re: regarding a counter file <someone@example.com>
    Re: Semantics of threads xhoster@gmail.com
    Re: Semantics of threads <benmorrow@tiscali.co.uk>
    Re: Semantics of threads <blgl@stacken.kth.se>
    Re: serial port blocking - windows <see.sig@rochester.rr.com>
    Re: UNIVERSAL::isa($object, 'UNIVERSAL') returns false? <kevin@vaildc.net>
    Re: Use MSXML in perl without registration <shah.vinay@gmail.com>
    Re: Use MSXML in perl without registration <shah.vinay@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 25 Jul 2006 16:39:37 -0700
From: "Matt Garrish" <mgarrish@gmail.com>
Subject: Re: Capture a image on client machine
Message-Id: <1153870777.013731.50310@p79g2000cwp.googlegroups.com>


pjsenthil@gmail.com wrote:

[TOFU corrected ]

>
> Matt Garrish wrote:
> > pjsenthil@gmail.com wrote:
> > > Mine is a Client -server Acrichitecture..The client will be viewing a
> > > video..if interested he will capture a video frame. and he will store
> > > on the server machine..and the corresponding path of the image will be
> > > stored on the server and will be used for further editions...
> > >
> >
> > >From a browser, you wouldn't be able to do it unless the person
> > captures the image, saves it and then uploads it through a form.
> >
> > You could write a client-side application to do the work of capturing
> > the image and posting it back to the server, but that would of course
> > require the user to install your app. You could write such a beast in
> > Perl and compile it to an executable, but how it would work (i.e.,
> > capture the image) would would depend on what OS it's run on. And you'd
> > likely find yourself limited to a simple screen capture of the users
> > desktop (unless the video is running in full-screen mode, I suppose).
> >
> But i thought of doing it in client server architecture with making it
> as installable application..that is in web...
>
> Is it not possible....do it in javascript...

Is the user viewing the video in another application on the computer,
or are you talking about a video embedded in a web page?

Javascript only gives you access to the browser's dom, so if you're
talking about the former it can't be done. And even if you're talking
about an embedded movie you'd still never be able to access what's
currently being run from a javascript.

The only thing that springs to my mind that would have the power to do
what you want is a custom browser plugin, but you don't write those in
Perl (but I'd be interested if someone were to prove me wrong on that
call).

Matt



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

Date: Wed, 26 Jul 2006 01:48:13 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Capture a image on client machine
Message-Id: <dnqip3-vlf.ln1@osiris.mauzo.dyndns.org>


Quoth "Matt Garrish" <mgarrish@gmail.com>:
> 
> The only thing that springs to my mind that would have the power to do
> what you want is a custom browser plugin, but you don't write those in
> Perl (but I'd be interested if someone were to prove me wrong on that
> call).

Well.... :) A Gecko plugin is just a C shared library, and an IE plugin
is just an ActiveX control, so either could ember a Perl interpreter and
have the majority of its code written in Perl.... :)

Ben

-- 
Giles: It's very common for Indian spirits to change to animal form.
Buffy: [...] and, 'Native American'. G: Sorry? B: We don't say 'Indian'.
G: Oh, right, yes; always behind on the terms... yes, still trying not to refer
to you lot as 'bloody colonials'.      [Buffy, 'Pangs'] benmorrow@tiscali.co.uk


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

Date: 25 Jul 2006 17:39:14 -0700
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: counting number of uniques in a multidimensional array column
Message-Id: <1153874354.076349.104220@b28g2000cwb.googlegroups.com>

Jack wrote:
> Ted, great job that works killer... can you tell me, I want to exclude
> from the counting any null values, I tried adding this without
> success..any reply would be appreciated..thanks, Jack
>
>  sub uniques
>  {
>   my %unique = ();
>   if (@_ != /^\z/) { $unique{$_}++ foreach @_ }  ;

1) this ---^^ only operates on a scalar; thus
2) this ^^ array is forced into scalar context; and
3) an array evaluated in scalar context yields the count of
   the number of elements in the array; but
4) here ---^^ you mistyped the negated binding operator; therefore
5) this ------^^^^^ attempts to match against whatever is
   currently contained in $_; and
6) if the return value for this test (1 or 0) is not equal to the
   number of elements in @_ (likely > 1); then
5) the block will be evaluated

>  return keys %unique;
> }

if only there were some way to test the value
foreach element of the array...

-jp



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

Date: 25 Jul 2006 15:36:21 -0700
From: "Jack" <jack_posemsky@yahoo.com>
Subject: dumb question about whether hashes get cleared from memory automatically
Message-Id: <1153866981.130323.197060@m79g2000cwm.googlegroups.com>

Hello,

I am creating several hashes over different large amounts of data as
part of a loop, and capturing some values from a given hash with each
iteration.  I dont want to keep them around in memory once I get the
results I am after and then go to the next iteration - I need to be
concerned about memory usage since I am dealing with a large volume -
do I need to actually "clear" the hash like once normally does with an
array or variable or are hashes automatically cleared with the next one
??  If hashes need to be cleared, what is the syntax ?

Thank you,

Jack



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

Date: Tue, 25 Jul 2006 23:40:09 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: dumb question about whether hashes get cleared from memory automatically
Message-Id: <ea66k9$6vh$1@gemini.csx.cam.ac.uk>

Jack wrote:
> Hello,
> 
> I am creating several hashes over different large amounts of data as
> part of a loop, and capturing some values from a given hash with each
> iteration.  I dont want to keep them around in memory once I get the
> results I am after and then go to the next iteration - I need to be
> concerned about memory usage since I am dealing with a large volume -
> do I need to actually "clear" the hash like once normally does with an
> array or variable or are hashes automatically cleared with the next one
> ??  If hashes need to be cleared, what is the syntax ?
> 

perldoc -q memory


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

Date: Tue, 25 Jul 2006 23:43:41 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: dumb question about whether hashes get cleared from memory automatically
Message-Id: <ea66qt$6vh$2@gemini.csx.cam.ac.uk>

David Squire wrote:
> Jack wrote:
>> Hello,
>>
>> I am creating several hashes over different large amounts of data as
>> part of a loop, and capturing some values from a given hash with each
>> iteration.  I dont want to keep them around in memory once I get the
>> results I am after and then go to the next iteration - I need to be
>> concerned about memory usage since I am dealing with a large volume -
>> do I need to actually "clear" the hash like once normally does with an
>> array or variable or are hashes automatically cleared with the next one
>> ??  If hashes need to be cleared, what is the syntax ?
>>
> 
> perldoc -q memory

Sorry, that's not the FAQ question I was thinking of. No doubt someone 
else will give it. Basically, once Perl has got memory from the OS for 
you, it won't give it back. It might reuse it once the Perl garbage 
collector is done with it - which should happen once you have got rid of 
all references to it.


DS


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

Date: Tue, 25 Jul 2006 23:46:06 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: dumb question about whether hashes get cleared from memory automatically
Message-Id: <ea66ve$6vh$3@gemini.csx.cam.ac.uk>

David Squire wrote:
> David Squire wrote:
>> Jack wrote:
>>> Hello,
>>>
>>> I am creating several hashes over different large amounts of data as
>>> part of a loop, and capturing some values from a given hash with each
>>> iteration.  I dont want to keep them around in memory once I get the
>>> results I am after and then go to the next iteration - I need to be
>>> concerned about memory usage since I am dealing with a large volume -
>>> do I need to actually "clear" the hash like once normally does with an
>>> array or variable or are hashes automatically cleared with the next one
>>> ??  If hashes need to be cleared, what is the syntax ?
>>>
>>
>> perldoc -q memory
> 
> Sorry, that's not the FAQ question I was thinking of. No doubt someone 
> else will give it.

It's perldoc -q free, 2nd question: "How can I free an array or hash so 
my program shrinks?"


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

Date: Tue, 25 Jul 2006 16:34:31 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: dumb question about whether hashes get cleared from memory automatically
Message-Id: <250720061634318807%jgibson@mail.arc.nasa.gov>

In article <1153866981.130323.197060@m79g2000cwm.googlegroups.com>,
Jack <jack_posemsky@yahoo.com> wrote:

> Hello,
> 
> I am creating several hashes over different large amounts of data as
> part of a loop, and capturing some values from a given hash with each
> iteration.  I dont want to keep them around in memory once I get the
> results I am after and then go to the next iteration - I need to be
> concerned about memory usage since I am dealing with a large volume -
> do I need to actually "clear" the hash like once normally does with an
> array or variable or are hashes automatically cleared with the next one
> ??  If hashes need to be cleared, what is the syntax ?

Define the hash inside the loop:

   while( <more_iterations> ) {
      my %hash;
      ...
   }

The hash will go out of scope at the end of the loop and you will get a
fresh, empty one at the beginning of each loop.

To explicitly clear a hash:

   undef %hash;

or

   %hash = ();

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: Tue, 25 Jul 2006 23:38:42 GMT
From: Charles DeRykus <ced@blv-sam-01.ca.boeing.com>
Subject: Re: FAQ 4.60 How can I always keep my hash sorted?
Message-Id: <J2zGCG.73y@news.boeing.com>

PerlFAQ Server wrote:
> This is an excerpt from the latest version perlfaq4.pod, which
> comes with the standard Perl distribution. These postings aim to 
> reduce the number of repeated questions as well as allow the community
> to review and update the answers. The latest version of the complete
> perlfaq is at http://faq.perl.org .
> 
> --------------------------------------------------------------------
> 
> 4.60: How can I always keep my hash sorted?
> 
>     You can look into using the DB_File module and tie() using the $DB_BTREE
>     hash bindings as documented in "In Memory Databases" in DB_File. The
>     Tie::IxHash module from CPAN might also be instructive.
> 

While not wanting to heap on calories, I think mention of Tie's speed 
penalty is warranted:

    +Caveat: The Tie interface can signficantly slow the performance of
             large hashes.

-- 
Charles DeRykus

timethese( 1_000, { 'IxHash' => sub { require Tie::IxHash;
                                       tie my %h,'Tie::IxHash' or die $!;
                                       $h{$_} = rand 1_000 for 1..1_000;
                                     },
                     'normal' => sub { my %h1; $h1{$_} = rand 1_000
                                                       for 1..1_000; }
                   } );

IxHash: 88 wallclock secs (59.60 usr +  0.01 sys = 59.61 CPU) @ 
16.78000)
normal:  9 wallclock secs ( 5.82 usr +  0.00 sys =  5.82 CPU) @
171.81000)


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

Date: Tue, 25 Jul 2006 23:45:44 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Handling KILL signal in a perl script
Message-Id: <ohjip3-5hc.ln1@osiris.mauzo.dyndns.org>


Quoth anno4000@radom.zrz.tu-berlin.de:
> A. Sinan Unur <1usa@llenroc.ude.invalid> wrote in comp.lang.perl.misc:
> > "Paul Lalli" <mritty@gmail.com> wrote in news:1153835306.539633.129170
> > @h48g2000cwc.googlegroups.com:
> > 
> > > Swarup Baran wrote:
> > >> What i need to handle is if this perl process gets a kill process
> > >> either because of a manual  kill or machine reboot etc. I should be
> > >> able to trap it, clean up if any resources and then EXIT.
> > > 
> > > My understanding is that SIGKILL is very specifically *not* trappable.
> > > Otherwise, it would be possible to write a program that simply cannot
> > > be stopped (short of rebooting the machine). 
> > 
> > IIRC, On the *nix machines I have run, issuing the reboot command from the 
> > prompt, results in the OS sending a SIGHUP, followed by a KILL. Presumably, 
> > the SIGHUP is to allow processes to clean up.
> 
> SIGHUP isn't universal, I think, but the procedure is:  First send
> a catchable signal and wait a bit, then SIGKILL all processes that
> haven't got the hint.

This is way OT, but any user processes will receive SIGHUP when their
session leader terminates. This is in POSIX. Process started from
/etc/rc (or whatever) will be stopped by the same mechanism, which
generally ends up sending a SIGTERM, though it may do other things. At
least linux sends TERM to all processes just before halt, before a final
KILL.

Ben

-- 
                Outside of a dog, a book is a man's best friend.
                Inside of a dog, it's too dark to read.
benmorrow@tiscali.co.uk                                           Groucho Marx



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

Date: Wed, 26 Jul 2006 00:00:06 GMT
From: Charles DeRykus <ced@blv-sam-01.ca.boeing.com>
Subject: Re: Handling KILL signal in a perl script
Message-Id: <J2zHC5.7wn@news.boeing.com>

Swarup Baran wrote:
> Hello All,
> 
> Here is what the scenario is...
> 
> I have a perl script which runs for hours reading data and processing
> it.
> 
> What i need to handle is if this perl process gets a kill process
> either because of a manual  kill or machine reboot etc. I should be
> able to trap it, clean up if any resources and then EXIT.
> 

Normally then, someone will send you a TERM (and possibly follow that 
with an untrappable KILL if ignored), so you could catch TERM at least:

   $SIG{ TERM } = sub { ... # cleanup  };


hth,
-- 
Charles DeRykus




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

Date: 25 Jul 2006 17:50:25 -0700
From: "gavino" <bootiack@yahoo.com>
Subject: is perl a mess as it scales, and is it really hard to debug?
Message-Id: <1153875025.170366.204640@s13g2000cwa.googlegroups.com>

I hear people bitch about perl but others say its most productive
language.



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

Date: 26 Jul 2006 03:55:26 GMT
From: xhoster@gmail.com
Subject: Re: is perl a mess as it scales, and is it really hard to debug?
Message-Id: <20060726000159.763$94@newsreader.com>

"gavino" <bootiack@yahoo.com> wrote:

Please put your question in your message as well as in the subject line.


] is perl a mess as it scales,

Scales in what dimension?  Code gets bigger?  Data structures get bigger?
Programs run for longer times without restarting?  number of threads
increases?

] and is it really hard to debug?

If you write spaghetti code, it will be hard to debug.  In any language.

> I hear people bitch about perl but others say its most productive
> language.

For some people it is the most productive.  Other people need the B&D of
something like Java to keep them from shooting themselves in the foot.

Xho

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


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

Date: 25 Jul 2006 18:28:22 -0700
From: "Davy" <zhushenli@gmail.com>
Subject: Re: Pass hash to subroutine?
Message-Id: <1153877302.404249.295040@h48g2000cwc.googlegroups.com>

Hi,

Thanks!

I have used "use *" as you said. And find I should pass \% to
subroutine. All work ok!

Best regards,
Davy

Paul Lalli wrote:
> Davy wrote:
> > How to pass hash to subroutine?
> > And my code list below(it seems the hash has not been passed to sub??):
>
> No, it was passed just fine.  You just didn't grab it in the subroutine
> itself.
>
>
> > Code:
> > #!/usr/local/bin/perl
>
> You forgot:
> use strict;
> use warnings;
>
> Put these at the top of *every* script you write.  They find 95% of the
> errors you're likely to make - including the one you made in this
> program.
>
> > %mc_mode_hash = ( "00" => "mc_mode_0",
>
> What is the point of the _hash suffix of this variable name?  The %
> already identifies this as a hash.
>
> >                   "01" => "mc_mode_1",
> >                   "10" => "mc_mode_2");
> > my $my_cnt = 1;
> > $my_cnt = &init_cnt_ref(%mc_mode_hash);
>
> Why are you calling your subroutine with the & prefix?  Do you know
> what two side effects that causes?  Do you want those side-effects?  If
> not, leave it off.
>
> > print ("my_cnt is $my_cnt \n");
> > sub init_cnt_ref(\%)
> > {
> >     #my (%hash0) = %{(shift)};
>
> This would have worked correctly, had you not made the mistake that
> 'use warnings' would have told you about.  Put that statement in, and
> you'll see what you did wrong.
>
> >     my %hash0 = %_ ;
>
> This is nonsense, as %_ is not a special variable.  Arguments are
> passed in to a subroutine via the local @_ array.
>
> my %hash0 = @_;
>
> >     my $cnt = 0;
> >     foreach $mc_mode ( values(%hash0))
> >     {
> >         print "mc_mode is $mc_mode \n";
> >         $cnt ++;
> >     } 
> >     return $cnt; 
> > } 
> 
> 
> Paul Lalli



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

Date: 25 Jul 2006 16:18:18 -0700
From: tzhong98-101@yahoo.com
Subject: Problem starting a new thread from another thread
Message-Id: <1153869498.525446.302770@m73g2000cwd.googlegroups.com>

I am trying to do some threading with perl, and my simple script just
refuses to work. Basically I created a new thread (T1), and then
attempted to create another one (T2) from within T1, which failed
silently. Could anyone tell me why that is?

======== The sample code ========

#!C:/perl/bin/perl.exe

use strict;
use IO::Socket;
use Thread;
use Config;
$Config{useithreads} or die "Recompile Perl with threads to run this
program.";


sub foo2 {
    sleep(5);
    print "foo2";
    print "T2 is done";
    }

sub foo1 {
    sleep(2);
    print "foo1";
    my $t2 = new Thread \&foo2;
    print "T2 is launched";
}

$\ = "\n";
my $t1 = new Thread \&foo1;
print "T1 is launched";

===== End of sample code ====

The Output:

T1 is launched
foo1


Apparently thread T2 is not even started. What's wrong?

Thanks,
Tim



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

Date: Wed, 26 Jul 2006 00:28:08 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Problem starting a new thread from another thread
Message-Id: <81mip3-fld.ln1@osiris.mauzo.dyndns.org>


Quoth tzhong98-101@yahoo.com:
> I am trying to do some threading with perl, and my simple script just
> refuses to work. Basically I created a new thread (T1), and then
> attempted to create another one (T2) from within T1, which failed
> silently. Could anyone tell me why that is?
> 
> ======== The sample code ========
> 
> #!C:/perl/bin/perl.exe
> 
> use strict;
> use IO::Socket;
> use Thread;

Thread.pm is for 5005threads. I believe it does back-compat with
ithreads, but you should be using threads.pm nowadays.

> use Config;
> $Config{useithreads} or die "Recompile Perl with threads to run this
> program.";

There's no need for this. threads.pm will croak if perl doesn't have
threads enabled (if you want threads iff they're there, you need to do
something like

    use constant HAVE_THREADS => eval { 
        require threads; 
        threads->import;
        1;  # work around a bug in (IIRC) 5.8.1
    };

and then test HAVE_THREADS (untested, as my perl isn't threaded)).

Ben

-- 
                Outside of a dog, a book is a man's best friend.
                Inside of a dog, it's too dark to read.
benmorrow@tiscali.co.uk                                           Groucho Marx


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

Date: 26 Jul 2006 03:40:12 GMT
From: xhoster@gmail.com
Subject: Re: Problem starting a new thread from another thread
Message-Id: <20060725234645.165$LW@newsreader.com>

tzhong98-101@yahoo.com wrote:
> I am trying to do some threading with perl, and my simple script just
> refuses to work. Basically I created a new thread (T1), and then
> attempted to create another one (T2) from within T1, which failed
> silently. Could anyone tell me why that is?

Do you get any message like this:
A thread exited while 2 threads were running.
If so, you should either join the threads or just put a sleep in the main
code to give the threads time to finish.

>
> ======== The sample code ========
>
> #!C:/perl/bin/perl.exe
>
> use strict;
> use IO::Socket;
> use Thread;

You should probably use threads;, not use Thread;.

Xho

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


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

Date: Tue, 25 Jul 2006 23:05:51 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: regarding a counter file
Message-Id: <jtxxg.159763$S61.52970@edtnps90>

andy wrote:
> My requirement is as below:
> I want a counter of 3 numbers and it will count and keep the last count
> as it is.
> The second time i open and run this script and press count buttons it
> should start counting from the last counter value.

use Tie::File;

my $counter_file = "$ENV{HOME}/.counter_file";

tie my @counters, 'Tie::File', $counter_file
    or die "Cannot open '$counter_file' $!";

# initialize @counters if this is the first time
@counters = ( 1, 2, 3 ) unless @counters;

my $current_counter = shift @counters;

# code that uses the $current_counter


push @counters, $current_counter;

untie @counters;



> Each time a count button is pressed it should be loged in to a txt file
> with date and time.
> I have written the script but not able to print the date and time in to
> the log file.

print LOG_FILE scalar localtime, "  counter = $current_counter\n";

Or if you want more control over the date and time formats:

use POSIX 'strftime';

print LOG_FILE strftime( '%x %X', localtime ), "  counter = $current_counter\n";




John
-- 
use Perl;
program
fulfillment


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

Date: 25 Jul 2006 22:38:33 GMT
From: xhoster@gmail.com
Subject: Re: Semantics of threads
Message-Id: <20060725184503.827$98@newsreader.com>

Bo Lindbergh <blgl@stacken.kth.se> wrote:
> In article <20060725150335.583$GO@newsreader.com>, xhoster@gmail.com
> wrote:
>
> > Bo Lindbergh <blgl@stacken.kth.se> wrote:
> > > Really?  I looked at the source and found no attempts to block other
> > > threads from running between the fork and the exec.
> >
> > It would really help to know what version of the source you looked at,
> > and the file(s) and line numbers
>
> 5.9.3, pp_sys.c, line 3950: start of pp_system.
> line 3956: taint handling.
> line 3966: output buffer flushing.
> line 3975: fork attempts start here.

But only if the #ifdef is satisfied.

> No sign of any thread-related stuff.

Actually there is, if you dig down into the guts of the
PerlProc_fork procedure (or the Perl_my_fork procedure, which is what
it seems to resolve to).  For all I know, that stuff is just a no-op on
some systems, but it is present for when it is needed.

Anyway, if you compare pp_fork and pp_system, you will see that pp_system
does not simply call pp_fork, and looks quite different from it.  Once you
resolve all the indirection, it may turn out that they do the same thing on
your OS, but if so that is only because that is what works best for your
system. Sometimes doing the right thing and doing the naive thing turn out
to be the same thing--the difference is in whether you know it is the right
thing in your case.

Xho

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


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

Date: Wed, 26 Jul 2006 00:18:26 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Semantics of threads
Message-Id: <2flip3-m8d.ln1@osiris.mauzo.dyndns.org>


Quoth Bo Lindbergh <blgl@stacken.kth.se>:
> 
> Really?  I looked at the source and found no attempts to block other
> threads from running between the fork and the exec.

I think you're suffering from the same misconception as I was: fork
doesn't duplicate all the threads in the process, only the calling
thread. You get a single new thread in the new process, which is why you
need pthread_atfork, to clear up any mess (mutexes) left by the threads
which no longer exist in this process.

Otherwise, yes, there would be a race condition between fork and exec,
where another thread could do something significant (IO, whatever) that
wouldn't be destroyed by the exec.

Ben

-- 
For far more marvellous is the truth than any artists of the past imagined!
Why do the poets of the present not speak of it? What men are poets who can
speak of Jupiter if he were like a man, but if he is an immense spinning
sphere of methane and ammonia must be silent?~Feynmann~benmorrow@tiscali.co.uk


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

Date: Wed, 26 Jul 2006 03:22:46 +0200
From: Bo Lindbergh <blgl@stacken.kth.se>
Subject: Re: Semantics of threads
Message-Id: <ea6g57$dt2$1@news.su.se>

In article <2flip3-m8d.ln1@osiris.mauzo.dyndns.org>,
 Ben Morrow <benmorrow@tiscali.co.uk> wrote:

> Quoth Bo Lindbergh <blgl@stacken.kth.se>:
> > 
> > Really?  I looked at the source and found no attempts to block other
> > threads from running between the fork and the exec.
> 
> I think you're suffering from the same misconception as I was: fork
> doesn't duplicate all the threads in the process, only the calling
> thread.

So you claim that it's a documentation error: the "some UNIX systems
copy all the current threads into the child process" part should be
removed from perlthrtut?


/Bo Lindbergh


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

Date: Wed, 26 Jul 2006 00:39:04 GMT
From: Bob Walton <see.sig@rochester.rr.com>
Subject: Re: serial port blocking - windows
Message-Id: <IQyxg.10366$1Z5.1000@twister.nyroc.rr.com>

sonnichs@berkshire.net wrote:
> Can anyone tell me how to control whether windows operates in
> blocking/nonblocking mode when programming the serial port with perl?
> It does not appear that I can use a system call to the windows "mode"
> command for this.
 ...
> Fritz
> 

use Win32::SerialPort;

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl


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

Date: Wed, 26 Jul 2006 01:21:44 GMT
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: UNIVERSAL::isa($object, 'UNIVERSAL') returns false?
Message-Id: <kevin-F195BA.21214425072006@news.verizon.net>

In article <44c2d8d9$0$22362$afc38c87@news.optusnet.com.au>,
 "Sisyphus" <sisyphus1@nomail.afraid.org> wrote:

> "Kevin Michael Vail" <kevin@vaildc.net> wrote in message
> news:kevin-9A3177.20500722072006@news.verizon.net...
> > I ran across a problem yesterday that I traced back to this line in
> > Callback.pm:
> >
> >     if (ref $func ne 'CODE' && UNIVERSAL::isa($func, "UNIVERSAL")) {
> >
> 
> What is Callback.pm ? I don't seem to have it (though I do have As build
> 638).

Oh, sorry, it's the Callback module (from CPAN) - a means of doing 
Tk-like callbacks but in normal Perl code.

> > $func was a blessed reference, so this should have been true.  Instead,
> > sometimes it wasn't.  It seems to depend on the data being processed at
> > the time, and I haven't yet been successful in producing anything
> > smaller than my entire program that can reproduce it yet.
> 
> Keep working at producing a minimal demo .... I suspect it is what we really
> need.

I suspect so, too, but I still haven't managed to do this.  (But to be 
honest, I haven't had the time to move it to the front burner.)

> >
> > One thing I discovered is that if I place a breakpoint here when the
> > comparison fails, and then (in the debugger) do the following:
> >
> >     use Scalar::Util qw(blessed);
> >     p blessed $func
> >
> > Not only does that print 1, but it makes the UNIVERSAL::isa function
> > return true afterwards as well!
> 
> It might be useful to do a Devel::Peek::Dump($func) under the various
> scenarios and look for differences. If Devel::Peek::Dump($func) *does* show
> up some variations (which is by no means guaranteed) then that might help to
> determine what's going on.

True.  I will try this when I have time.

> > This is in ActiveState Perl 5.6.1 (build 638).  I haven't been able to
> > try to get this to fail under 5.8.x because I'm not able to move to that
> > version yet (interactions with Perl2Exe that I haven't had time to track
> > down yet, involving problems with regular expressions), although I
> > suspect that's the real solution.
> >
> > As a workaround, I replaced the line above with
> >
> >     if (ref $func ne 'CODE' && blessed $func) {
> >
> > which is fine for what I'm doing (internal utilities, compiled with
> > perl2exe and installed on workstations without Perl), but obviously not
> > ideal.
> >
> > Note: it may not be clear from the above, but the problem shows up both
> > running under Perl2Exe and when just running normally.
> 
> There's probably nothing to stop you from also installing the latest perl
> 5.8.8 and seeing whether the same problem still exists. Not sure that would
> achieve much beyond determining whether the bug disappears with perl 5.8.8.
> (When installing additional versions of ActiveState perl I always download
> the zip package, rather than the msi, and then install by running the
> 'install.bat', making sure to *not* accept any options that will mess with
> the registry or the path.)

I've got 5.8.8 installed as well as 5.6.1, but would have to move a lot 
of custom modules over first.  Have attempted to upgrade several times, 
but I always run into something.  At first it was DBD::Oracle; then I 
discovered the Oracle Instant Client library.  Now it's regular 
expressions failing, but only under Perl2Exe.  (There also seems to be a 
problem with embedded widgets in the Tk::HList widget, but I haven't 
tried to track that one down yet.)

> > I guess my Perl question is WTF??  I seem to recall reading somewhere
> > about a bug in "isa" in a particular Perl version that might have been
> > 5.6.1, but I don't recall where now, and never did have any details.
> 
> Comparing 'perldoc UNIVERSAL' for both 5.6 and 5.8, I note that under perl
> 5.6, we are advised to *not* do 'use UNIVERSAL qw(isa)', whereas, with perl
> 5.8, it's quite ok to import UNIVERSAL functions into the main namespace.
> Could that be what you're thinking of ?

Could be!
-- 
boss, sometimes i think           |  kevin michael vail
that our friend mehitabel         |  kevin@vaildc.net
is a trifle too gay               |
        -- archy                  |  wotthehell wotthehell


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

Date: 25 Jul 2006 20:50:25 -0700
From: "Vinay" <shah.vinay@gmail.com>
Subject: Re: Use MSXML in perl without registration
Message-Id: <1153885825.689805.57570@m73g2000cwd.googlegroups.com>

You would think whats the harm in registering? I think so too :)
But the issue is that this script fo mine will be part of a set of
bigger changes(more scripts), that some one can just copy over to the
system and use. It should not touch the base OS or install anything on
the machine.
Its a customer's requirement.
Thanks for your analysis. I have not yet looked into the problem
deeply. I will post something if I find an answer to this.

Vinay


Ben Morrow wrote:
> Quoth "Sisyphus" <sisyphus1@nomail.afraid.org>:
> >
> > "Vinay" <shah.vinay@gmail.com> wrote in message
> > news:1153782403.410656.21810@75g2000cwc.googlegroups.com...
> > > I would like to use MSXML4.0 in my perl script, but not have it
> > > register on my machine. The way to do that is explained for C++ at this
> > > link:
> > > http://www.perfectxml.com/articles/msxml/TipsAugust02.asp
> > > I am finding it difficult to port it over to perl. Anyone has any clue
> > > for the same? What steps do I need to take?
> > >
> >
> > You could use Inline::CPP to run that code from perl .... but only if you
> > have a C++ compiler.
>
> But what would be the point of that? The point is to write Perl :).
>
> Note you could probably make mingw work with some effort... and you can
> precompile the module. I would probably *not* use Inline, but just write
> an XS module in C++ if I was going down that route.
>
> > Otherwise you can use the Win32::API module.
> >
> > With Win32::API, I envisage that there's no need to call LoadLibrary,
> > GetProcessAddress, and FreeLibrary. Instead you just access the functions
> > from the dll directly. (However, I'm not sure if that's correct - given that
> > you're dealing with COM objects.)
>
> That is correct insofar as calling Win32 APIs (or: C functions in DLLs
> with the __stdcall calling convention) goes: the Win32::API
> instantiation process does the LoadLibrary for you. However, you can't
> call C++ member functions at all, so you can't translate that code.
>
> The whole concept seems a little dodgy to me: why can't you just
> register the component from your script
> (system "regsvr32 $ENV{SYSTEMROOT}\\system32\\msxml4.dll"; IIRC; perhaps
> in a BEGIN block) and then use it properly with Win32::OLE?
>
> Ben
>
> --
>   The cosmos, at best, is like a rubbish heap scattered at random.
>                                                            Heraclitus
>   benmorrow@tiscali.co.uk



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

Date: 25 Jul 2006 20:54:41 -0700
From: "Vinay" <shah.vinay@gmail.com>
Subject: Re: Use MSXML in perl without registration
Message-Id: <1153886081.415161.325640@h48g2000cwc.googlegroups.com>

Thanks. It explains how to use MSXML better, not on how to load it from
the dll, which I want to do.

tuser wrote:
> Vinay wrote:
> > I would like to use MSXML4.0 in my perl script, but not have it
> > register on my machine. The way to do that is explained for C++ at this
> > link:
> > http://www.perfectxml.com/articles/msxml/TipsAugust02.asp
> > I am finding it difficult to port it over to perl. Anyone has any clue
> > for the same? What steps do I need to take?
>
> Have a look at the posting in comp.lang.perl.misc
> "Windows ActiveState Perl: MSXML transformNodeToObject finally
> succeeded"
> Date: 17/02/2006 23:14
> http://tinyurl.co.uk/5ljh



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

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


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