[22652] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4873 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 22 00:06:07 2003

Date: Mon, 21 Apr 2003 21:05: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           Mon, 21 Apr 2003     Volume: 10 Number: 4873

Today's topics:
    Re: Accesing machines of a network (Bryan Castillo)
        ANNOUNCE: MPEG::Audio::Frame (Yuval Kojman)
        compare two files (Herb Burnswell)
    Re: compare two files <trh411@earthlink.net>
    Re: compare two files <bwalton@rochester.rr.com>
    Re: Copying files efficiently <spam@thecouch.homeip.net>
    Re: Extract data from 3 lines, combine into 1 line Help (Skinny Guy)
    Re: fake flocking on win32 <bwalton@rochester.rr.com>
    Re: Help: ? $next_one == ${next_one} <bwalton@rochester.rr.com>
    Re: How can I hide a specific Window (Thomas B)
    Re: How can I hide a specific Window <kalinabears@hdc.com.au>
    Re: korn shell or perl (Philip Brown)
    Re: network install, access via registry mod, win env (Bryan Castillo)
    Re: Perl source install over redhat rpm <pa@panix.com>
    Re: print out multi queries (Bryan Castillo)
    Re: print out multi queries <jurgenex@hotmail.com>
    Re: Returning Values from a Perl Thread (Bryan Castillo)
    Re: Returning Values from a Perl Thread <spokester@REMOVE-MEcox.net>
    Re: Trying to get a list of Currently running Windows A <kalinabears@hdc.com.au>
    Re: Using Rijndael encryption on socket connection betw (Bryan Castillo)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 21 Apr 2003 17:33:39 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Accesing machines of a network
Message-Id: <1bff1830.0304211633.4ad1eecb@posting.google.com>

Warning: if you ask for a review you mostly get negative comments.


1. Don't use & to call subroutines unless you are calling
   them before the sub definition appears and you are not using ()'s.
   It makes the script look like perl 4.
   
2. Don't use a temp file for the net view command, just to reopen it
   parse it and delete it.  Use a pipe.  (the example I showed you 
   used one).  Using a pipe elimates a file that could get corrupted
   if more than 1 instance of your script is running at the same time.

3. Don't use a global array - (Obviously, you used this because
   the wanted function for File::Find can not have extra arguments
   passed to it.  Instead, use a closure. (might be slower though)).
   You could have also had the wanted function print directly to the file
   without storing in memory (unless you were planning on sorting them 
   before writing them to file).
   [I might get some arguments here about the closure]

# Im using IO::File to show you that a my variable can be
# accessed from a closure.
use File::Find;
use IO::File; 

# you would call this as getFilesRecursively("logfile.txt", "folder");
sub getFilesRecursively {
  my $filename = shift;
  my $out = IO::File->new($filename, "a") ||
       die "Failed to open $filename. $!";
  find(sub {
     my $file = lc($File::Find::name);
     $file =~ s/\//\\/g;
     print $out $file, "\n";
  }, @_);
  $out->close;
} 


3(b). The global array you used you initialized like so:
     @allFileName = [];
     In doing this you are setting $allFileName[0] to a
     newly created array reference.  You have an array within an array.
     I don't think you meant to do this.

4. use strict;

5. use warnings;


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

Date: Mon, 21 Apr 2003 23:43:21 GMT
From: nothingmuch@altern.org (Yuval Kojman)
Subject: ANNOUNCE: MPEG::Audio::Frame
Message-Id: <8e5306ef514dc2087407a92fe43d3b1c@news.teranews.com>

This module provides a class for creating objects representing MPEG 1
or 2 audio frames from a filehandle. It provides an object oriented
interface, aswell as a tied one, and is available at CPAN.

version 0.03 provides a missing method from it's perceeders aswell as
some documentation fixes.


It's implemented in pure perl and is provided mainly as a utility for
datagram based streaming or safe munging of mp3 streams.




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

Date: 21 Apr 2003 18:43:37 -0700
From: patyoung13@hotmail.com (Herb Burnswell)
Subject: compare two files
Message-Id: <3b38898e.0304211743.1daeee39@posting.google.com>

Hi All,

I am a beginner with perl and would greatly appreciate some
assistance.  I want to compare two log files and if they are
significantly different in size, send myself an email.  I would like
to do something similar to:

 #!/usr/bin/perl

$file1 = "logfile1";
$file2 = "logfile2";

$size1 = `wc -l $file1 | awk '{print \$1}'`;
$size2 = `wc -l $file2 | awk '{print \$1}'`;
$diff  = "($size1 - $size2)";

if ( "$diff" +- 300 ) {

      $commandline = "mailx –s "my subject" me@me.com < warningfile";
       system ( $commandline );

}

exit;

As you can see, I don't know the proper syntax but that is the idea of
what I need.  I really don't know the best way of going about this
either.  Is there an easier way than to use ‘wc –l'?  I can't really
use diff because the files will have different info.  Thank you very
much in advance for any information or links to information provided.

Herb


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

Date: Tue, 22 Apr 2003 02:09:11 GMT
From: "Tom Hoffmann" <trh411@earthlink.net>
Subject: Re: compare two files
Message-Id: <pan.2003.04.22.02.08.39.824509@earthlink.net>

On Mon, 21 Apr 2003 18:43:37 -0700, Herb Burnswell wrote:

> Hi All,
> 
> I am a beginner with perl and would greatly appreciate some assistance.  I
> want to compare two log files and if they are significantly different in
> size, send myself an email.  I would like to do something similar to:
> 
>  #!/usr/bin/perl
> 
> $file1 = "logfile1";
> $file2 = "logfile2";
> 
> $size1 = `wc -l $file1 | awk '{print \$1}'`; $size2 = `wc -l $file2 | awk
> '{print \$1}'`; $diff  = "($size1 - $size2)";

perldoc -f stat


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

Date: Tue, 22 Apr 2003 03:22:54 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: compare two files
Message-Id: <3EA4B56B.3090003@rochester.rr.com>

Herb Burnswell wrote:

 ...
> assistance.  I want to compare two log files and if they are
> significantly different in size, send myself an email.  I would like
> to do something similar to:
> 
>  #!/usr/bin/perl
> 
> $file1 = "logfile1";
> $file2 = "logfile2";
> 
> $size1 = `wc -l $file1 | awk '{print \$1}'`;
> $size2 = `wc -l $file2 | awk '{print \$1}'`;
> $diff  = "($size1 - $size2)";

Here you want to lose the quotes.  They will result in a string like:

(23-24)

as the value of $diff, which isn't what you want.


> 
> if ( "$diff" +- 300 ) {


That won't fly syntax-wise.  You want something like:

   if ( abs($diff)>300 ) {


> 
>       $commandline = "mailx -s "my subject" me@me.com < warningfile";


On the above line you need to watch your quoting.  Maybe something like:

   $commandline = "mailx -s \"my subject\" me\@me.com < warningfile";


>        system ( $commandline );
> 
> }
> 
> exit;
> 
> As you can see, I don't know the proper syntax but that is the idea of
> what I need.  I really don't know the best way of going about this
> either.  Is there an easier way than to use 'wc -l'?  I can't really


Using wc is probably a reasonable solution if you really want to know if 
the number of text lines in the files differs significantly.  If you 
could be happy with the number of bytes of file size difference, 
something like:

     if(abs((-s $file1)- -s $file2)>300) {

might be easier than wc and awk.


> use diff because the files will have different info.  Thank you very
> much in advance for any information or links to information provided.
> 
> Herb
> 

-- 
Bob Walton



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

Date: Mon, 21 Apr 2003 18:49:14 -0400
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: Copying files efficiently
Message-Id: <Az_oa.21595$sU1.289804@weber.videotron.net>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Felix wrote:
> Hello all.  I'm currently writing my first real Perl program, which
> will automatically back up folders that change frequently and need to
> be backed up regularly.  I compared my copying code with Ctrl-C and
> Ctrl-V in Windows.  In one case, my program took approx 1min, 50secs
> to copy a folder, while Windows took 1min, 15secs.  Can I make my
> program faster here?  Here is the code:
> 
> for (@source) {
>     
>   open IN, "$source/$_" or die $!;
>   open OUT, "> $target/$_" or die $!;
>   binmode IN; binmode OUT;
>   print "Currently copying $_\n";
>   while (<IN>) {
> 
>     print OUT $_;
>      
>   }
> 
> }
> 
> @source is an array of file names to be copied, $source is the source
> folder, $target the target folder.  I tried reading the entire file at
> once, and then writing, but this used much too much memory, and was
> not much faster, at all.  Any help would be appreciated.

The <> operator is fairly expensive compared to raw data reads/writes 
since it forces perl to inspect the data, look for line-feeds, shuffle 
the file-position pointer etc..

Since you're not really doing any per-line manipulations of the data, 
look into using sysread and syswrite instead.

Also, if this is the bulk of your program, you're definately not using 
any "cool/clever"ness provided by perl.  You might want to consider 
re-writing it in C to gain a bit of speed.

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+pHVteS99pGMif6wRAmirAJ4l9yA/ugjrhr+g+EIVObZmW6GvmACZAZaa
lqX2bFzCAVWs8cEfh5yjEMg=
=DyjA
-----END PGP SIGNATURE-----



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

Date: 21 Apr 2003 21:04:17 -0700
From: skinnychineseguy@hotmail.com (Skinny Guy)
Subject: Re: Extract data from 3 lines, combine into 1 line Help!
Message-Id: <f9b5a61d.0304212004.54bccb35@posting.google.com>

Dang, what did you just do? I can't understand it, but it works. What
the heck is that ... perl -00l012ne

Can you adjust it so that 

(1) instead of the GET1, GET2, GET3, its ALPHA, BETA, CHARLIE.  

(2) the fields-to-extract are n fields to the right of the (ALPHA or
BETA or CHARLIE) where

ALPHA: target field is 2 fields to the right
BETA: target field is 18 fields to the right
CHARLIE: target field is 8 fields to the right

(3) the fields to extract are numeric but sometimes broken up by
spaces or a carriage return (once you find the number, you have to
keeping joining until you reach a non-numeric, non-white-or-CR-space
character).

If you can do this, I'll really be floored. I'm writing a Java program
to try to do it now. Unless I spend a lot of time with perl its really
hard to know how to make it work magic.

"John W. Krahn" <krahnj@acm.org> wrote in message news:<3EA46A0B.7DEC20FA@acm.org>...
> Skinny Guy wrote:
> > 
> > I need to extract all the 'AAAAA' fields from the lines starting with
> > GET1, GET2, and GET3 and output it in a file that has the 3 fields on
> > every single line as in AAAAA AAAAA AAAAA. Each paragraph repeats lots
> > of times in the source file. The AAAAA's are always in the same field
> > position after each GET1,GET2,GET3 deliminated by |'s.  Any help
> > please?
> > 
> > NOGET| |field3|pd
> > |11|222     GET1|PPP|AAAAA
> > GET2||field3|AAAAA
> > NOGET
> > continuationNotNewLineFromAbove
> > |||dddddd
> > GET3|field2|AAAAA
> > 
> > NOGET| |field3|pd
> > |11|222    GET1|PPP|AAAAA    GET2||field3|AAAAA
> > NOGET
> > continuationNotNewLineFromAbove
> > |||dddddd
> > GET3|field2|AAAAA
> 
> 
> perl -00l012ne'$,=$";print/(?:GET[13]|GET2\|[^|]*)\|[^|]*\|(\w+)/g' yourfile
> 
> 
> John


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

Date: Tue, 22 Apr 2003 02:56:44 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: fake flocking on win32
Message-Id: <3EA4AF49.50901@rochester.rr.com>

dan baker wrote:

 ...
> win32 environment as on the eventual *nix server. The big problem is
> that there is no flock on win32, and I am a little confused by what


Where do you get the idea there is no flock on Win32 systems?  It works 
fine on NT, and probably also on 2000 etc (although I can't personally 
vouch for anything other than NT).  True, it doesn't work on 95 or 98, 
at least not with the AS port (don't know about other ports, but I would 
bet not).  The fix is to change to NT or subsequent.

Your "fake" procedure will sooner or later fail due to non-atomic 
operations.  Consider, for example, if several processes are competing 
for your file lock.  One of them does the -f (did you perhaps mean -e?), 
finds your lock file doesn't exist.  Then a second process does its -f, 
before the first process does its open, also finding the lock file 
doesn't exist.  Then the first process opens the lock file, establishing 
its lock, and proceeds to muck with your tied file.  Then the second 
process does likewise, and you're in the crap.  You're SOL on 
95/98/98SE.  If you want to do proper multitasking, you need NT and 
subsequent.  Or a real OS.


 ...


-- 
Bob Walton



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

Date: Tue, 22 Apr 2003 02:39:44 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Help: ? $next_one == ${next_one}
Message-Id: <3EA4AB4D.1070908@rochester.rr.com>

yj wrote:

 ...


> In a code:
>   my $next_one;# a scalar variable declared
>  ......
>  ${next_one}=1; #but ${next_one} is used instead of $next_one, I am
> confused here
> 
> Are  $next_one and ${next_one} are the same scalar virable. if so why
> put  next_one between { and}.
> 
> 

$next_one and ${next_one} are indeed the same thing.  One purpose to use 
${next_one} might be obfuscation.  Another would be if you were trying 
to interpolate the variable in a string where the variable name is 
followed by an alphanumeric character, like "abc${next_one}def" for 
example.  That is mostly why the construct is available in Perl -- if it 
weren't, there would be no way to interpolate a variable name followed 
immediately by an alphanumeric character, as the compiler would have no 
way of knowing where the variable name is supposed to stop and the 
literal text start.

-- 
Bob Walton



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

Date: 21 Apr 2003 16:50:16 -0700
From: thomas@shurflo.com (Thomas B)
Subject: Re: How can I hide a specific Window
Message-Id: <866f534e.0304211550.3bb6e960@posting.google.com>

I actually want to launch a separate process and hide it.

thomas@shurflo.com (Thomas B) wrote in message news:<866f534e.0304211028.40895fae@posting.google.com>...
> I have the code to do it, but I don't know how to find the Windows
> Handle.
> 
> I'm currently using:
> 
> 
> $FindWindow = new Win32::API( "msinfo32.exe", "FindWindow", [ P, P ],
> L );
> 
> 
> 
> I've also tried using its title:
> 
> $FindWindow = new Win32::API( "System Information", "FindWindow", [ P,
> P ], L );
> 
> 
> 
> This is just an example.  I actually want to hide a Perl Script that
> does background virus update checking.  I know how to hide the current
> running Perl Script - I need to find out how to hide a separate
> application.


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

Date: Tue, 22 Apr 2003 11:37:26 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: How can I hide a specific Window
Message-Id: <3ea49dd3$0$12447@echo-01.iinet.net.au>


"Thomas B" <thomas@shurflo.com> wrote in message
news:866f534e.0304211550.3bb6e960@posting.google.com...
> I actually want to launch a separate process and hide it.
>

You'll want to 'use Win32::Process;'.
The module is part of libwin32, and you probably already have it.

Cheers,
Rob




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

Date: Tue, 22 Apr 2003 00:57:56 GMT
From: phil+s3@bolthole.no-bots.com (Philip Brown)
Subject: Re: korn shell or perl
Message-Id: <slrnba9521.c0q.phil+s3@bolthole.com>

On Mon, 21 Apr 2003 20:58:31 GMT, ian@WINDOZEdigiserv.net wrote:
>Great Eric, and much appreciated.
>
>My primary scripting language is PHP and I use Perl mainly for system
>scripting [....]

Why not use php?  there is an installable /usr/local/bin/php for
just this purpose :-)

(or if you would like a prepackaged binary, /opt/csw/bin/php,
  grab mod_php from blastwave.org ;-)



-- 
  http://www.blastwave.org/ for solaris pre-packaged binaries with pkg-get
    Organized by the author of pkg-get
[Trim the no-bots from my address to reply to me by email!]
         S.1618 http://thomas.loc.gov/cgi-bin/bdquery/z?d105:SN01618:@@@D
                            http://www.spamlaws.com/state/ca1.html


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

Date: 21 Apr 2003 17:51:42 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: network install, access via registry mod, win env
Message-Id: <1bff1830.0304211651.1f8ec9a8@posting.google.com>

> Can you install perl on the network and access all it functionality
> by simply updating local registries?
> 

It's not the registries that make it difficult.  Perl has a
configuration file Config.pm, which contains absolute paths to various
things (some of which influences @INC).  You will have to make sure
they are mapping the remote share to the same drive that is used in
Config.pm. (perhaps you could change the entries to UNC file names  - 
I seem to remember trying this, but finding that there were
difficulties though).

Regarding registry entries, you might change some so that a .pl file
is automatically run under perl when the file is double-clicked
though.  You might also want the perl executable directory to be in
the users PATH.

> If can, what registry entries?  
> 
> nt - 2000 - win98
> perl - activeware 5.6.1
> 
> thanks


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

Date: Tue, 22 Apr 2003 01:03:35 +0000 (UTC)
From: Pierre Asselin <pa@panix.com>
Subject: Re: Perl source install over redhat rpm
Message-Id: <b824d7$6uq$2@reader1.panix.com>

Eddy <eddy@nospamaxa.it> wrote:
> On my RH 6.2 I have tryed to upgrade Perl to 5.8 with source version

> It seems that the lib directories have mixed together  with the old rpm
> version from redhat:
> [ . . . ]
> perl -V says:
> @INC:
>     /usr/local/lib/perl5/5.8.0/i686-linux
>     /usr/local/lib/perl5/5.8.0
>     /usr/local/lib/perl5/site_perl/5.8.0/i686-linux
>     /usr/local/lib/perl5/site_perl/5.8.0
>     /usr/local/lib/perl5/site_perl

That looks perfectly normal.  The new perl in /usr/local/bin uses
only /usr/local/lib/perl5.  Try the old one with "/usr/bin/perl -V",
and make sure it only looks under /usr/lib/perl5.

What stopped working exactly?



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

Date: 21 Apr 2003 16:56:53 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: print out multi queries
Message-Id: <1bff1830.0304211556.32198a46@posting.google.com>

Benjamin Goldberg <goldbb2@earthlink.net> wrote in message news:<3E851991.471DB10A@earthlink.net>...
> Jeff D Gleixner wrote:
> > 
> > Mario542 wrote:
> > > Does anyone know how to get a script to print two select queries at
> > > the same time? It prints the first select but not the second. Maybe
> > > this cann't be done.
> > 
> > You need 2 separate queries.
> 
> True.


Not completely true. (depends if you consider this one or two queries)

select 'systables' as tname, count(*) as tcount from systables
union
select 'syscolumns' as tname, count(*) as tcount from syscolumns

You can pass this to $dbh->prepare as one query.  

I don't know how well union is supported across various databases,
I'm using Infomix.


> 
> > Also, no need for the prepare if
> > you're not using placeholders.
> 
> False -- the 'do' method does not return SELECT results.
> 
> (Yes, one could use one of the two 'selectall_<type>ref' methods, but if
> the query result is huge, they would be innefficient, both in time and
> memory.  Plus, these didn't exist in older versions of DBI, whereas
> prepare/execute have been around forever.)


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

Date: Tue, 22 Apr 2003 03:17:09 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: print out multi queries
Message-Id: <Vu2pa.13332$yO5.7065@nwrddc02.gnilink.net>

Mario542 wrote:
> How does one run two queries in one script?

What "query" are you talking about?
Perl does not have "queries" per se.....

jue




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

Date: 21 Apr 2003 16:45:08 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Returning Values from a Perl Thread
Message-Id: <1bff1830.0304211545.6bfc59d7@posting.google.com>

> 
> > Trying to return data from a perl thread. Can anyone tell me whats
> > wrong with the following code? The output is '4'. It seems like the
> > return array is being treated in a scalar context. This code matches
> > exactly (as best I can tell) the simple example in the perlthrtut
> > docs.
> > 
> > Thanks, Douglas.
> > 
> > 
> > #!/usr/local/bin/perl
> > 
> > use strict;
> > use threads;
> > 
> > sub go {
> >    my @d;
> >    push (@d,"A");
> >    push (@d,"B");
> >    push (@d,"C");
> >    push (@d,"D");
> >    return @d;
> > }
> > 
> > sub main {
> >    my (@data);
> >    my $t;
> >    $t = threads->new(\&go);
> >    @data = $t->join;
> >    print @data;
> > 
> > }
> > 
> > main();
> > 
> 
> 
> 
> return is sensitive to context (see perldoc -f return).
> 
> Note the difference in results:
> 
> #! /bin/perl
> use strict;
> use warnings;
> use threads;
> 
> sub go {
>     my @d = qw(A B C D);
>     print wantarray? "ARRAY\n" : "OTHER\n";
>     return @d;
> }
> 
> my @data;
> my ($t) = threads->new("go");
> @data = $t->join;
> print "@data\n";
> 
> my $t2 = threads->new("go");
> @data = $t2->join;
> print "@data\n";

That is just strange. The return context is set when the thread is
created, but the return value is extracted in an entirely different
section of code.  I think the context should be set where the thread
is joined, however that is probably near impossible to implement.

The way I see it, only scalars should be returned from a thread which
you would only use to report success or error.  Data should be
trasferred through a shared variable.

(just my opinion though)

use strict;
use warnings;
use threads;
use threads::shared;

sub go {
    my $data = shift;
    @{$data} = qw{A B C D};
}

my $data = &share([]);
my $t = threads->new("go", $data);
$t->join;
print @$data, "\n";


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

Date: Mon, 21 Apr 2003 17:22:00 -0700
From: Bob Greenwood <spokester@REMOVE-MEcox.net>
Subject: Re: Returning Values from a Perl Thread
Message-Id: <FW%oa.9744$zn5.4212@fed1read03>

Bryan Castillo wrote:
>>>Trying to return data from a perl thread. Can anyone tell me whats
>>>wrong with the following code? The output is '4'. It seems like the
>>>return array is being treated in a scalar context. This code matches
>>>exactly (as best I can tell) the simple example in the perlthrtut
>>>docs.
>>>
>>>Thanks, Douglas.
>>>
>>>
>>>#!/usr/local/bin/perl
>>>
>>>use strict;
>>>use threads;
>>>
>>>sub go {
>>>   my @d;
>>>   push (@d,"A");
>>>   push (@d,"B");
>>>   push (@d,"C");
>>>   push (@d,"D");
>>>   return @d;
>>>}
>>>
>>>sub main {
>>>   my (@data);
>>>   my $t;
>>>   $t = threads->new(\&go);
>>>   @data = $t->join;
>>>   print @data;
>>>
>>>}
>>>
>>>main();
>>>
>>
>>
>>
>>return is sensitive to context (see perldoc -f return).
>>
>>Note the difference in results:
>>
>>#! /bin/perl
>>use strict;
>>use warnings;
>>use threads;
>>
>>sub go {
>>    my @d = qw(A B C D);
>>    print wantarray? "ARRAY\n" : "OTHER\n";
>>    return @d;
>>}
>>
>>my @data;
>>my ($t) = threads->new("go");
>>@data = $t->join;
>>print "@data\n";
>>
>>my $t2 = threads->new("go");
>>@data = $t2->join;
>>print "@data\n";
> 
> 
> That is just strange. The return context is set when the thread is
> created, but the return value is extracted in an entirely different
> section of code.  I think the context should be set where the thread
> is joined, however that is probably near impossible to implement.
> 
> The way I see it, only scalars should be returned from a thread which
> you would only use to report success or error.  Data should be
> trasferred through a shared variable.
> 
> (just my opinion though)
> 
> use strict;
> use warnings;
> use threads;
> use threads::shared;
> 
> sub go {
>     my $data = shift;
>     @{$data} = qw{A B C D};
> }
> 
> my $data = &share([]);
> my $t = threads->new("go", $data);
> $t->join;
> print @$data, "\n";


In your sub go() return the array as a reference, \@d. You can assign 
the return to a scalar in the calling routine. Just have to be sure to
dereference it when you use it there. ;) Good Luck.
-- 
Bob Greenwood
IM: spokester@jabber.org
"Some days insanity is the only option."
-- 



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

Date: Tue, 22 Apr 2003 11:20:54 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: Trying to get a list of Currently running Windows Apps - How
Message-Id: <3ea499f6$0$12448@echo-01.iinet.net.au>


"Thomas B" <thomas@shurflo.com> wrote in message
news:866f534e.0304211025.e79bf13@posting.google.com...
> How can I get a list of Currently running windows applications? I want
> to list all of the currently running Windows applications running on
> Windows NT/2000.

Jutta Klebe's Win32::PerfLib should provide you with what you want. The
module is part of the libwin32 package, and you probably already have it.

Check out the sample scripts at
http://www.bybyte.de/jmk/docs/Perl5/PerfLib/PerfLib_sample.html
, especially 'process.pl'.

Cheers,
Rob




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

Date: 21 Apr 2003 17:40:25 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Using Rijndael encryption on socket connection between Windows and Unix...
Message-Id: <1bff1830.0304211640.79bc67ad@posting.google.com>

rook_5150@yahoo.com (Bryan Castillo) wrote in message news:<1bff1830.0304211237.5e4ceab@posting.google.com>...
> > I'm using Rijndeal encryption to secure the data that I want to send over a
> > socket connection. When I send some text over the socket from a Windows
> > client to a OpenBSD server the decryption will not work :(  From a OpenBSD
> > to an OpenBSD machine or from a Windows to a Windows machine is does work!
> 
> Have you though about just using SSL?  (Perhaps this isn't easy to
> install on Windows though - never tried it)
> 
> [snip]
> > 
> > ----- Output client.pl -------
> > Plaintext: Testing123
> > Encrypted: E8?f?c¶?úÉb?°.??
> > ----- Output client.pl -------
> > 
> > ----- Output server.pl -------
> > Encrypted: E8ðfõc£b±ø.Ñ
> > Decrypted: Uåì@6ingj³ð
> > ----- Output server.pl -------
> 
> Did you notice that your encrypted values were different?  This
> should tell you that something is quite wrong.  Looking at your code I
> see that
> you are using <> and print to send the data via sockets.  Don't do
> this.  Use sysread and syswrite.  (Unless you use binmode ":raw").
> 
> > 

It looks like I was having a dyslexic moment.

use syswrite here
> >  print $sock "$crypted"; # use sysread
> 
> 


use sysread here
> >  while (defined ($buf = <$new_sock>)) # use syswrite


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

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.  

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


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