[26036] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8245 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 12 18:05:30 2005

Date: Tue, 12 Jul 2005 15:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 12 Jul 2005     Volume: 10 Number: 8245

Today's topics:
        AS Perl: rep gives 500 server closed? <john@castleamber.com>
    Re: AS Perl: rep gives 500 server closed? <john@castleamber.com>
    Re: Book:  Higher-Order Perl: Transforming Programs wit (Anno Siegel)
    Re: Book:  Higher-Order Perl: Transforming Programs wit axel@white-eagle.invalid.uk
    Re: Book:  Higher-Order Perl: Transforming Programs wit <tzz@lifelogs.com>
        Building HoHoH from arbitrary size arrays ? <spam.me@blueyonder.co.uk>
        DBI and fetchhasref <Peter.Kramer@gmx.de>
        Generating a HoH without duplicate code <lynn.watts@ugs.com>
    Re: Generating a HoH without duplicate code xhoster@gmail.com
    Re: Generating a HoH without duplicate code <someone@example.com>
    Re: Minor correction  July 11, 2005 <horedson@earthlink.net>
        Win32::Process->Create, can't get right syntax <sheam@hb-studios.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 12 Jul 2005 16:00:04 GMT
From: John Bokma <john@castleamber.com>
Subject: AS Perl: rep gives 500 server closed?
Message-Id: <Xns96916FC21765Dcastleamber@130.133.1.4>

I keep getting:

Error: 500 Server closed connection without sending any data back

When I try to access the ActiveState repositories. Since I have been 
juggling with Perl installs (problems with PAR) I might have done something 
that causes this, but I have no idea what :-(

Anyone?

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: 12 Jul 2005 16:25:39 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: AS Perl: rep gives 500 server closed?
Message-Id: <Xns9691741807E15castleamber@130.133.1.4>

John Bokma <john@castleamber.com> wrote:

> I keep getting:
> 
> Error: 500 Server closed connection without sending any data back
> 
> When I try to access the ActiveState repositories. Since I have been 
> juggling with Perl installs (problems with PAR) I might have done
> something that causes this, but I have no idea what :-(
> 
> Anyone?

If I connect directly to 
<http://ppm.ActiveState.com/PPM/ppmserver-5.8-windows.plex?
urn:/PPM/Server/SQL>

I get a 500 too, so I guess AS is having problems, I already emailed 
support.

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: 12 Jul 2005 10:17:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Book:  Higher-Order Perl: Transforming Programs with Programs
Message-Id: <db05bb$maq$1@mamenchi.zrz.TU-Berlin.DE>

 <axel@white-eagle.invalid.uk> wrote in comp.lang.perl.misc:
> David H. Adler <dha@panix.com> wrote:
> > On 2005-07-09, axel@white-eagle.invalid.uk
> <axel@white-eagle.invalid.uk> wrote:
> >> Indeed. May I draw attention to the _author's_ site:
> >>
> >> http://hop.perl.plover.com/#free
> >>
> >>       "My contract says that after the book is published I can
> >>       distribute the complete text from my web site. The content
> >>       of my book will be available to everyone everywhere for
> >>       free. Watch this space for updates."
>  
> > That said, if you can, buy the book anyway. It's real good. If we buy
> > this one, maybe he'll write more! :-)
> 
> I intend to. Acquiring new books is not a problem... now spending time
> reading them and, more importantly, finding bookshelf space is!

Right!  Mine is sitting in a stack on the floor, largely unread and
waiting for a vacancy in the shelf.  Along with introductions to Haskell,
UML, Design Patterns and other stuff I'm going to read RSN.

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: Tue, 12 Jul 2005 13:06:33 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: Book:  Higher-Order Perl: Transforming Programs with Programs
Message-Id: <tfPAe.127131$Vo6.118412@fe3.news.blueyonder.co.uk>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> <axel@white-eagle.invalid.uk> wrote in comp.lang.perl.misc:
>> David H. Adler <dha@panix.com> wrote:
>> > On 2005-07-09, axel@white-eagle.invalid.uk
>> <axel@white-eagle.invalid.uk> wrote:

[ re Higher Order Perl ] 

>> > That said, if you can, buy the book anyway. It's real good. If we buy
>> > this one, maybe he'll write more! :-)

>> I intend to. Acquiring new books is not a problem... now spending time
>> reading them and, more importantly, finding bookshelf space is!
 
> Right!  Mine is sitting in a stack on the floor, largely unread and
> waiting for a vacancy in the shelf.  Along with introductions to Haskell,
> UML, Design Patterns and other stuff I'm going to read RSN.

Wow! You also have unread books on UML - I bought one years ago and another
when I was in Amsterdam... I have never opened the covers of either.

They are at the bottom of my books to read... first I need to
increase my German so I can read some 'Koelsch Krimis'. Opps, I am
going wildly off-topic.

Axel




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

Date: Tue, 12 Jul 2005 13:48:52 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Book:  Higher-Order Perl: Transforming Programs with Programs
Message-Id: <4nk6jvnce3.fsf@lifelogs.com>

On Mon, 11 Jul 2005, dha@panix.com wrote:

> That said, if you can, buy the book anyway. It's real good. If we
> buy this one, maybe he'll write more! :-)

I strongly agree, "Higher-Order Perl" is a truly excellent book that
is more about techniques than about a particular language (although
Perl works really well to demonstrate the concepts).  

A warning for beginner programmers: it's not for you.  You need at
least a few years of experience as a programmer, and probably a few
years of college-level CS classes, to get the most out of the book.

Ted

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----


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

Date: Tue, 12 Jul 2005 14:07:47 +0100
From: Allan Houston <spam.me@blueyonder.co.uk>
Subject: Building HoHoH from arbitrary size arrays ?
Message-Id: <5ad38$42d3c0a4$c2758ec3$3929@nf5.news-service.com>

Hi,

I've searched and read about everything I can find on trying to do this, 
but my only solution I can think of is real, real ugly..

Basically I'm looking to create a sub routine which will query a 
database table for the specified rows, and create a hash where each 
column is a key in the hash of hashes.

i.e. From a table like so :

+---------------+---------------+------------+------+
| region        | location      | function   | type |
+---------------+---------------+------------+------+
| Aztec West    | Aztec West    | PE Routers | 7513 |
| Aztec West    | Staverton     | PE Routers | 7513 |
| Barnsley      | Barnsley      | PE Routers | 7513 |
| Barnsley      | Bradford      | PE Routers | 7513 |
| Barnsley      | Sheffield     | PE Routers | 7513 |
| Basildon      | Basildon      | PE Routers | 7513 |
| Basildon      | Gillingham    | PE Routers | 7513 |
-----------------------------------------------------

I'd produce a hash like :

	$hash{'Aztec West'}{'Aztec West'}{'PE Routers}{'7513'}
	$hash{'Aztec West'}{'Staverton'}{'PE Routers}{'7513'}
	$hash{'Barnsley'}{'Barnsley'}{'PE Routers'}{'7513'}    etc etc.

The problem being that I'm trying to create a function which will read 
in say the first $count columns and return a hash of hashes with a depth 
of $count keys.

The only way I can think to do it so far is something like this :

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

while (@t=$query->fetchrow_array())
{

if      (@t == 1)
{       $hash{$t[0]}=''; }
elsif   (@t == 2)
{       $hash{$t[0]}{$t[1]}='';}
elsif   (@t == 3)
{       $hash{$t[0]}{$t[1]}{$t[2]}='';}
elsif   (@t == 4)
{       $hash{$t[0]}{$t[1]}{$t[2]}{$t[3]}='';}
elsif   (@t == 5)
{       $hash{$t[0]}{$t[1]}{$t[2]}{$t[3]}{$t[4]}='';}
elsif   (@t == 6)
{       $hash{$t[0]}{$t[1]}{$t[2]}{$t[3]}{$t[4]}{$t[5]}='';}

}

return(\%hash);

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

There has to be a more elegant solution than this surely.. Can anyone 
point me in the right direction please ?

Cheers,
Allan.


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

Date: Tue, 12 Jul 2005 15:39:59 +0200
From: "Peter.Kramer" <Peter.Kramer@gmx.de>
Subject: DBI and fetchhasref
Message-Id: <42d3c82f$0$18018$9b4e6d93@newsread4.arcor-online.net>

hi there
I'm wondering why I cant get all resulst in my hasref in this statement:


--
select   r.resourcesize, a.samaccountname

   from aduser a
   (
    select * from resourcesize
    where ts = (select max(ts) from resourcesize where server = 'xyz')
   )  r

   where a.samaccountname = r.samaccountname(+)
----

What I get is an hasref and all data from table "a" and all fields of table 
"r" but no data of table "r".
I assume, that the sub select is the problem.

result:
$hash->{SAMACCOUNTNAME} = "tiger"
$hash->{RESOURCESIZE} = ""

When I execute the script in SQL Plus all Data is availible!

$hash->{SAMACCOUNTNAME} = "tiger"
$hash->{RESOURCESIZE} = "1234"

I'm using Active State Perl 5.8.4 with DBD-Oracle and Oracle 9i 




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

Date: Tue, 12 Jul 2005 11:57:02 -0700
From: "lynn" <lynn.watts@ugs.com>
Subject: Generating a HoH without duplicate code
Message-Id: <42d418ab$1@usenet.ugs.com>

Hi All,

I am tring to generate a HoH's without using duplicate code. (see script)
Can someone help me do the same thing without the duplicate code :-)

Thanks!!

Lynn


use strict;
use warnings;
use Data::Dumper;

my %product = ();

while (<DATA>) {
    my ( $family, $hour ) = split(/,/);

    for ($family) {
        if (/NX/) {
            $product{'NX'}{'hour'} += $hour;
            $product{'NX'}{'count'}++;
        }    # do something
        elsif (/UNIGRAPHICS_NX/) {
            $product{'NX'}{'hour'} += $hour;
            $product{'NX'}{'count'}++;
        }
        elsif (/TC_ENGR-IMAN/) {
            $product{$family}{'hour'} += $hour;
            $product{$family}{'count'}++;
        }
        elsif (/SOLID_EDGE/) {
            $product{$family}{'hour'} += $hour;
            $product{$family}{'count'}++;
        }
        elsif (/WEBTOOLS/) {
            $product{$family}{'hour'} += $hour;
            $product{$family}{'count'}++;
        }
        elsif (/TC_COMMUNITY/) {
            $product{$family}{'hour'} += $hour;
            $product{$family}{'count'}++;
        }
        else {
            $product{'OTHER'}{'hour'} += $hour;
            $product{'OTHER'}{'count'}++;
        }    # default
    }
}

print Dumper( \%product );

__DATA__
NX,4.098
UNIGRAPHICS_NX,2.009
WEBTOOLS,.98
TC_ENGR-IMAN,2.09
FEMAP,0.54
SOLID_EDGE,1.03
TC_COMMUNITY,9.02
FEMAP,.81
TC_ENG-META,1.07
NX,1.308
TC_ENGR-IMAN,4.39 




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

Date: 12 Jul 2005 19:37:26 GMT
From: xhoster@gmail.com
Subject: Re: Generating a HoH without duplicate code
Message-Id: <20050712153726.961$45@newsreader.com>

"lynn" <lynn.watts@ugs.com> wrote:
> Hi All,
>
> I am tring to generate a HoH's without using duplicate code. (see script)
> Can someone help me do the same thing without the duplicate code :-)
>
> Thanks!!
>
> Lynn
>
> use strict;
> use warnings;
> use Data::Dumper;
>
> my %product = ();
>
> while (<DATA>) {
>     my ( $family, $hour ) = split(/,/);
>
>     for ($family) {
>         if (/NX/) {
>             $product{'NX'}{'hour'} += $hour;
>             $product{'NX'}{'count'}++;
>         }    # do something
>         elsif (/UNIGRAPHICS_NX/) {
>             $product{'NX'}{'hour'} += $hour;
>             $product{'NX'}{'count'}++;
>         }

You can get rid of this elsif altogether.  If /NX/ doesn't match, then
/UNIGRAPHICS_NX/ isn't going to, either.

Or maybe you should be testing for equality rather than using regex?:
if ($_ eq 'NX') {



>         elsif (/TC_ENGR-IMAN/) {
>             $product{$family}{'hour'} += $hour;
>             $product{$family}{'count'}++;
>         }
>         elsif (/SOLID_EDGE/) {
>             $product{$family}{'hour'} += $hour;
>             $product{$family}{'count'}++;
>         }
>         elsif (/WEBTOOLS/) {
>             $product{$family}{'hour'} += $hour;
>             $product{$family}{'count'}++;
>         }
>         elsif (/TC_COMMUNITY/) {
>             $product{$family}{'hour'} += $hour;
>             $product{$family}{'count'}++;
>         }


Since these all do the same thing, just combine the conditions with OR into
one if condition.

elsif (/TC_ENGR-IMAN/ or /SOLID_Edge/ or /WEBTOOLS/ or /TC_COMM/) {
        $product{$family}{'hour'} += $hour;
        $product{$family}{'count'}++;
}



>         else {
>             $product{'OTHER'}{'hour'} += $hour;
>             $product{'OTHER'}{'count'}++;
>         }    # default
>     }
> }

Xho

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


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

Date: Tue, 12 Jul 2005 20:25:42 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Generating a HoH without duplicate code
Message-Id: <aHVAe.120878$9A2.58577@edtnps89>

lynn wrote:
> 
> I am tring to generate a HoH's without using duplicate code. (see script)
> Can someone help me do the same thing without the duplicate code :-)
> 
> 
> use strict;
> use warnings;
> use Data::Dumper;
> 
> my %product = ();
> 
> while (<DATA>) {
>     my ( $family, $hour ) = split(/,/);
> 
>     for ($family) {
>         if (/NX/) {
>             $product{'NX'}{'hour'} += $hour;
>             $product{'NX'}{'count'}++;
>         }    # do something
>         elsif (/UNIGRAPHICS_NX/) {
>             $product{'NX'}{'hour'} += $hour;
>             $product{'NX'}{'count'}++;
>         }
>         elsif (/TC_ENGR-IMAN/) {
>             $product{$family}{'hour'} += $hour;
>             $product{$family}{'count'}++;
>         }
>         elsif (/SOLID_EDGE/) {
>             $product{$family}{'hour'} += $hour;
>             $product{$family}{'count'}++;
>         }
>         elsif (/WEBTOOLS/) {
>             $product{$family}{'hour'} += $hour;
>             $product{$family}{'count'}++;
>         }
>         elsif (/TC_COMMUNITY/) {
>             $product{$family}{'hour'} += $hour;
>             $product{$family}{'count'}++;
>         }
>         else {
>             $product{'OTHER'}{'hour'} += $hour;
>             $product{'OTHER'}{'count'}++;
>         }    # default
>     }
> }
> 
> print Dumper( \%product );
> 
> __DATA__
> NX,4.098
> UNIGRAPHICS_NX,2.009
> WEBTOOLS,.98
> TC_ENGR-IMAN,2.09
> FEMAP,0.54
> SOLID_EDGE,1.03
> TC_COMMUNITY,9.02
> FEMAP,.81
> TC_ENG-META,1.07
> NX,1.308
> TC_ENGR-IMAN,4.39 

You could do it with a regular expression:

my %product;
while ( <DATA> ) {
     if ( 
/^(?:UNIGRAPHICS_)?(TC_COMMUNITY|WEBTOOLS|SOLID_EDGE|TC_ENGR-IMAN|NX)?(?:.*?),(.+)/ 
) {
         my $family = $1 || 'OTHER';
         $product{ $family }{ hour } += $2;
         $product{ $family }{ count }++;
         }
     }

print Dumper \%product;


Or with a hash:

my %valid = qw(
     TC_COMMUNITY   TC_COMMUNITY
     WEBTOOLS       WEBTOOLS
     SOLID_EDGE     SOLID_EDGE
     TC_ENGR-IMAN   TC_ENGR-IMAN
     UNIGRAPHICS_NX NX
     NX             NX
     );
my %product;
while ( <DATA> ) {
     my ( $family, $hour ) = split /,/;
     $family = $valid{ $family } || 'OTHER';
     $product{ $family }{ hour } += $hour;
     $product{ $family }{ count }++;
     }

print Dumper \%product;



John
-- 
use Perl;
program
fulfillment


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

Date: Tue, 12 Jul 2005 19:38:43 GMT
From: "Hank Oredson" <horedson@earthlink.net>
Subject: Re: Minor correction  July 11, 2005
Message-Id: <7%UAe.4148$BK1.174@newsread3.news.pas.earthlink.net>

"edgrsprj" <edgrsprj@ix.netcom.com> wrote in message 
news:upBAe.1915$oZ.930@newsread2.news.atl.earthlink.net...
> "edgrsprj" <edgrsprj@ix.netcom.com> wrote in message
> news:D7qAe.21003$eM6.9503@newsread3.news.atl.earthlink.net...
>> PROPOSED EARTHQUAKE FORECASTING
>> COMPUTER PROGRAM DEVELOPMENT EFFORT
>
>> it jumps strait to the display routine and uses the entered command to
> begin
>
> Should be the word "straight" instead of strait.


What observational data are used?
What are the sources of that observational data?
How are those sources accessed?
Is there a database to hold historical plus current data?
If so, is it centralized or distributed?

The project might be of interest if the data sources are
rich enough, complete enough, and current enough.

-- 

  ... Hank

http://home.earthlink.net/~horedson
http://home.earthlink.net/~w0rli




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

Date: Tue, 12 Jul 2005 18:49:40 GMT
From: "Shea Martin" <sheam@hb-studios.com>
Subject: Win32::Process->Create, can't get right syntax
Message-Id: <8hUAe.60179$Ph4.1777077@ursa-nb00s0.nbnet.nb.ca>

I have the following line in my code:

 Win32::Process->Create($proc, "C:\\WINDOWS\\system32\\notepad.exe",
           'nodepad text.txt', 1, DETACHED_PROCESS, "." );

It keeps generating the following error:

Usage: Win32::Process::Create(cP, appname, cmdline, inherit, flags, curdir) 
at D
:\my\path\test.pm line 535.


Any ideas?

Thanks,

~S 




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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 8245
***************************************


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