[22809] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5030 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 23 14:06:20 2003

Date: Fri, 23 May 2003 11:05:07 -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           Fri, 23 May 2003     Volume: 10 Number: 5030

Today's topics:
    Re: 32 bits checksum calculation <pkrupa@redwood.rsc.raytheon.com>
    Re: Alarm + System zombies (Vinicio Tavares)
        Can I have an array containing a hash containing a hash <rubberducky703@hotmail.com>
    Re: Can I have an array containing a hash containing a  <ddunham@redwood.taos.com>
    Re: Can't locate sub.pl <pierre@couderc.cc>
    Re: Copying all files in a directory <minceme@start.no>
    Re: day of week (Christopher Hamel)
    Re: extract pattern <g4rry_short@zw4llet.com>
    Re: extract pattern <minceme@start.no>
    Re: Extracting an executable name and arguments from a  <allanon@hotmail.com>
        HELP: Extracting an executable name and arguments from  <rubberducky703@hotmail.com>
        How does find sort? (Sherman Willden)
    Re: How does find sort? <krahnj@acm.org>
    Re: How does find sort? <tzz@lifelogs.com>
    Re: How does find sort? (Randal L. Schwartz)
    Re: Install/setup Net::SSH::PERL <kalinabears@hdc.com.au>
    Re: Lookahead: find empty line(s) or $ (Tad McClellan)
    Re: Managing remote win32 hosts (Mark Leddy)
        Parsing and replacing html then putting it all back tog (Shaun)
    Re: Problem with Addition - doesn't interpret as a numb (Tad McClellan)
        purely Perl CGI/DBI-DBD interface to DB2? <jpagnew@vcu.edu>
    Re: reading javascript arrays <ubl@schaffhausen.de>
    Re: Regexp Multiple Matching Problem (Big Brother)
        removing last part of a line (ram)
    Re: removing last part of a line <krahnj@acm.org>
    Re: removing last part of a line <pkrupa@redwood.rsc.raytheon.com>
    Re: removing last part of a line <ddunham@redwood.taos.com>
        Spawning self - a better way? <tp601553@cia.gov>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 23 May 2003 17:23:02 +0000
From: "Peter A. Krupa" <pkrupa@redwood.rsc.raytheon.com>
Subject: Re: 32 bits checksum calculation
Message-Id: <3ECE58F6.7000509@redwood.rsc.raytheon.com>

# Is a 128 bit checksum okay?

# Example adapted from Digest::MD5 documentation.

use Digest::MD5;

$file = shift || 'xsum.pl';

open ( FILE, $file ) or die ( "Can't open '$file': $!" );

binmode ( FILE );

print ( Digest::MD5->new->addfile ( *FILE )->hexdigest, " $file\n" );



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

Date: 23 May 2003 06:28:35 -0700
From: vtmcs@terra.com.br (Vinicio Tavares)
Subject: Re: Alarm + System zombies
Message-Id: <a165b9fc.0305230528.19adf2d7@posting.google.com>

How can I get the 'system' processes pid and kill them?


         Vinicio


vek@station02.ohout.pharmapartners.nl (Villy Kruse) wrote in message news:<slrnbcped1.i1p.vek@station02.ohout.pharmapartners.nl>...
> On 21 May 2003 06:13:55 -0700,
>     Vinicio Tavares <vtmcs@terra.com.br> wrote:
> 
> 
> >I have this code, it creates zombies, how can I solve this problem? Thanks.
> >
> >...
> >eval {
> >    local $SIG {ALRM} = sub { die "..." };
> >    alarm $timx;
> >    system "...";
> >    alarm 0;
> >}
> >...
> >
> 
> 
> Don't try to abort the system function.  It won't have a chance to
> take care of the zombie that is created possible long after the alarm
> timed out.
> 
> 
> Villy


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

Date: Fri, 23 May 2003 17:18:28 +0100
From: "Max Adams" <rubberducky703@hotmail.com>
Subject: Can I have an array containing a hash containing a hash?
Message-Id: <balhkm$115hb$1@ID-116287.news.dfncis.de>

Can I have an array containing a hash containing a hash?

I want a structure similar to this

[index]
    {identifier1}
        {component1}
        {count4component1}
        {componentX}
        {count4componentX}
[index]
    {identifier2}
        {component1}
        {count4component1}

I want to store file details and this is what I want to store

[0]
    Program1.exe
        FileSize
        Modified Time
        Last Accessed By
[1]
    Program 2
    ....

However when I try and do an assignment like this:

$Stats[0]{Name}{FileUser} = $_[1];

I get an error:

Can't use string ("DMCORP.ADMIN") as a HASH ref while "strict refs" in use
at C:\AnaProg.pl line 148, <fileIN> line 3.

Can anyone suggest a workaround or solution?











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

Date: Fri, 23 May 2003 16:38:21 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: Can I have an array containing a hash containing a hash?
Message-Id: <18sza.1512$MJ7.222@newssvr16.news.prodigy.com>

Max Adams <rubberducky703@hotmail.com> wrote:
> Can I have an array containing a hash containing a hash?

Almost.  You can have an array containing references to hashes, each
containing references to other hashes.

> However when I try and do an assignment like this:

> $Stats[0]{Name}{FileUser} = $_[1];

> I get an error:

> Can't use string ("DMCORP.ADMIN") as a HASH ref while "strict refs" in use
> at C:\AnaProg.pl line 148, <fileIN> line 3.

Hmm.. I don't know why.  It seems okay to me.

Did you mistype something into your post rather than cut and paste?

% cat /tmp/foo
#!/bin/perl -lw
use strict;
my @stats;
$stats[0]{Name}{FileUser} = "Foobar";
print scalar @stats;
print keys %{$stats[0]};
print keys %{$stats[0]{Name}};
print $stats[0]{Name}{FileUser};
% /tmp/foo
1
Name
FileUser
Foobar
%

-- 
Darren Dunham                                           ddunham@taos.com
Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >


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

Date: Fri, 23 May 2003 12:20:29 +0200
From: Pierre Couderc <pierre@couderc.cc>
To: Brian McCauley <nobull@mail.com>
Subject: Re: Can't locate sub.pl
Message-Id: <3ECDF5ED.2090300@couderc.cc>

Brian McCauley wrote:
 >
 > The mechanism provided in Perl5 for this is the module.
 >
 >
 >>I have solved the problem with absolute path in my script. A solution
 >>that personnally, I find "horrible".
 >
 >
 > If I understood your problem correctly then using an absolute path
 > will not solve it.
 >
 > Like I said, if multiple modules (or mod_perl-ized CGI scripts)
 > require() the same file you are playing Russian roulette.
 >
Ok, and I think that it works now (fully, not the Russian roulette way...) 
because I have used absolute paths AND I have declared mysub as a package!

Thank you again.
Pierre



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

Date: Fri, 23 May 2003 15:10:28 +0000 (UTC)
From: Vlad Tepes <minceme@start.no>
Subject: Re: Copying all files in a directory
Message-Id: <baldl4$a75$1@troll.powertech.no>

> Naina <naina_r@yahoo.com> wrote:

> Hi 
>
> I used File::Copy and what I was able to do was copy some specific
> files. Can i copy all files in a directory to another directory?I
> tried *.*,it doesnt work.For example i need to copy all files in
> newdir to temp...
> 
> Eg copy ("C:/temp/newdir/*.*", "k:/temp/*.*");
>
> Any suggestion would be welcome. Thanks Naina

If you want, you can create unsafe, unportable and inefficient scripts
with the Shell module:

    use Shell;
    cp('/files/*.*', '/backups');

On windows, this might work:

    use Shell;
    copy('C:\files\*.*', 'K:\backups');

It may be what you asked for, but it's not what you want. Or maybe it
is. Don't know. Just feeled like posting.

-- 
                                              (,_    ,_,    _,)
                                              /|\`\._( )_./'/|\
                                             · ·  \/ L /\ D  · ·
                                            /__|.-'`-\_/-`'-.|__\
                                           `          "          `


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

Date: 23 May 2003 06:08:00 -0700
From: hamelcd@hotmail.com (Christopher Hamel)
Subject: Re: day of week
Message-Id: <4f60d5b3.0305230508.1aefc2b8@posting.google.com>

Garry Williams <garry@ifr.zvolve.net> wrote in message news:<slrnbcq3j4.pbr.garry@zfw.zvolve.net>...
> 
>     my %dow = ( 0 => 'Sunday',    1 => 'Monday',   2 => 'Tuesday',
> 		3 => 'Wednesday', 4 => 'Thursday', 5 => 'Friday',
> 		6 => 'Saturday' );
> 

I realize we're talking seven elements here, but would this not be
better served by an array?

my @dow = qw/Sunday Monday Tuesday Wednesday
             Thursday Friday Saturday/;


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

Date: Fri, 23 May 2003 12:19:37 +0000
From: Garry Short <g4rry_short@zw4llet.com>
Subject: Re: extract pattern
Message-Id: <bal07r$e1u$1$8300dec7@news.demon.co.uk>

vaidehi wrote:

> vaidehi_30@yahoo.com (vaidehi) wrote in message
> news:<b20ff12f.0305221456.7e72faa2@posting.google.com>...
>> Hello,
>> 
>> I have got strings like this one:
>> 1: 196.37.75.158:1024 - 10.10.1.12:79 (a2b)             6>    6< 
>> (complete)
>> 
>> I want to extract only "196.37.75.158:1024 - 10.10.1.12:79" from this
>> string How do we do it?
>> 
>> thanks
>> -vaidehi
> 
> Hello,
> I could do that!
> $line =$_;
> $line= s/\(.+//;         #substitutes everything followed by "(" with
> nothing
> $line= s/.*?://;         #substitutes  evrything b4 ":" with nothing.
> 
> But it is taking two instructions to accomplish the job. Can we do it
> in a single instruction??
> 
> Thanks
> -Vaidehi

$line =~ s/^.*?:(.*?)\(.+$/$1/;
Assuming your regexes were correct, the middle bit (.*?) captures everything
else and stuffs it into $1, which you then substitute in as the complete
string. I've also added ^ and $, just to anchor the two matches.

Regards,

Garry




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

Date: Fri, 23 May 2003 12:27:38 +0000 (UTC)
From: Vlad Tepes <minceme@start.no>
Subject: Re: extract pattern
Message-Id: <bal43q$673$1@troll.powertech.no>

> vaidehi <vaidehi_30@yahoo.com> wrote:

> vaidehi_30@yahoo.com (vaidehi) wrote in message news:<b20ff12f.0305221456.7e72faa2@posting.google.com>...
>> Hello, 
>> 
>> I have got strings like this one:
>> 1: 196.37.75.158:1024 - 10.10.1.12:79 (a2b)             6>    6<  (complete)
>> 
>> I want to extract only "196.37.75.158:1024 - 10.10.1.12:79" from this string
>> How do we do it?
>> 
>> thanks
>> -vaidehi
>
> Hello,
> I could do that!
> $line =$_;
> $line= s/\(.+//;         #substitutes everything followed by "(" with
> nothing
> $line= s/.*?://;         #substitutes  evrything b4 ":" with nothing.
>
> But it is taking two instructions to accomplish the job. Can we do it
> in a single instruction??
>
> Thanks
> -Vaidehi

s/.*: (.+) \(.*/$1/;

or maybe

s/                                          # Substitute with comments
   ^                                     # start of string
    .*?                                #  anything, as few as possible
        (                             # start capture into $1
            \d+\.\d+\.\d+\.\d+ : \d+ #    ip:port
            \s - \s                  #      a space - a dash - a space
            \d+\.\d+\.\d+\.\d+ : \d+ #    ip:port
        )                             # end capture
     .*                                # anything, as many as possible
   $                                     # end of line
/$1/x;                                      # replace with whats in $1



-- 
                                              (,_    ,_,    _,)
                                              /|\`\._( )_./'/|\
                                             / ,  \/ L /\ D  , \
                                            /__|.-'`-\_/-`'-.|__\
                                           `          "          `


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

Date: Fri, 23 May 2003 15:16:02 +0100
From: "Allanon" <allanon@hotmail.com>
Subject: Re: Extracting an executable name and arguments from a string
Message-Id: <balaf3$l28@newton.cc.rl.ac.uk>


"Paul Tomlinson" <rubberducky703@hotmail.com> wrote in message
news:bal82u$10j9q$1@ID-116287.news.dfncis.de...
> All,
> I have a string in a file similar to the one below and I want to extract
the
> process name (in the example below I would like "ATM.exe" returned) and
any
> arguments which are also in the string
>
> This is the start of the string:
> [COMPDMN102:C:\Program
> Files\ATM\ATM.exe:1660:{B2C51131-9396-497D-8F3F-663E3F6CCC50}] ....... etc
> etc
>
> I can pattern match and determine if ".exe" exists in the string but i'm
> unsure of how I can retrieve the process name before it.  I'm not
interested
> in the path to the file just the filename itself.

How about:

$_ = '[COMPDMN102:C:\Program
Files\ATM\ATM.exe:1660:{B2C51131-9396-497D-8F3F-663E3F6CCC50}]';

@extract = $_ =~ /^\[([^:]+).*?([^\\]+\.exe)\:/i;

$extract[0] would then be the process name and $extract[1] the executable
name.

Allanon




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

Date: Fri, 23 May 2003 14:35:25 +0100
From: "Paul Tomlinson" <rubberducky703@hotmail.com>
Subject: HELP: Extracting an executable name and arguments from a string
Message-Id: <bal82u$10j9q$1@ID-116287.news.dfncis.de>

All,
I have a string in a file similar to the one below and I want to extract the
process name (in the example below I would like "ATM.exe" returned) and any
arguments which are also in the string

This is the start of the string:
[COMPDMN102:C:\Program
Files\ATM\ATM.exe:1660:{B2C51131-9396-497D-8F3F-663E3F6CCC50}] ....... etc
etc

I can pattern match and determine if ".exe" exists in the string but i'm
unsure of how I can retrieve the process name before it.  I'm not interested
in the path to the file just the filename itself.

Can anyone here help.

PT




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

Date: 23 May 2003 07:18:09 -0700
From: sherman.willden@hp.com (Sherman Willden)
Subject: How does find sort?
Message-Id: <3a80d8d6.0305230618.69ae4e3e@posting.google.com>

How does find sort on the following list. I am afraid that I may pop
the wrong one.
TA_22_20030412_2
TA_22_20030511_3
TA_22_20030514_6
TA_22_20030517_9
TA_22_20030522_12
TA_22_20030522_15

We perform product builds and I need to keep only the last four
directories in a history folder. I perform the routine shown below
which seems to work, but like I said, I may someday remove a directory
that I want to keep. I am using Win2K.

#! perl -w

use strict;
use File::Find;

my $version="22";
my $history_dir="o:\\2.2_History\\server";
my @dir_list;

find(sub { /TA\_$version.*$/ && (push @dir_list, $File::Find::name) },
"$history_dir" );
while( @dir_list + 0 > 2 ) {
    my $popped_element = pop(@dir_list);
    print "popped_element '$popped_element'\n";
}
popped_element 'o:\2.2_History\server/windows/distro_files/TA_22_20030412_2
popped_element 'o:\2.2_History\server/windows/distro_files/TA_22_20030511_3

Presently the above routine returns TA_22_20030412_2 and
TA_22_20030511_3 which I then remove. I have to convert the forward
slash ( / ) to a backward slash ( \ ) for the remove to work.

Thanks;

Sherman


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

Date: Fri, 23 May 2003 16:08:55 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: How does find sort?
Message-Id: <3ECE4777.51E108AA@acm.org>

Sherman Willden wrote:
> 
> How does find sort on the following list.

find doesn't do any sorting, you will have to do that yourself.

> I am afraid that I may pop
> the wrong one.
> TA_22_20030412_2
> TA_22_20030511_3
> TA_22_20030514_6
> TA_22_20030517_9
> TA_22_20030522_12
> TA_22_20030522_15
> 
> We perform product builds and I need to keep only the last four
> directories in a history folder. I perform the routine shown below
> which seems to work,

"seems to work" is not a good way develop programs.  You should probably
define your specs in more detail.

> but like I said, I may someday remove a directory
> that I want to keep. I am using Win2K.
> 
> #! perl -w
> 
> use strict;
> use File::Find;
> 
> my $version="22";

You don't have to quote numbers, perl will do the right thing.


> my $history_dir="o:\\2.2_History\\server";

You don't have to use back-slashes, perl will do the right thing with
slashes instead.


> my @dir_list;
> 
> find(sub { /TA\_$version.*$/ && (push @dir_list, $File::Find::name) }, "$history_dir" );

The underscore (_) character is not special in quoted strings or regular
expressions, you don't have to precede it with a back-slash.  The
variable $history_dir is already a string, you don't have to enclose it
in double quotes.


> while( @dir_list + 0 > 2 ) {

An array in scalar context is a number, you don't have to add zero to
it.


>     my $popped_element = pop(@dir_list);
>     print "popped_element '$popped_element'\n";
> }

This would more idiomatically be written as:

print "popped_element '$_'\n" for reverse splice @dir_list, 2;


> popped_element 'o:\2.2_History\server/windows/distro_files/TA_22_20030412_2
> popped_element 'o:\2.2_History\server/windows/distro_files/TA_22_20030511_3
> 
> Presently the above routine returns TA_22_20030412_2 and
> TA_22_20030511_3 which I then remove. I have to convert the forward
> slash ( / ) to a backward slash ( \ ) for the remove to work.

unlink() will work with forward slashes.


John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 23 May 2003 12:10:53 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: How does find sort?
Message-Id: <4n65o1tzhu.fsf@lockgroove.bwh.harvard.edu>

On 23 May 2003, sherman.willden@hp.com wrote:
> How does find sort on the following list. I am afraid that I may pop
> the wrong one.
> TA_22_20030412_2
> TA_22_20030511_3
> TA_22_20030514_6
> TA_22_20030517_9
> TA_22_20030522_12
> TA_22_20030522_15
> 
> We perform product builds and I need to keep only the last four
> directories in a history folder. 

If you mean "the last four alphabetically, assuming the directory
naming above is consistent" then sort @dir_list before you pop from
it.  You should realize, however, that a directory or file named
"ZEBRA" will come last.  You may want to sort by the directory's ctime
instead.

> while( @dir_list + 0 > 2 ) 
> { 
>   my $popped_element = pop(@dir_list); 
>   print "popped_element '$popped_element'\n";
> }

You are not popping the last four, you're popping until there's two
left.  Also, I would use array subscripts and scalar(@dir_list) but
that's a matter of taste.

Ted


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

Date: Fri, 23 May 2003 16:43:30 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: sherman.willden@hp.com (Sherman Willden)
Subject: Re: How does find sort?
Message-Id: <6285703c66220f6bf35a40fb100c7158@TeraNews>

>>>>> "Sherman" == Sherman Willden <sherman.willden@hp.com> writes:

Sherman> How does find sort on the following list. I am afraid that I may pop
Sherman> the wrong one.
Sherman> TA_22_20030412_2
Sherman> TA_22_20030511_3
Sherman> TA_22_20030514_6
Sherman> TA_22_20030517_9
Sherman> TA_22_20030522_12
Sherman> TA_22_20030522_15

"find" doesn't sort.  If you want it sorted, sort it.

print "Just another Pelr hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Sat, 24 May 2003 00:55:32 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: Install/setup Net::SSH::PERL
Message-Id: <3ece377f$0$26199@echo-01.iinet.net.au>


----- Original Message -----
From: "Randy Kobes" <randy@theoryx5.uwinnipeg.ca>

> I also saw this bug in Math::Pari
> on 5.8 in one of its tests (an error about a free to a wrong
> pool)

Yeah - that's the one. I thought there were some additional errors as well,
but now that I check I find they occurred with my mingw build of perl only.

Incidentally, I can send you blib's of Math::GMP (and the GMP dll which is
also needed) if you want to put up ppm's of that module on theoryx5.

Let me know if you're interested.

Cheers,
Rob




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

Date: Fri, 23 May 2003 07:43:22 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Lookahead: find empty line(s) or $
Message-Id: <slrnbcs5ra.4kt.tadmc@magna.augustmail.com>

Martin Schweikert <MartinSchweikert@gmx.de> wrote:

> I would like to find empty lines or '$' characters in a lookahead 
> expression.


> But now I want to say: "find one or more empty line or a '$' character" 
> in one statement.


But what you want to say is not really what you want!

It appears that you really want to say:

   find one or more empty line or a '$' character or end of string


> I tried variants of
> 
> (?=[\n{2,}\$])       '$' is found correctly, but introducing the [] 
> causes \n{2,} to match a single \n instead of 2 or more.


Or a single comma, or a single curly brace, or a single '2' digit...


> (?=\n{2,}|\$)        finds the empty line, but not the '$' character


This does exactly what you say you want to do.

The problem is not with your pattern, your problem is with the
specification of what you want to do.


> undef $/;
> open (TEXT, 'foo.txt');


You should always, yes *always*, check the return value from open():

   open(TEXT, 'foo.txt') or die "could not open 'foo.txt'  $!";


> while (<TEXT>) {


Writing a loop that is guaranteed to execute exactly once is obfuscation.


> The input looks like

> $1/11$ aaa aaaaaaaa aaa a aaaaaaaa aa $1/12$ bbbbbbb bb bbbbbbb b bbb bb
> 
> $1/13$ cccccc ccccc cc c 
> ccccccccc cc $1/14$ dddddddd dddddd dddd
> dddddddd ddddd
> ----------


Your pattern matches 3 times, just like it is supposed to.

You _require_ either a blank line or a dollar sign at the end of
a "record", the "record" starting with $1/14$ does not meet
that specification.


> Help!


   (?=\n{2,}|\$|$)


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 23 May 2003 03:54:55 -0700
From: mark_leddy@hotmail.com (Mark Leddy)
Subject: Re: Managing remote win32 hosts
Message-Id: <b54b4ac5.0305230254.4e46d1f7@posting.google.com>

Did you find the answer?
Can you query a Windows 2000 host using Perl & WMI from a machine with
Linux and Perl?

I could see it would likely be easy from a Windows 2000 machine to a
Windows 2000 machine I have done that with VBScript, but I think it
would be tricky because on a Linux box with Perl - what is the method
that it uses for authenication to the Windows machine (and is it
secure) to let you query WMI?

Please let me know, it would be great if you could also post any
samples of your script.

Thanks,
Mark






"MHW" <MHW@MHW.com> wrote in message news:<zrMwa.21388$hd6.19012@fed1read05>...
> Thanks all. I have approached this from all angles I can find and it looks
> like WMI scripting may be the way to go. Windows 2000 and 2003 has a WMI
> provider for WLBS located at root\MicrosoftNLB. I am pretty sure I can
> interface with this object through perl.
> 
> Thanks,
> 
> MHW
> 
> "William Goedicke" <goedicke@goedsole.com> wrote in message
> news:m3n0hrf2tx.fsf@mail.goedsole.com...
> > Dear MHW -
> >
> > "MHW" <MHW@MHW.com> writes:
> >
> > > I want the ability to pole for service availability (HTTP, Terminal
> > > Services, etc.) on a Windows Load Balanced Cluster (WLBS)
> >
> > You should investigate netsaint (i.e. http://www.netsaint.org).
> >
> > > and [then I want to] generate windows commands from the Linux server
> > > to remove hosts from the cluster.
> >
> > In the past I solved this problem by creating a CGI script on the
> > servers that would execute arbitrary commands contained in the URL.
> >
> > "What?!?!?!" you say; that's the worst security disaster possible!
> > The trick was that I encrypted the URL-embedded command with the
> > public key of each server I was controlling.  I used this in
> > combination with netsaint to automatically control services for
> > several hundred machines at a web-hosting firm.  It worked like a
> > charm.
> >
> > We also used it for systems configuration management and diagnostics.
> > We kept a database of diagnostic commands which we ran against
> > machines when customers reported problems to isolate changes.
> > Consider commands: perl -v, cksum /etc/xinetd.conf and net services.
> >
> >      Yours -      Billy
> >
> > ============================================================
> >      William Goedicke     goedicke@goedsole.com
> >                           http://www.goedsole.com:8080
> > ============================================================
> >
> >           Lest we forget:
> >
> > A day without raw fish is like a day without sunshine.
> >
> > - William Goedicke


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

Date: 23 May 2003 10:15:29 -0700
From: shirschman@hotmail.com (Shaun)
Subject: Parsing and replacing html then putting it all back together again?
Message-Id: <1d3311d7.0305230915.3f6083e2@posting.google.com>

Ok so here's the issue:

I have a script that transforms xml data with it's xsl counter part,
to create my html ($html).

I need to parse $html for the first block, middle block and last block
of data.  The begining of the middle block of data is seperated by
<!--\(--> (simply trying to find a unique set of characters for perl
to find) and ends with <!--\)--> ofcourse marking the begining of the
last block.

So I need to be able to take the middle block of data, and replace it
with a new block of data, then combine the first, new middle, and last
block of data to produce a new $html =)

Any modules out there with this type of functionality built in?  Be
gentle, I'm a novice.


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

Date: Thu, 22 May 2003 22:12:49 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Problem with Addition - doesn't interpret as a number?
Message-Id: <slrnbcr4dh.3rq.tadmc@magna.augustmail.com>

Dave <nipper1999@aol.com> wrote:

>  Here is sample code:

[snip code]

> Output is similar to this:

[snip output]

> What am I missing?  


The program's input.   :-)


> I want to do simple addition and I can't seem to
> get it to work.


If you post a short and complete program *that we can run*
that will demonstrate your problem, then we will be able to 
help you fix it.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 23 May 2003 09:08:21 -0400
From: Jim Agnew <jpagnew@vcu.edu>
Subject: purely Perl CGI/DBI-DBD interface to DB2?
Message-Id: <3ECE1D45.E7B38FC4@vcu.edu>

Dear Netpeople,

thanks for the help i've gotten in here, both thru lurking and direct
help...

I'm trying to roll my own pure-Perl cgi interface to DB2, considering
that i've looked alll over sourceforge and freshmeat for one, and they
*all* need Java, PHP, or something else.

I'm trying to roll a pure Perl interface to allow it to be used
anywhere, for any db..

the ones I've found are dependent on some feature such as mysql, etc..
I want one that runs purely off the perl dbi/dbd interface.

another nice point would be if it could grab the table/column
information
from the database itself.

has anyone seen such a beast?  i'm dumbfounded that it does not exist
yet.. !!

Jim

--
"4,000 years ago I made a mistake."  Elrond Half-Elven, in "Fellowship
of the Ring"

-- 
"4,000 years ago I made a mistake."  Elrond Half-Elven, in "Fellowship
of the Ring"


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

Date: Fri, 23 May 2003 14:36:21 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: reading javascript arrays
Message-Id: <bal7os$dc2$1@news.dtag.de>

darthtampon wrote:
> i have tried everything. All the books i have dont help either. can somebody
> give me an example of perl code reading a javascript array.

Assuming there is a solution, you should have found it if you tried 
everything. I doubt though that you would have finished your work before 
infinity.

Your question is not clear. Do you want to pass a JavaScript data 
structure to Perl or do you want to parse JavaScript source code using 
Perl? Are your Perl program and JavaScript program on the same computer 
or are you talking about a client server environment?

Read up on serialization. That might enlighten you enough to solve the 
problem yourself.

malte



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

Date: 23 May 2003 06:29:52 -0700
From: jonasb@alum.rpi.edu (Big Brother)
Subject: Re: Regexp Multiple Matching Problem
Message-Id: <79c1dbe1.0305230529.771222ab@posting.google.com>

Thanks for your replies. I figured I'd be a little more specific with
the code. I'm pretty sure that the problem lies in the variable that I
use to get the matched string, but I've looked through the docs and am
not sure what to use.

        if ($_=~m/$RE{net}{IPv4}{dec}{-keep}/g)   #Find IP Address
        {
                if ($objects{$1}==NULL)         #Already in hash?
                {
                        $objects{$1}=(16777215-$i); #hash to determine
color
                        $i+=65433;
                }
                $hlight=$1;
                $color=sprintf("%04x",$objects{$1});

                s/$hlight/<A
HREF=\"http:\/\/$serverip\/cgi-bin\/s2h.cgi?t=$t&nm=$nm&filter=$hlight\"><SPAN
style=\"background-color: #$color\">$hlight<\/SPAN><\/A>/g;

        }


I tried while instead of if, I also tried foreach. The while loop
seems to go on forever, and the foreach doesn't highlight anything.

Thanks!

B
jonasb@alum.rpi.edu (Big Brother) wrote in message news:<79c1dbe1.0305211051.687aebe6@posting.google.com>...
> Hi -
> 
> I am writing a script that parses through a file line by line to
> search for IP addresses (it's to make syslog files available in HTML
> with the IPs highlighted). I've got the code working for the first IP
> on each line, but it never goes on to match if there is a second IP on
> the line. So I have...
> if($_=~/IPmatchingregexp/)
> {
>     do stuff
> }
> 
> I tried replacing the if with a while, but it seems to go into an
> infinite loop. Can anyone help me on how do basically do a:
> foreach(matched regexp)? I want to run the "do stuff" code for each IP
> on the line, not just the first.
> 
> Thanks!
> B


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

Date: 23 May 2003 10:05:18 -0700
From: ramc8191@rediffmail.com (ram)
Subject: removing last part of a line
Message-Id: <53c2d1ac.0305230905.613a521b@posting.google.com>

I have a Huge file
and need to remove everything after the occurence of a / on ech line

i have been trying to do it with

perl -pi.bak -e 's/\/*/""/g' temp1.txt

but thanks to my extremely limited knowledge of perl and
regexpressions ...dont know what its doing..

help


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

Date: Fri, 23 May 2003 17:28:53 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: removing last part of a line
Message-Id: <3ECE5A43.F8D1AC6E@acm.org>

ram wrote:
> 
> I have a Huge file
> and need to remove everything after the occurence of a / on ech line
> 
> i have been trying to do it with
> 
> perl -pi.bak -e 's/\/*/""/g' temp1.txt
> 
> but thanks to my extremely limited knowledge of perl and
> regexpressions ...dont know what its doing..

Everything after the first '/'.

perl -pi.bak -e's!(?<=/).*!!' temp1.txt

Everything after the last '/'.

perl -lpi.bak -e's!(?<=/)[^/]*$!!' temp1.txt


John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 23 May 2003 17:29:41 +0000
From: "Peter A. Krupa" <pkrupa@redwood.rsc.raytheon.com>
Subject: Re: removing last part of a line
Message-Id: <3ECE5A85.7060305@redwood.rsc.raytheon.com>

I think this will suffice:

perl -pi.bak -e "s/\/.*//" temp1.txt

You need a period after the asterisk to match  any character following 
the slash zero or more times...



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

Date: Fri, 23 May 2003 17:58:38 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: removing last part of a line
Message-Id: <ijtza.2438$7h2.56285203@newssvr21.news.prodigy.com>

ram <ramc8191@rediffmail.com> wrote:
> I have a Huge file
> and need to remove everything after the occurence of a / on ech line

> i have been trying to do it with

> perl -pi.bak -e 's/\/*/""/g' temp1.txt

Close.  * means zero or more of the thing before it.  And you want to
remove "anything" after the slash.  The period "." will match (almost)
any character.

If you want to remove it, you can leave the right hand side blank.  You
don't need the "" bit.

Also, this will start at the first slash and remove everything
else.  Because of that, it will never match twice on a line.  You don't
need the /g bit.

perl -pi.bak -e 's/\/.*//' temp1.txt

-- 
Darren Dunham                                           ddunham@taos.com
Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >


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

Date: Fri, 23 May 2003 14:46:26 GMT
From: Tweetie Pooh <tp601553@cia.gov>
Subject: Spawning self - a better way?
Message-Id: <Xns9384A0777F9A5TweetiePooh@62.253.162.105>

   I asked a question here earlier this week and the solution worked.  We it 
did sort of.  The problem is not in perl though.

Essentially I had a server that spawned children on connection, not unusual.  
The other side though did not send data as requested and didn't always make 
the connection properly.  Change of tack.

Now my side connects out and listens on the remote port, collecting data, 
processing and passing on.

The program reads a list of remote host ip's (and port) into an array and 
does some other setup stuff.

If no command line parameters are present it assumes to be the daddy and 
enters a loop using system() to call itself with each ip/port combination as 
background processes after which it exits.

If command line parameters are present the above loop is bypassed and the 
program opens log file and output port then enters an infinite loop in which 
it connects to the remote site.  If connect is OK it loops reads data and 
processes yada yada yada.

Is this a "good" way to do this?  Is there a better way, what is it?  I know 
there is another way, this is Perl.


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

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


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