[22651] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4872 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 21 18:06:03 2003

Date: Mon, 21 Apr 2003 15:05:09 -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: 4872

Today's topics:
    Re: Addition in substitution (Kai Henningsen)
    Re: Beginners question - directions please... (Mark Grimes)
    Re: Environment Varibles (Kai Henningsen)
        Extract data from 3 lines, combine into 1 line Help! (Skinny Guy)
    Re: Extract data from 3 lines, combine into 1 line Help <krahnj@acm.org>
        fake flocking on win32 (dan baker)
    Re: grep in array <tzz@lifelogs.com>
        Help: ? $next_one == ${next_one} <yjin6666@hotmail.com>
        How can I hide a specific Window (Thomas B)
        korn shell or perl (NNTP)
    Re: korn shell or perl <ian@WINDOZEdigiserv.net>
    Re: korn shell or perl <vilain@spamcop.net>
    Re: korn shell or perl <ccox_nopenotthis@airmail.net>
    Re: korn shell or perl <emschwar@pobox.com>
    Re: korn shell or perl <ian@WINDOZEdigiserv.net>
        network install, access via registry mod, win env (hfs2)
    Re: perl/tk and fork command on windows (Bryan Castillo)
    Re: print out multi queries <tony_curtis32@yahoo.com>
    Re: Q. Does ActivePerl for Windows require Apache to be (Jim Jones)
    Re: Q. Does ActivePerl for Windows require Apache to be <nospam@raytheon.com>
    Re: regexp match problem <abigail@abigail.nl>
    Re: Remembering previous values of the form. (Bryan Castillo)
    Re: Trouble with LWP <kasp@epatra.com>
    Re: Trouble with LWP <mbudash@sonic.net>
        Trying to get a list of Currently running Windows Apps  (Thomas B)
    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 20:10:00 +0200
From: kaih=8kHr7gGXw-B@khms.westfalen.de (Kai Henningsen)
Subject: Re: Addition in substitution
Message-Id: <8kHr7gGXw-B@khms.westfalen.de>

tadmc@augustmail.com (Tad McClellan)  wrote on 05.04.03 in <slrnb8unfo.6ca.tadmc@magna.augustmail.com>:

> Blakis <brflaming@yahoo.com> wrote:
> > I'm trying to update the version number in a bunch of Java files using
> > Perl. The Java files all have a line similar to the following:
> >
> >  * @version 1.0.4
> >
> > I want my Perl script to increment the last number by one. Here's the
> > substitution I'm using:
> >
> > $lines =~ s/( \* \@version \d\.\d\.)(\d).*/$1$2++/);
>                                                     ^
>                                                     ^
> Where is the open paren to match that closing paren?
>
>
>     Do not re-type Perl code
>         Use copy/paste or your editor's "import" function rather than
>         attempting to type in your code. If you make a typo you will get
>         followups about your typos instead of about the question you are
>         trying to get answered.
>
>
> > How can I make it so that the ++ in the substitution actually
> > increments the integer instead of tacking it on to the end of the
> > string?
>
> use the s///e modifier:
>
>    s/( \* \@version \d\.\d\.)(\d).*/$1 . ($2+1)/e;

It's rather likely that what the OP *really* wants is to use

    s/( \* \@version \d+\.\d+\.)(\d+).*/$1 . ($2+1)/e;

or he'll be surprised in a short while.

Kai
-- 
http://www.westfalen.de/private/khms/
"... by God I *KNOW* what this network is for, and you can't have it."
  - Russ Allbery (rra@stanford.edu)


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

Date: 21 Apr 2003 11:29:53 -0700
From: mvg_yho@yahoo.com (Mark Grimes)
Subject: Re: Beginners question - directions please...
Message-Id: <79937b32.0304211029.342ccfd9@posting.google.com>

Tony,

While I fully agree with William that a different file format may make
this problem significantly simpler, I also realize that there are
times when you can't do anything about the format of the file you are
parsing and just need a solution. The following code should do the
trick with the help of one fairly complicated regex...

#!/usr/bin/perl

use strict;
use warnings;

my @entries;

undef $/; # slurp entire file, make sure the file isn't so
          # big it takes up all your RAM
my $file = <>;
$file =~ s!\s*(\#.*)?$!!mg;    # Remove any comments and whitespace

while( $file =~ s/
          (MON|TUE|WED|THU|FRI|SAT|SUN)\n    # The day
          (\d+)\n                            # The device
          ((\d{1,2}:\d{1,2}\n)+)            # The times
          ((.+[ \t]+\d+\n)+)                # The files
        //mx )
{

  my ($day, $dev, $t, $f) = ( $1, $2, $3, $5 );

  # Re-format each file
  $f =~ s/\n/, /mg;

  # print "($day; $dev; $t; $f)\n";

  # Parse each time
  while( $t =~ s/
            (\d{1,2}:\d{1,2})\n              # Each time
          //mx )
  {
    # print "$day $dev $1 ($f)\n";
    my @tmp = ($day, $dev, $1, "($f)");
    push @entries, \@tmp;
  }
}

foreach my $e (@entries){
  print join(', ', @$e), "\n";
}

"Tony" <no_spam@no.spam.org.invalid> wrote in message news:<pan.2003.04.21.00.14.08.546063@no.spam.org.invalid>...
> Hi Guys,
> 
> Got a special little project.  I have a specific config file in the format
> listed at the  end of this post.
> 
> I am looking for some pointers to how the following can be acheived:
> 
> I need to read the file into a perl program and process it.
> 
> The idea is that the perl program will be started, read in the file
> and on the specified week day, at the specified time, start sending the
> listed files to an output device, one after the other.  Each file name
> is followed by a single digit which denotes the number of times
> the file is processed by the output device (Controlled by an
> external program) with 1 being = once, 2-9 being = 2 - 9 times
> and 0 being infinite (10000 times).
> 
> The processing of the files is done by the external program and
> perl does not need to deal with the multiple play times specified
> after each file name (The external program does this and gives an
> exit code when done).
> I could set the file to play once always and let perl do the repeats
> as needed.
> 
> When the last file on a given start time is playing multiple times
> (Looping),  the next time (On the same output device) should result
> in the looping being aborted and a new set of files being played etc.
> 
> I have done some work like getting the day of the week from
> the RTC and ensuring that it is in large caps.  I also know how to
> get the files sent to the external program with the appropriate switches
> to be able to process the files.
> 
> My biggest perolem is that I do not know how to get from the
> given file format to an array with a suitable format that can be
> run, something like:
> 
> MON 0 02:00 (/some/path/file.name_1 1, /some/path/file.name_2 1, etc)
> MON 1 12:00 (/some/path/file.name1 1, /some/path/file.name_2 1, etc)
> TUE 0 15:00 (/some/path/file.name1 1, /some/path/file.name_2 1, etc)
> 
> Maybe this is the wrong approach....
> 
> It may be better to scan the entire file in a loop matching against the
> day of the week, then picking up the output device number, then matching
> the play time and finally grabbing the files that follow - I don't know.
> 
> Any suggestions.
> 
> Please note that I am new to all this but have read a lot on perl,
> various tutorials and FAQ's...(Have I started something to big...?)
> 
> Best regards
> 
> Tony
> 
> Begin file format.
> ======================
> MON       # The day of the week to take action...
> 0         # The output device to use...0 in this case
> 02:00     # The time to process the listed files     
> 12:00     # The next time to process the listed files
> [...more times, one per line...]     # There may be up to 24 times
> /some/path/file.name_1 1     # The first file to send to device 0,
> /some/path/file.name_2 2     # The second file to device 0
> /some/path/file.name_3 0     # The 3rd file to device 0
> [...more files, there may be up to 10 or so...]
> MON     # The day of the week to take action...
> 1        # The output device to use...1 in this case
> 05:00
> 16:00
> [...several times, one per line...]
> /some/path/other_file_1.name 1
> /some/path/_other_file_2.name 2
> /some/path/other_file_3.name 0
> TUE
> 0
> 02:00
> 12:00
> [...several times, one per line...]
> /some/path/new_file_1.name 1
> /some/path/new_file_2.name 2
> /some/path/new_file_3.name 0
> WED
> 0
> 13:00
> [...continues like this for the whole week...]


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

Date: 21 Apr 2003 22:06:00 +0200
From: kaih=8kHr7yKmw-B@khms.westfalen.de (Kai Henningsen)
Subject: Re: Environment Varibles
Message-Id: <8kHr7yKmw-B@khms.westfalen.de>

News@LearnQuick.Com (Herb Martin)  wrote on 20.04.03 in <RSqoa.108135$vI3.4393846@twister.austin.rr.com>:

> In Windows (where it sounded like he might be working)
> there is a program called setx.exe (Resource Kit.)
>
> One can also do it by modifying the registry.  Win32 Perl
> has modules for registry access.

None of this is relevant to the question.

> > > I am guessing this is basically a OS specific thing, right?
> > No.
>
> Sometimes.

No.


Kai
-- 
http://www.westfalen.de/private/khms/
"... by God I *KNOW* what this network is for, and you can't have it."
  - Russ Allbery (rra@stanford.edu)


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

Date: 21 Apr 2003 14:16:35 -0700
From: skinnychineseguy@hotmail.com (Skinny Guy)
Subject: Extract data from 3 lines, combine into 1 line Help!
Message-Id: <f9b5a61d.0304211316.3ed6a1a5@posting.google.com>

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

 ...
 ...
 ...


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

Date: Mon, 21 Apr 2003 22:00:55 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Extract data from 3 lines, combine into 1 line Help!
Message-Id: <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
-- 
use Perl;
program
fulfillment


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

Date: 21 Apr 2003 13:47:13 -0700
From: botfood@yahoo.com (dan baker)
Subject: fake flocking on win32
Message-Id: <13685ef8.0304211247.2092baac@posting.google.com>

hi folks.... I'm working on a little web-driven application that will
use tie()ed hashes for a simple database. So far it looks like a plain
tie using DB_File maybe with the MLDBM on top will be just perfect.

EXCEPT, I would really like to to work the "same" on my development
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
I've read so far with regard to flocking tie()ed hashes anyway.

SO, I am thinking that I would "fake" flock functionality
simplistically by open()ing a temp "lock" file . a call from another
process would find the lock file already exists, and keep trying (with
some timeout parameter) until it is close()ed and unlink()ed from the
first process.

pseudocode might be something like:

CHECKLOCK:
# ( -f lockfile.txt ) {
    # unless we should timeout and die, sleep 1
    # check again to see if its been unlinked
} else {
    # OPEN a lockfile
}

# application .....
use MLDBM qw(DB_File Storable);
use Fcntl;
my %car=();
tie (%car, "MLDBM", "car_data",
      O_CREAT|O_RDWR, 0666, $DB_File::DB_BTREE) || or die..... 
 ...etc...
untie %car;
#

# CLOSE lockfile.txt 
# unlink lockfile.txt 
# exit;

Is there any huge conceptual problem with this?


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

Date: Mon, 21 Apr 2003 15:38:59 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: grep in array
Message-Id: <4nhe8rmyi4.fsf@lockgroove.bwh.harvard.edu>

On Sun, 20 Apr 2003, mr@sandman.net wrote:
> In article <4nof361n53.fsf@lockgroove.bwh.harvard.edu>,
>  Ted Zlatanov <tzz@lifelogs.com> wrote:
> 
>> 1) $& and such special variables are usually unnecessary,
>>    especially for tasks as simple as yours.  Your code is badly
>>    written, that's why you're having trouble.
> 
> So tell me how I set a variable to the full string I found a match
> in, please.

You could find matches in several full strings in your example, so
your question is misleading.  Use the return value of grep() - it
returns the list of matched strings (just like the grep utility will
return a list of matched lines).  But please, don't invoke
keys(%people) on every loop iteration, it's inefficient since we don't
expect %people to be modified by the loop.  Look at the example I
posted earlier.

Ted


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

Date: Mon, 21 Apr 2003 16:14:43 -0500
From: yj <yjin6666@hotmail.com>
Subject: Help: ? $next_one == ${next_one}
Message-Id: <3EA45F43.6994D20@hotmail.com>

Hi,

Could someone help me out the following question. Thanks lots.

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}.



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

Date: 21 Apr 2003 11:28:19 -0700
From: thomas@shurflo.com (Thomas B)
Subject: How can I hide a specific Window
Message-Id: <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: 21 Apr 2003 12:39:09 -0700
From: news8080@yahoo.com (NNTP)
Subject: korn shell or perl
Message-Id: <110fc16.0304211139.2d1e34cc@posting.google.com>

I need to extract whatever string apper after the word 'src: ' from a
text file containing 50,000 lines approx. (for firewall log analysis
if you've not fig. that out yet)

so far I've been experimenting with cut -d and that is no good for
this kinda things
any ideas, here is an example line

21Apr2003 15:16:20 accept 127.0.0.1  >    mail product: SmartDefense;
dst: xxx.xxx.xx.xx; attack: Port Scanning; src: xxx.xx.xx.xx;

This is all one line.


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

Date: Mon, 21 Apr 2003 19:59:46 GMT
From: "Ian.H [dS]" <ian@WINDOZEdigiserv.net>
Subject: Re: korn shell or perl
Message-Id: <toi8avkvraf709er49q5omplmhgmihgrta@4ax.com>
Keywords: Remove WINDOZE to reply

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

In a fit of excitement on 21 Apr 2003 12:39:09 -0700,
news8080@yahoo.com (NNTP) managed to scribble:

> I need to extract whatever string apper after the word 'src: ' from
> a text file containing 50,000 lines approx. (for firewall log
> analysis if you've not fig. that out yet)
> 
> so far I've been experimenting with cut -d and that is no good for
> this kinda things
> any ideas, here is an example line
> 
> 21Apr2003 15:16:20 accept 127.0.0.1  >    mail product:
> SmartDefense; dst: xxx.xxx.xx.xx; attack: Port Scanning; src:
> xxx.xx.xx.xx;
> 
> This is all one line.


#!d:\perl\bin\perl
use strict;
use warnings;

my $logfile = 'testfile.txt';
my @addys;

open(LOG, "<$logfile");
  while (<LOG>) {
    chomp;
    my @stuff = split(/ src\: /, $_);
    push @addys, $stuff[1] =~ /(.*?)\;/;
  }
close(LOG);

foreach(@addys) {
  print "$_\n";
}




In testfile.txt, I used:


1Apr2003 15:16:20 accept 127.0.0.1  >    mail product: SmartDefense;
dst: xxx.xx.xx.xx; attack: Port Scanning; src: 123.123.123.123;

1Apr2003 15:16:20 accept 127.0.0.1  >    mail product: SmartDefense;
dst: xxx.xx.xx.xx; attack: Port Scanning; src: 234.234.234.234;

(singular lines as defined by you).


I receive:


[d:\home\tk]$ sec.pl
123.123.123.123
234.234.234.234


HTH.



Regards,

  Ian

-----BEGIN xxx SIGNATURE-----
Version: PGP 8.0

iQA/AwUBPqRNbWfqtj251CDhEQIjYwCfSrdhkKaUQYzeZcEPrq/x+qx61vQAn2Lr
dTThkVhuBnSXu0qwZgdQJhe2
=3s02
-----END PGP SIGNATURE-----

-- 
Ian.H  [Design & Development]
digiServ Network - Web solutions
www.digiserv.net  |  irc.digiserv.net  |  forum.digiserv.net
Scripting, Web design, development & hosting.


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

Date: Mon, 21 Apr 2003 13:12:10 -0700
From: "Michael Vilain <vilain@spamcop.net>"
Subject: Re: korn shell or perl
Message-Id: <news-CEA0BE.13121021042003@news.tdl.com>

In article <110fc16.0304211139.2d1e34cc@posting.google.com>,
 news8080@yahoo.com (NNTP) wrote:

> I need to extract whatever string apper after the word 'src: ' from a
> text file containing 50,000 lines approx. (for firewall log analysis
> if you've not fig. that out yet)
> 
> so far I've been experimenting with cut -d and that is no good for
> this kinda things
> any ideas, here is an example line
> 
> 21Apr2003 15:16:20 accept 127.0.0.1  >    mail product: SmartDefense;
> dst: xxx.xxx.xx.xx; attack: Port Scanning; src: xxx.xx.xx.xx;
> 
> This is all one line.

what's wrong with grep piped through awk?  Regardless of the shell I was 
using, those would be the tools I'd use unless I had perl.  If all the 
lines that contain "src:" are formatted the same, then you can extract 
that column with awk.

-- 
DeeDee, don't press that button!  DeeDee!  NO!  Dee...





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

Date: Mon, 21 Apr 2003 15:33:49 -0500
From: Chris Cox <ccox_nopenotthis@airmail.net>
Subject: Re: korn shell or perl
Message-Id: <7CD9439C75C2240A.22F4FFCD8AC2264A.3450900FC3FD8BC3@lp.airnews.net>

Ian.H [dS] wrote:
 ...
>>I need to extract whatever string apper after the word 'src: ' from
>>a text file containing 50,000 lines approx. (for firewall log
>>analysis if you've not fig. that out yet)
>>
>>so far I've been experimenting with cut -d and that is no good for
>>this kinda things
>>any ideas, here is an example line
>>
>>21Apr2003 15:16:20 accept 127.0.0.1  >    mail product:
>>SmartDefense; dst: xxx.xxx.xx.xx; attack: Port Scanning; src:
>>xxx.xx.xx.xx;
>>
>>This is all one line.

:-)

 ...world's largest simple perl script snipped...

How about sed:

sed -n 's/.*src: \(.*\)/\1/p'




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

Date: 21 Apr 2003 14:34:51 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: korn shell or perl
Message-Id: <etohe8rtwr8.fsf@wormtongue.emschwar>

"Ian.H [dS]" <ian@WINDOZEdigiserv.net> writes:
> #!d:\perl\bin\perl
> use strict;
> use warnings;

Both good.  Yaay for using them.

> my $logfile = 'testfile.txt';
> my @addys;
> 
> open(LOG, "<$logfile");
>   while (<LOG>) {
>     chomp;
>     my @stuff = split(/ src\: /, $_);
>     push @addys, $stuff[1] =~ /(.*?)\;/;
>   }
> close(LOG);
> 
> foreach(@addys) {
>   print "$_\n";
> }

Ouch.  Two iterations over the same data?  Why not do the print
in the first place?  Why bother with a chomp() if you're just going to
extract the data you want with an RE anyway?  Why split() and then use
an RE?  Why not just use the RE in the first place?

$ perl -ne 'print "$1\n" if /src:(.*);/' < /tmp/testfile.txt
 123.123.123.123
 234.234.234.234

(same data)

I suppose if you wanted to keep @addys around for other processing,
you could do:

while(<LOG>) {
  push @src_addrs, $1 if /src:(.*);/;
}

Note intentionally greedy regex; if you want to be minimal about such
things, you can replace the (.*) with ([^;]+) in both examples.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Mon, 21 Apr 2003 20:58:31 GMT
From: "Ian.H [dS]" <ian@WINDOZEdigiserv.net>
Subject: Re: korn shell or perl
Message-Id: <bkm8av4lbs5jiogtpas86bbuedju5bv9hm@4ax.com>
Keywords: Remove WINDOZE to reply

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

In a fit of excitement on 21 Apr 2003 14:34:51 -0600, Eric Schwartz
<emschwar@pobox.com> managed to scribble:

> "Ian.H [dS]" <ian@WINDOZEdigiserv.net> writes:
> > #!d:\perl\bin\perl
> > use strict;
> > use warnings;
> 
> Both good.  Yaay for using them.
> 
> > my $logfile = 'testfile.txt';
> > my @addys;
> > 
> > open(LOG, "<$logfile");
> >   while (<LOG>) {
> >     chomp;
> >     my @stuff = split(/ src\: /, $_);
> >     push @addys, $stuff[1] =~ /(.*?)\;/;
> >   }
> > close(LOG);
> > 
> > foreach(@addys) {
> >   print "$_\n";
> > }
> 
> Ouch.  Two iterations over the same data?  Why not do the print
> in the first place?  Why bother with a chomp() if you're just going
> to extract the data you want with an RE anyway?  Why split() and
> then use an RE?  Why not just use the RE in the first place?
> 
> $ perl -ne 'print "$1\n" if /src:(.*);/' < /tmp/testfile.txt
>  123.123.123.123
>  234.234.234.234
> 
> (same data)
> 
> I suppose if you wanted to keep @addys around for other processing,
> you could do:
> 
> while(<LOG>) {
>   push @src_addrs, $1 if /src:(.*);/;
> }
> 
> Note intentionally greedy regex; if you want to be minimal about
> such things, you can replace the (.*) with ([^;]+) in both
> examples.
> 
> -=Eric


Great Eric, and much appreciated.

My primary scripting language is PHP and I use Perl mainly for system
scripting as and when, but 99% of my Perl work is for personal use.
The old age phrase "it works". I know there's a million and one
others that could do it better, as you have explained here very well,
which is why I personally like Usenet. While my method may work,
someone will happily post a more simple method from which I can learn
from and progress =)

Thanks again.



Regards,

  Ian

-----BEGIN xxx SIGNATURE-----
Version: PGP 8.0

iQA/AwUBPqRbM2fqtj251CDhEQJ13wCglCfUKLhQnt1cQWZWwFAr/r8NtJ0AoK90
c+azwfxd2drA8Qi+32b9g/h9
=q49K
-----END PGP SIGNATURE-----

-- 
Ian.H  [Design & Development]
digiServ Network - Web solutions
www.digiserv.net  |  irc.digiserv.net  |  forum.digiserv.net
Scripting, Web design, development & hosting.


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

Date: 21 Apr 2003 13:03:04 -0700
From: hfs2@yahoo.com (hfs2)
Subject: network install, access via registry mod, win env
Message-Id: <17f20df0.0304211203.19f9dad0@posting.google.com>

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

If can, what registry entries?  

nt - 2000 - win98
perl - activeware 5.6.1

thanks


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

Date: 21 Apr 2003 14:45:19 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: perl/tk and fork command on windows
Message-Id: <1bff1830.0304211345.186baa12@posting.google.com>

> Can anyone tell me why the following does not work (using Activeperl
> 5.6 on W2K machine).  Windows produces an error when the fork is
> commanded.

[My Disclaimer]
(Before you read the rest of this, you should really be asking
yourself
 whether or not you need to use fork, threads, or another process.
 You should see if select or one of the Tk event mechanisms better
 suits your needs.  Since your script was obiously an example and you 
 didn't elude to the underlying requirements of your program,
 it is hard to tell what would best suits your needs.)


First, fork is implemented on windows using threads. It is not another
process.

Here is my theory (somewhat of a stab)

When you fork, you are copying all of the code being used by Tk,
probably some global and/or static data. After the fork, the gui
handling code internal to Tk, trounces all over itself.  On perl 5.8 I
get a popup dialog from windows

"The instruction at "0x28......" 
(You get the picture?)

I was able to run something asynchronously from Tk, using the
threads pragma and perl 5.8. (perl/Tk is not thread-safe 
though, you probably wouldn't want to try and code something 
that would modify a widget (I don't even know if you could 
easily since references are not blessed when copied from one 
thread to another).  However, I believe that explicityly creating
a thread instead of forking will not cause as much damage, due to the
way variables are shared to another thread.

Your other option is to use Win32::Process.  With Win32::Process you
will need another script or program seperate from the parent (My
example cheats by passing the script an argument if the script was
spawned).

Anyway, here is an example with fork, threads and Win32::Process.

(Check out how much faster control is returned to the gui
 with Win32::Process as opposed to using threads).

use strict;
use warnings;
use threads;

$| = 1;

($#ARGV >= 0 and $ARGV[0] eq "spawn") ? run_spawn() : start_gui();

sub start_gui {
  require Tk;
  my $mw = Tk::MainWindow->new;
  $mw->Button(-text=>"Thread",-command=>\&DO_IT_thread)->pack();
  $mw->Button(-text=>"Fork",-command=>\&DO_IT_fork)->pack();
  $mw->Button(-text=>"Win32::Process",-command=>\&DO_IT_w32proc)->pack();
  Tk::MainLoop();
}

# parent will be printed first
sub DO_IT_thread {
  async { sleep 1; print "child\n" };
  print "parent\n";
}

# this crashed the script on windows and perl 5.8.0 (for me)
sub DO_IT_fork {
  my $pid;
  if ($pid=fork()) {
    print "Parent\n";
    waitpid($pid,0);
  }
  else {
    print "child\n";
    CORE::exit;
  }
}

# this cheats by starting a new copy of
# the script with a different arg.
sub DO_IT_w32proc {
  require Config;
  require Win32::Process;
  my $proc;
  Win32::Process::Create(
      $proc, 
      $Config::Config{perlpath}, 
      "\"$Config::Config{perlpath}\" \"$0\" spawn", 
      0,
      &Win32::Process::NORMAL_PRIORITY_CLASS,
      "."
  ) || die Win32::FormatMessage(Win32::GetLastError());
  print "Parent spawned child with pid - ", $proc->GetProcessID(),
"\n";
}

sub run_spawn {
  print "Spawned new perl using Win32::Process\n";
}



> 
> $| = 1;
> $mw = MainWindow->new;
> $mw->Button(-text=>"Push Me",-command=>\&DO_IT)->pack();
> MainLoop;
> 
> sub DO_IT {
>    if ($pid=fork()) {
>       print "Parent\n";
>       waitpid($pid,0);
>    } else {
>       print "child\n";
>       CORE::exit;
>    }
> }


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

Date: Mon, 21 Apr 2003 13:16:51 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: print out multi queries
Message-Id: <87k7dnwwa4.fsf@limey.hpcc.uh.edu>

>> On Mon, 21 Apr 2003 16:36:14 +0000,
>> Mario542 <member17678@dbforums.com> said:

> How does one run two queries in one script?

Do one first, then the other.  Or both in parallel.

What kind of query are you talking about?

hth
t


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

Date: Mon, 21 Apr 2003 14:57:22 GMT
From: harley.davidson@mailcity.com (Jim Jones)
Subject: Re: Q. Does ActivePerl for Windows require Apache to be installed  ?
Message-Id: <3ea40454.21667145@nntp.ix.netcom.com>

On Mon, 21 Apr 2003 10:08:05 -0500, Chris Olive <nospam@raytheon.com>
wrote:

>Jim Jones wrote:
>> On Mon, 21 Apr 2003 02:49:45 GMT, "Jürgen Exner"
>> <jurgenex@hotmail.com> wrote:
>> 
>> 
>>>Jim wrote:
>>>[Does ActivePerl for Windows require Apache to be installed ?]
>>>
>>>>Can anyone help?
>>>
>>>Of course not.
>>>Why would you possibly think it would?
>>>
>>>jue
>>>
>> 
>> Hi,
>> Because I was just not sure. I want to get started practicing Perl for
>> web stuff, and just didnt know. I have NT4 and loaded Apache2 which
>> works fine. I now want to add Perl so I can start working with it. 
>> 
>> Please advise, given my scenario.
>> THanks for the responses,
>> 
>> Jim
>> 
>
>When you say "ActivePerl" that could be translated to mean ActiveState's 
>PerlScript.  There's a difference between ActivePerl or PerlScript and 
>just Perl under Windows.  And ActiveState's documentation of PerlScript, 
>unfortunately, is very scant.  (There is no better scripting engine for 
>ASP than PerlScript, however.  An incredible shame that it's so poorly 
>documented.)
>
>If you can clarify which you mean, I (and others) could probably provide 
>you with better assistance since I've used both pretty extensively on 
>the Windows platform.
>
>PerlScript != Perl   # strictly speaking
>
>Seeing that you've loaded Apache however (and I can't tell if you loaded 
>Apache because you thought you needed to do so,

Yes, I did load it because I thought I needed to, to start practicing
Perl for enhancing my web pages.

I'd intended to install a Perl interpreter on top of the newly
isntalled Apache2 server on my nt box.

> or because that's 
>exactly what you wanted to do), then maybe you aren't talking about 
>PerlScript since PerlScript REQUIRES running IIS...

Then, I don't want the one that requires running IIS.
I don't want to run anymore MS sfuff, right now than I already am.

Also, is this the right group to be posting my newbie questions?
If there's a more appropriate one to post my fundamental questions,
I'd be delighted to, because I learn more slowly than most.

Thanks,
Jim

>

>Chris
>-----
>Chris Olive
>Systems Consultant
>Raytheon Technical Services Corporation
>Indianapolis, IN
>
>email: olivec(AT)indy(DOT)raytheon(DOT)com
>



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

Date: Mon, 21 Apr 2003 17:00:59 -0500
From: Chris Olive <nospam@raytheon.com>
Subject: Re: Q. Does ActivePerl for Windows require Apache to be installed ?
Message-Id: <mVZoa.328$35.1113@dfw-service2.ext.raytheon.com>

Jim Jones wrote:
> On Mon, 21 Apr 2003 10:08:05 -0500, Chris Olive <nospam@raytheon.com>
> wrote:
> 
> 
>>Jim Jones wrote:
>>
>>>On Mon, 21 Apr 2003 02:49:45 GMT, "Jürgen Exner"
>>><jurgenex@hotmail.com> wrote:
>>>
>>>
>>>
>>>>Jim wrote:
>>>>[Does ActivePerl for Windows require Apache to be installed ?]
>>>>
>>>>
>>>>>Can anyone help?
>>>>
>>>>Of course not.
>>>>Why would you possibly think it would?
>>>>
>>>>jue
>>>>
>>>
>>>Hi,
>>>Because I was just not sure. I want to get started practicing Perl for
>>>web stuff, and just didnt know. I have NT4 and loaded Apache2 which
>>>works fine. I now want to add Perl so I can start working with it. 
>>>
>>>Please advise, given my scenario.
>>>THanks for the responses,
>>>
>>>Jim
>>>
>>
>>When you say "ActivePerl" that could be translated to mean ActiveState's 
>>PerlScript.  There's a difference between ActivePerl or PerlScript and 
>>just Perl under Windows.  And ActiveState's documentation of PerlScript, 
>>unfortunately, is very scant.  (There is no better scripting engine for 
>>ASP than PerlScript, however.  An incredible shame that it's so poorly 
>>documented.)
>>
>>If you can clarify which you mean, I (and others) could probably provide 
>>you with better assistance since I've used both pretty extensively on 
>>the Windows platform.
>>
>>PerlScript != Perl   # strictly speaking
>>
>>Seeing that you've loaded Apache however (and I can't tell if you loaded 
>>Apache because you thought you needed to do so,
> 
> 
> Yes, I did load it because I thought I needed to, to start practicing
> Perl for enhancing my web pages.
> 
> I'd intended to install a Perl interpreter on top of the newly
> isntalled Apache2 server on my nt box.
> 
> 
>>or because that's 
>>exactly what you wanted to do), then maybe you aren't talking about 
>>PerlScript since PerlScript REQUIRES running IIS...
> 
> 
> Then, I don't want the one that requires running IIS.
> I don't want to run anymore MS sfuff, right now than I already am.
> 
> Also, is this the right group to be posting my newbie questions?
> If there's a more appropriate one to post my fundamental questions,
> I'd be delighted to, because I learn more slowly than most.
> 
> Thanks,
> Jim

I'm no authority on this group (or any other Perl group) having only 
recently landed here myself.  But it does appear to be a place somewhat 
receptive to newbie questions, though I have seen some haughty attitudes 
on display from time to time.

It also seems that some purists here often point out the difference 
between Perl and CGI.  And indeed, strictly speaking as some insist on 
pointing out, one has nothing to do with the other.  True enough.  Yet 
Perl will almost always be closely associated with CGI because THAT was 
the thing that popularized Perl and brought it into broader, public 
light.  THAT'S why there *are* newbies here, more than likely, is 
because of CGI.  (Without CGI and the Web, Perl is just some 
"new-fangled scripting language for Unix" like Ruby is currently 
viewed.)  It's a bit like hearing your average person on the street use 
the terms "internet" and "web" interchangably.  Understandable since the 
"web" popularized the (much larger) "internet," and sometimes there's 
nothing to be won in pointing out that there is a (huge) difference.

So... That being said, you may need to be a little patient with some 
responses you get.  Have fun with Perl and Apache on NT.  And if you 
ever HAVE to run IIS, AS PerlScript is the ONLY way to fly in Classic ASP...

Chris
-----
Chris Olive
Systems Consultant
Raytheon Technical Services Corporation
Indianapolis, IN

email: olivec(AT)indy(DOT)raytheon(DOT)com



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

Date: 21 Apr 2003 21:08:41 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: regexp match problem
Message-Id: <slrnba8nep.gd.abigail@alexandra.abigail.nl>

Rong (m9l3@interchange.ubc.ca) wrote on MMMDXIX September MCMXCIII in
<URL:news:1050864679.147700@texada.ugrad.cs.ubc.ca>:
``  Maybe I have a little misunderstanding about regular expresson.
``  I just wonder why /.[^w].?/ can match "two".
``  It seems that I have specified the second character not to be w.


No, you did not. You have specified there must be a character
that's followed by a character that isn't w, and that may
be followed by another character.

/.[^w].?/ matches 'wo'. The o is not a w, and 'wo' is followed by
zero or one other character.



Abigail
-- 
CHECK {print "another "}
BEGIN {print "Just "   }
END   {print "Hacker\n"}
INIT  {print "Perl "   }


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

Date: 21 Apr 2003 14:53:44 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Remembering previous values of the form.
Message-Id: <1bff1830.0304211353.2594c37a@posting.google.com>

> 
> 2) When building the HTML form, perl script would add hidden variables to the 
>    HTML form. When the user updates the entries in the form, the javascript 
>    would generate psuedo SQL code based on the changes made by the user.
>    When user presses "Save" button, another perl script would be executed. 
>    The second perl script would retrieve the hidden variable using param() 
>    and build SQL statement and execute it.


I don't have alot to contribute except a warning. (sorry) 

The idea of (client-side) javascript generating psuedo SQL scares me
to death and I hope your database does not support subqueries or
multiple statements in one query (separated by ';').


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

Date: Mon, 21 Apr 2003 23:32:17 +0530
From: "Kasp" <kasp@epatra.com>
Subject: Re: Trouble with LWP
Message-Id: <b81d7i$isn$1@newsreader.mailgate.org>

>    # post again to comp.lan.perl.misc

:-) I am back, Keith.

I couldn't compile the exact code you gave me, but with a few changes this
is what I tried.

use LWP::UserAgent;
$br = new LWP::UserAgent;
$br->proxy(['http','ftp'], "http://149.21.1.1");    #I even tried to replace
this with "myProxy" -- my proxy
$req=new HTTP::Request(GET, "http://www.perl.com/images/75-logo.jpg");
$doc=$br->request($req);
if ($doc->is_sucess) {
    # do some funky perl
}
else {
   # postING again to comp.lan.perl.misc
}

I am getting this error:
Can't locate object method "is_sucess" via package "HTTP::Headers" at (eval
10) line 1.

Also, if it helps, I have set my environment variable HTTP_proxy to our
local proxy (myProxy).
What is wierd is that one of my friends tried the code I had sent earlier
and it worked for him. He has a Linux machine and is behind the firewall
like me....So to some its another reason to to kick WinDOZE and adopt Linux.
But just for the sake of curosity and satisfaction, I want to get this thing
to work!
--
"Accept that some days you are the pigeon and some days the statue."
"A pat on the back is only a few inches from a kick in the butt." - Dilbert.





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

Date: Mon, 21 Apr 2003 18:54:40 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Trouble with LWP
Message-Id: <mbudash-058474.11544321042003@typhoon.sonic.net>

In article <b81d7i$isn$1@newsreader.mailgate.org>,
 "Kasp" <kasp@epatra.com> wrote:

> >    # post again to comp.lan.perl.misc
> 
> :-) I am back, Keith.
> 
> I couldn't compile the exact code you gave me, but with a few changes this
> is what I tried.
> 
> use LWP::UserAgent;
> $br = new LWP::UserAgent;
> $br->proxy(['http','ftp'], "http://149.21.1.1");    #I even tried to replace
> this with "myProxy" -- my proxy
> $req=new HTTP::Request(GET, "http://www.perl.com/images/75-logo.jpg");
> $doc=$br->request($req);
> if ($doc->is_sucess) {
>     # do some funky perl
> }
> else {
>    # postING again to comp.lan.perl.misc
> }
> 
> I am getting this error:
> Can't locate object method "is_sucess" via package "HTTP::Headers" at (eval
> 10) line 1.

you misspelled 'is_success' (you need 2 c's...)

-- 
Michael Budash


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

Date: 21 Apr 2003 11:25:03 -0700
From: thomas@shurflo.com (Thomas B)
Subject: Trying to get a list of Currently running Windows Apps - How
Message-Id: <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.


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

Date: 21 Apr 2003 13:37:22 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Using Rijndael encryption on socket connection between Windows and Unix...
Message-Id: <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").

> 
[snip]
>  print $sock "$crypted"; # use sysread


[snip]
>  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 4872
***************************************


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