[22295] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4516 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 5 18:10:48 2003

Date: Wed, 5 Feb 2003 15:07:16 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 5 Feb 2003     Volume: 10 Number: 4516

Today's topics:
    Re: 16 bit application (Scott)
    Re: Bidirectional communication -- solution ok? [long,  <goldbb2@earthlink.net>
    Re: Build my own perl html help docs <fma@doe.carleton.ca>
    Re: Converting C code to perl but the results are not t <mothra@nowhereatall.com>
    Re: Crossposting (was: Fetchrow Question) <goldbb2@earthlink.net>
    Re: Fast de-tabify <GPatnude@adelphia.net>
    Re: Fast de-tabify <uri@stemsystems.com>
    Re: gSTLFilt/perl/g++ problem: regexp too big (SOLVED) <fma@doe.carleton.ca>
        Help with arrays and such, please. <iamdownloading@yahoo.com>
    Re: Help with arrays and such, please. <GPatnude@adelphia.net>
    Re: Help with arrays and such, please. <bkennedy@hmsonline.com>
    Re: Help with arrays and such, please. Andrew Lee
    Re: How do i use pidof <jengelh@linux01.gwdg.de>
    Re: How do you: 'make install PREFIX=somepath', and the <usenet@tinita.de>
        just installed ActivePerl5.8, then? (samphdauto)
    Re: just installed ActivePerl5.8, then? <kjetilsk.skotheim@usit.uio.no>
        Mod_perl - reading POST-content when Content-length is  <kjetilsk.skotheim@usit.uio.no>
        New (open source) multipattern list/replace tool: <LFDC@lfdc.com>
    Re: PERL + SQL <twhu@lucent.com>
        Q on Guttman-Rosler <kj345@lycos.com>
    Re: Q on Guttman-Rosler <uri@stemsystems.com>
    Re: Q on Guttman-Rosler <kj345@lycos.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 5 Feb 2003 13:07:05 -0800
From: myhvac@hotmail.com (Scott)
Subject: Re: 16 bit application
Message-Id: <35ff4733.0302051307.2476c258@posting.google.com>

"Ben Kennedy" <bkennedy@hmsonline.com> wrote in message news:<NDKdncDYUPraaaKjXTWcpQ@giganews.com>...
> "Scott" <myhvac@hotmail.com> wrote in message
> news:35ff4733.0302032056.5c32783@posting.google.com...
> > Can Perl interact with a 16 bit application?  I have a company where
> > their software is written in a visual basic 16 bit program and I want
> > to develop for them a html interface using Perl.
> 
> How does your 16 bit program interact with the outside world?  Perl can use
> the IPC::Open2 module to communicate with external processes via STDIN and
> STDOUT, if that is how your program chooses to communicate.
> 
> --Ben Kennedy

 ..Thanks for the Followup Ben,

   The software they have was written in VB is composed of several
different "modules".  Half of the modules are forms the other half are
solvers.  I have suggested that they replace the VB forms with perl
forms put the software on a server and allow remote access via a web
browser.  I wrote new forms in Perl and (not having access to their
source code) wrote new solvers in C to demonstrate how this would
work.  The problem that they pointed out was that their software was
16 bit and when the data gets passed back and forth it will get
truncated or corrupted is there a way to output with something like
IPC::Open2 as you suggested with 16 bit data and retrieve in a similar
way?  They are currently re writing all of their solvers in Java
because they found this as the only solution to their problem.


Scott..


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

Date: Wed, 05 Feb 2003 15:27:17 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Bidirectional communication -- solution ok? [long, nice ASCII chart  :-]
Message-Id: <3E4173A5.CC19D98F@earthlink.net>

Jörg Ziefle wrote:
[snip]

The code could be written much more simply.

use IPC::Open2;
sub do_bogo {
   my $data = shift;
   if( open(my($bogo), "-|") ) {
      return [<$bogo>];
   } else {
      open2( ">&STDOUT", my($realbogo), @BOGO );
      print $realbogo @$data;
      close $realbogo;
      exit;
   }
}

This code is no less robust than your code, but it is (imho) a bit
easier to read.

-- 
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
 landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"


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

Date: 5 Feb 2003 16:44:46 GMT
From: Shing-Fat Fred Ma <fma@doe.carleton.ca>
Subject: Re: Build my own perl html help docs
Message-Id: <3E413F78.5754BE95@doe.carleton.ca>



Helgi Briem wrote:
> On 4 Feb 2003 03:34:52 GMT, Shing-Fat Fred Ma
> <fma@doe.carleton.ca> wrote:
>
>>In your opinion, how self contained is an Active State
>>Perl?
>
> I don't know what that means.  It requires no other
> programs beyond the base OS, if that's what you mean.

I was concerned that the installation put files into
parts of the file tree without my knowing.  Thus
superseding other executables, or resource files.
Yes, my concern is somewhat vaguely defined.  But
I can give an example of what I mean.  I tried to
build gcc several times, and never got a build that
gave low enough test failures...I wanted to try
installing it anyway, just to see whether it works.
But I didn't quite know all the places that it puts
stuff, or even overwrites stuff, and the resulting
side effects.  So I never did.  So I'm wondering of
the ActivePerl installation puts files into its own
self contained directory tree.

A few more question, if you don't mind....is the
installation pretty robust and straightforward
for solaris 8 (sun box)?  I would be building my
own copy as nonroot.  Perl (no-name) takes 10MB
before building, and the instructions for solaris
show lots of stuff which I know will take time to
learn about, so it seems more a job for sysadmin
than a regular user.  I didn't do it, because of
time, it's not a matter of choice at all.

Fred



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

Date: Wed, 5 Feb 2003 08:19:52 -0800
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: Converting C code to perl but the results are not the same
Message-Id: <3e413859$1@usenet.ugs.com>


<ctcgag@hotmail.com> wrote in message
news:20030203164852.876$12@newsreader.com...
> "Mothra" <mothra@nowhereatall.com> wrote:
[snipped]

Hi Xho,
>
> If both arguments to a division are integers, C does an integer
> division, while Perl does a regular floating point divide.
>
>
> > And how to fix it?
>
> either use the int function in Perl wherever C is implicitly truncating,
> or use the "use integer;" module (pragma?) in your subroutine.
>
> Xho
>
This did the trick!!

Thanks Xho!!

Mothra




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

Date: Wed, 05 Feb 2003 13:54:09 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Crossposting (was: Fetchrow Question)
Message-Id: <3E415DD1.3344EAD3@earthlink.net>

Tintin wrote:
> mgarrish wrote:
[snip garbage[
> 
> Matt.  Matt.  So young and so much to learn.

They go together, don't they?

Young folks know little, but think they know everything.

Sadly, some old folks are the same.

-- 
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
 landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"


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

Date: Wed, 05 Feb 2003 19:35:59 GMT
From: "codeWarrior" <GPatnude@adelphia.net>
Subject: Re: Fast de-tabify
Message-Id: <zId0a.2475$jR3.1236523@news1.news.adelphia.net>


"Irving Kimura" <irving_kimura@lycos.com> wrote in message
news:b1osi1$l0l$1@reader1.panix.com...
>
>
> Is there a faster Perl code to "de-tabify" a long string than this?:
>
> $no_tabs =
>   join "\n",
>     map { s/([^\t]*)\t/$1 . (' ' x (8-(length($1)%8)))/eg; $_ }
>       split /\n/, $string_with_tabs;
>
> Thanks,
> -Irv
>

#! usr/local/bin/perll -X
$NOTABS = "0,\t1,\t2,\t3,\t4,\t5";
print "It's got tabs in it: $NOTABS\n";

$NOTABS =~ s/\t//gisx;

print "Where'd the tabs go ???:$NOTABS\n";
exit(0);







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

Date: Wed, 05 Feb 2003 19:53:10 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Fast de-tabify
Message-Id: <x765rymrmi.fsf@mail.sysarch.com>

>>>>> "c" == codeWarrior  <GPatnude@adelphia.net> writes:

  >> Is there a faster Perl code to "de-tabify" a long string than this?:
  >> 
  >> $no_tabs =
  >> join "\n",
  >> map { s/([^\t]*)\t/$1 . (' ' x (8-(length($1)%8)))/eg; $_ }
  >> split /\n/, $string_with_tabs;

  c> $NOTABS = "0,\t1,\t2,\t3,\t4,\t5";

  c> $NOTABS =~ s/\t//gisx;

why the i, s or x options? they don't do anything there.

and if you just want to remove tabs, tr/\t//d is much faster

  c> print "Where'd the tabs go ???:$NOTABS\n";

but the goal of the OP was not to delete tabs, but to expand them to
their equivilent spaces. that is the notion of de-tabifying. the output
has to read the same as if there were the original 8 column tabs in it.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class


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

Date: 5 Feb 2003 17:00:27 GMT
From: Shing-Fat Fred Ma <fma@doe.carleton.ca>
Subject: Re: gSTLFilt/perl/g++ problem: regexp too big (SOLVED)
Message-Id: <3E414323.9D3E322A@doe.carleton.ca>


Hi,

In case anyone is reading this thread, I'm
posting a solution.  The problem was that
Perl 5.004_04 keeps complaining about a
regexp being too big (solaris 8).  The application
was gSTLFilt.pl release 2.20, for use with gcc 2.x/3.x.  Specifically, using the Standard
Template Library (STL, a C++ template library) causes
unnecessarily complicated errors messages, which are
cleaned up by gSTLFilt.

Leor Zolman (who wrote the filter) provided the
following fix.  On line 261, change

     $idp = "(?:$id )?(?:$id )?(?:$id )?$id ?$p ?"; # one or more identifiers/keywords with perhaps some *'s after

to

     $idp = "(?:$id ){0,3}$id ?$p ?";    # one or more identifiers/keywords with perhaps some *'s after

That's it!

Thanks go Leor, who says that a new revision will
be available soon.

Fred

--
Fred Ma, fma@doe.carleton.ca
Carleton University, Dept. of Electronics
1125 Colonel By Drive, Ottawa, Ontario
Canada, K1S 5B6




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

Date: 5 Feb 2003 11:02:46 -0600
From: Perl Dude <iamdownloading@yahoo.com>
Subject: Help with arrays and such, please.
Message-Id: <3e4143b6_1@binarykiller.newsgroups.com>

I'm sure that the method I'm using is not the correct one.  I'm 
an "advanced newbie" when it comes to this stuff.

I'm parsing out my mail log, looking for attempted relays from 
spammers via the same IP so I can report them to the proper 
authorities.  The log file is chronological, so spammer A may 
have several hits per day interspersed with hits from spammers 
B, C, and D.

I'm currently parsing the log and obtaining three items... time, 
address, and relay.  

01:24 ispam@spam.com 123.123.123.123
01:26 uspam@spamsucks.com 0.0.0.0
01:30 hespams@toomuchspam.com 123.123.123.123
01:45 spam@dev.null 123.1.2.3

and so on.

For lack of experience and knowledge they are going into three 
seperate arrays; @Time, @Address, @Relay.

What I need to do is sort this so that as I pass through the 
array of hits, I get a report of times and spammers of each 
relay address.  

Spam attempts from 123.123.123.123:
   01:24 ispam@spam.com 
   01:30 hespams@toomuchspam.com 

Spam attempts from 0.0.0.0:
   01:26 uspam@spamsucks.com 

Spam attempts from 123.1.2.3:
   01:45 spam@dev.null

My problem is in running through the @Relay array and getting 
all instances of one relay out of it, then looping back through 
for the next.

Here's the code I'm using, which doesn't really work...

while ($#Relay > -1){
     $NewRelay = $CompareRelay;
     $CompareRelay = @Relay[0];
     unless ($CompareRelay eq $NewRelay) {
          print "\nRelay Attempts via $CompareRelay :\n";
          }
     $ShiftRelay = shift @Relay;
     $ShiftTime = shift @Time;
     $ShiftAddress = shift @Address;
     if ($CompareRelay eq $ShiftRelay){
          print SENDMAIL "\t$ShiftTime : $ShiftAddress\n";
          }else{
          push @Relay, ($ShiftRelay);
          push @Time, ($ShiftTime);
          push @Address, ($ShiftAddress);
          }    
     }

What is the best way to do this?  A hash?  I don't have any 
experiences with hashes (yet).  Or a three dimensional array?  I 
would think a 3D array would be best, but I can't figure out how 
to create it as I parse the log file, and then how to parse the 
array later on for the report.

Any comments and suggestions are VERY much appreciated.  TIA.


-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
   http://www.newsfeed.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----


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

Date: Wed, 05 Feb 2003 19:22:52 GMT
From: "codeWarrior" <GPatnude@adelphia.net>
Subject: Re: Help with arrays and such, please.
Message-Id: <gwd0a.2465$jR3.1233224@news1.news.adelphia.net>


"Perl Dude" <iamdownloading@yahoo.com> wrote in message
news:3e4143b6_1@binarykiller.newsgroups.com...
> I'm sure that the method I'm using is not the correct one.  I'm
> an "advanced newbie" when it comes to this stuff.
>
> I'm parsing out my mail log, looking for attempted relays from
> spammers via the same IP so I can report them to the proper
> authorities.  The log file is chronological, so spammer A may
> have several hits per day interspersed with hits from spammers
> B, C, and D.
>
> I'm currently parsing the log and obtaining three items... time,
> address, and relay.
>
> 01:24 ispam@spam.com 123.123.123.123
> 01:26 uspam@spamsucks.com 0.0.0.0
> 01:30 hespams@toomuchspam.com 123.123.123.123
> 01:45 spam@dev.null 123.1.2.3

A Hash --> You can pretty much ignore the time... It doesn't matter WHEN a
spammer did it... It's how many occurrences of spam from each IP Address
that you are after... ? Right ? With that said...

    foreach $LINE (@PARSEDLOG) { # I assume your "oparsed" log is an array
of the three columns...

        chomp $LINE;
        ($HTIME, $EMAIL, $IPADDR) = split (" ", $LINE); # SPLIT THE LINE ON
THE SINGLE SPACE BETWEEN...
        $SPAMMERS{$IPADDR}->{COUNT} += 1;

    }

    # foreach $IP (keys %SPAMMERS) { # NOT SORTED...
    foreach $IP (sort { $SPAMMERS{$a} cmp $SPAMMERS{$b} } keys %SPAMMERS) {

        print "$SPAMMERS{$IP}->{COUNT}\n"; # STDOUT -- REPLACE the \n with
<BR> if you are printing to a browser...

    }


>
> and so on.
>
> For lack of experience and knowledge they are going into three
> seperate arrays; @Time, @Address, @Relay.
>
> What I need to do is sort this so that as I pass through the
> array of hits, I get a report of times and spammers of each
> relay address.
>
> Spam attempts from 123.123.123.123:
>    01:24 ispam@spam.com
>    01:30 hespams@toomuchspam.com
>
> Spam attempts from 0.0.0.0:
>    01:26 uspam@spamsucks.com
>
> Spam attempts from 123.1.2.3:
>    01:45 spam@dev.null
>
> My problem is in running through the @Relay array and getting
> all instances of one relay out of it, then looping back through
> for the next.
>
> Here's the code I'm using, which doesn't really work...
>
> while ($#Relay > -1){
>      $NewRelay = $CompareRelay;
>      $CompareRelay = @Relay[0];
>      unless ($CompareRelay eq $NewRelay) {
>           print "\nRelay Attempts via $CompareRelay :\n";
>           }
>      $ShiftRelay = shift @Relay;
>      $ShiftTime = shift @Time;
>      $ShiftAddress = shift @Address;
>      if ($CompareRelay eq $ShiftRelay){
>           print SENDMAIL "\t$ShiftTime : $ShiftAddress\n";
>           }else{
>           push @Relay, ($ShiftRelay);
>           push @Time, ($ShiftTime);
>           push @Address, ($ShiftAddress);
>           }
>      }
>
> What is the best way to do this?  A hash?  I don't have any
> experiences with hashes (yet).  Or a three dimensional array?  I
> would think a 3D array would be best, but I can't figure out how
> to create it as I parse the log file, and then how to parse the
> array later on for the report.
>
> Any comments and suggestions are VERY much appreciated.  TIA.
>
>
> -----------== Posted via Newsfeed.Com - Uncensored Usenet News
==----------
>    http://www.newsfeed.com       The #1 Newsgroup Service in the World!
> -----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers
=-----




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

Date: Wed, 5 Feb 2003 14:26:52 -0500
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: Help with arrays and such, please.
Message-Id: <7zadncyTxuh2-NyjXTWcow@giganews.com>


"Perl Dude" <iamdownloading@yahoo.com> wrote in message
news:3e4143b6_1@binarykiller.newsgroups.com...

> For lack of experience and knowledge they are going into three
> seperate arrays; @Time, @Address, @Relay.
>
> What I need to do is sort this so that as I pass through the
> array of hits, I get a report of times and spammers of each
> relay address.
>
> ...
>
> What is the best way to do this?  A hash?  I don't have any
> experiences with hashes (yet).  Or a three dimensional array?

You should definitely investigate hashes which are an essential Perl data
structure (perldoc perldata).  Hashes should form the basis of any
datastucture that relates things to arbitrary keys, in this case IP
addresses.  Then look into references (perldoc perlref) which, when combined
with hashes, will create the multi-dimensional data structure you are
looking for.  There is also helpful information about creating and
traversing complex data structures in "perldoc perldsc" and "perldoc
perllol".  Good luck!

--Ben Kennedy




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

Date: Wed, 05 Feb 2003 14:56:29 -0500
From: Andrew Lee
Subject: Re: Help with arrays and such, please.
Message-Id: <ogo24v4smk7nlkp4g0anvhn90gaq6bbc4e@4ax.com>

On 5 Feb 2003 11:02:46 -0600, Perl Dude <iamdownloading@yahoo.com>
wrote:

>I'm sure that the method I'm using is not the correct one.  I'm 
>an "advanced newbie" when it comes to this stuff.

Please don't post to comp.lang.perl -- it is a dead newsgroup.

>
>I'm parsing out my mail log, looking for attempted relays from 
>spammers via the same IP so I can report them to the proper 
>authorities.  The log file is chronological, so spammer A may 
>have several hits per day interspersed with hits from spammers 
>B, C, and D.
>
>I'm currently parsing the log and obtaining three items... time, 
>address, and relay.  
>
>01:24 ispam@spam.com 123.123.123.123
>01:26 uspam@spamsucks.com 0.0.0.0
>01:30 hespams@toomuchspam.com 123.123.123.123
>01:45 spam@dev.null 123.1.2.3
>
>and so on.
>
>For lack of experience and knowledge they are going into three 
>seperate arrays; @Time, @Address, @Relay.

Your guess (below) is on par with what I might try -- a hash (keyed on
IP) of arrays (the data associated to that IP).  See my code below.

>
>What I need to do is sort this so that as I pass through the 
>array of hits, I get a report of times and spammers of each 
>relay address.  
>
>Spam attempts from 123.123.123.123:
>   01:24 ispam@spam.com 
>   01:30 hespams@toomuchspam.com 
>
>Spam attempts from 0.0.0.0:
>   01:26 uspam@spamsucks.com 
>
>Spam attempts from 123.1.2.3:
>   01:45 spam@dev.null

So you are keying on IP addresses.  How much spam is in your mail log?
These data structures might get huge.

>
>My problem is in running through the @Relay array and getting 
>all instances of one relay out of it, then looping back through 
>for the next.

>
>Here's the code I'm using, which doesn't really work...
>
>while ($#Relay > -1){
You don't need this ... if you want to loop over an array just say :

foreach my $elem (@Relay) {

Perl does the work for you.

>     $NewRelay = $CompareRelay;

you should use strict and warnings -- they will save you endless
headaches.

>     $CompareRelay = @Relay[0];
>     unless ($CompareRelay eq $NewRelay) {
>          print "\nRelay Attempts via $CompareRelay :\n";
>          }
>     $ShiftRelay = shift @Relay;
>     $ShiftTime = shift @Time;
>     $ShiftAddress = shift @Address;

This is the problem with parallel arrays ... Not all the arrays are
always going to have the same number of elements.
 
>     if ($CompareRelay eq $ShiftRelay){
>          print SENDMAIL "\t$ShiftTime : $ShiftAddress\n";
>          }else{
>          push @Relay, ($ShiftRelay);
>          push @Time, ($ShiftTime);
>          push @Address, ($ShiftAddress);
>          }    
>     }
>

I'm not sure why you are saving the data back onto the arrays?


>What is the best way to do this?  A hash?  I don't have any 
>experiences with hashes (yet).  Or a three dimensional array?  I 
>would think a 3D array would be best, but I can't figure out how 
>to create it as I parse the log file, and then how to parse the 
>array later on for the report.
>
>Any comments and suggestions are VERY much appreciated.  TIA.

Take a look at the following :

#!/usr/bin/perl -w
use strict;
open FH, "<spam.log" or die $!; # or whatever the logfile is called
my %ip_addrs;
while (my $line = <FH>) {
    my ($hhmm, $relay, $ip_addr) = split /\s+/, $line;
    push @{ $ip_addrs{$ip_addr} }, ($hhmm, $relay);
}
use Data::Dumper;
print Dumper(%ip_addrs);
__END__

This is very vanilla but shows the power of hashes over arrays for this
type of problem.  Each element of the hash is an array (actually a list)
of the times and relays associated to an IP address. 

e.g.

$ip_addrs{'123.123.123.123'} holds 
'01:24',
'ispam@spam.com',
'01:30',
'hespams@toomuchspam.com'

You can also create a hash using the relays as keys and setting the time
and IP address as values associated to that key.

HTH


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

Date: Wed, 5 Feb 2003 19:32:55 +0100
From: Jan Engelhardt <jengelh@linux01.gwdg.de>
Subject: Re: How do i use pidof
Message-Id: <Pine.LNX.4.33.0302051930480.16626-100000@linux01.gwdg.de>

>I am trying to test for the presence of a PID for a program.
>If it is nit running, then start it
>How would I do this ?
>
>#!/usr/bin/perl
>@andy = `pidof xastir`;
>if (xxxxxxxxxx)

Under Linux and similar (not Win32 ugh) you can do the following:

  $existant = `ps -h $pid` ne "";

(-h strips the "  PID TTY      STAT   TIME
COMMAND" header, which is normally returned in any case.)



- Jan Engelhardt



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

Date: 5 Feb 2003 17:52:03 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: How do you: 'make install PREFIX=somepath', and then platform-independantly find somepath?
Message-Id: <tinh9ukj8$1hy$tina@news01.tinita.de>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> Asfand yar Qazi  <f_ker@yahoo.co.uk_NO_SPAM> wrote in comp.lang.perl.misc:

>> my $stem = $Config{sitelib_stem};
>> my $prefix = $Config{prefix};
>> $stem =~ m!($prefix)(.+)!;
>> print $2;
>> __END__
>> 

> Ah, so the elusive quantity is $Config{ sitelib_stem}.

> The above could also be written

>     my ( $x) = $Config{ sitelib_stem} =~ /^\Q$Config{ prefix}\E(.+)/;
>     print $x;

very nice, this is useful for my recent problem, too.
i *knew* there had to be something in %Config.
but wait, i tried this with 5.005_03, and there $Config{sitelib_stem}
doesn't exist. i would end up with the empty string, but
a test shows that the installed module resides
under $MODPATH/lib/perl5/site_perl/5.005/i586-linux/.
but if it's reliable for all versions >= 5.6.0 that would
be sufficient for my case, i guess.

regards, tina

-- 
http://www.tinita.de/        \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/      \     / _` / _ \/ _ \ '_(_-< of
http://PerlQuotes.tinita.de/   \    \ _,_\ __/\ __/_| /__/ perception


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

Date: 5 Feb 2003 12:53:51 -0800
From: samj@eisa.net.au (samphdauto)
Subject: just installed ActivePerl5.8, then?
Message-Id: <65050d4c.0302051253.466e4f1d@posting.google.com>

Hello
I just installed this ActivePerl 5.8, then Start|Programs|ActiveState
ActivePerl5.8 | Perl Package Manager which opened a C:/ prompt window
under W2K with the command line ppm>

what am I doing?
where am I going? 
why am I doing what I am doing?
where is every body?
the documnetations is not that friendly either in answering those
questins.
any body can tell me what is going on & what will happen next...
thanks

Sam


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

Date: Wed, 05 Feb 2003 21:21:35 GMT
From: Kjetil Skotheim <kjetilsk.skotheim@usit.uio.no>
Subject: Re: just installed ActivePerl5.8, then?
Message-Id: <1104_1044480095@nntp.uio.no>

5 Feb 2003 12:53:51 -0800, skrev samj@eisa.net.au (samphdauto):
> Hello
> I just installed this ActivePerl 5.8, then Start|Programs|ActiveState
> ActivePerl5.8 | Perl Package Manager which opened a C:/ prompt window
> under W2K with the command line ppm>
> 
> what am I doing?

U've just opened the Perl Package Manager interactive command tool.

> where am I going? 

To the ActiveState module library at:
http://ppm.activestate.com/PPMPackages/

> why am I doing what I am doing?

When you install Perl you get lots of modules (or packages as they'r
also called). But sometimes you need more. I could for instance
recomend HTML::Template is you're creating web applications.
Install that by typing 'install HTML::Template' after the PPM> prompt.
PPM is almost the same as 'perl -MCPAN -e shell' on a un*x-box.
The help command and reading C:\Perl\html\index.html should tell U more.

> where is every body?

dunno

> the documnetations is not that friendly either in answering those
> questins.
> any body can tell me what is going on & what will happen next...
> thanks
> 
> Sam





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

Date: Wed, 05 Feb 2003 21:09:54 GMT
From: Kjetil Skotheim <kjetilsk.skotheim@usit.uio.no>
Subject: Mod_perl - reading POST-content when Content-length is missing
Message-Id: <1103_1044479394@nntp.uio.no>


Mod_perl - reading POST-content when Content-length is missing

It may seem at bit odd that the client for our file-receiving-
server is not able to send the Content-length header field
 but thats the case. The client instead sends a 'size'-field
in the query string. (The client is also unable to post
content-type application/multiform). My server now use this:


use Apache::Constants qw(:response :http);
sub handler 
{ 
  my $r=shift; 
  my %R=$r->args();
  if(      $R{'size'}
       and not $r->header_in('Content-length')
       and $r->is_initial_req())
  {
    $r->header_in('Content-length',$R{'size'});
    $r->internal_redirect_handler("/receiver?".$r->args());
    return REDIRECT;
  }
  .
  .
  handling...
  my $size=$R{'size'} || $r->header_in('Content-length');
  $r->read($buffer,$size)
  .
  .
  return OK
}

The only difference between sending a content-length header field
and a query string field 'size' is that the latter hangs the connection
until the timout specified in httpd.conf happens. Otherwise the response
and results are the same.

I dont want the client to wait this long, but I also dont want to
reduce the Timeout setting. (And I can't change the agreed upon protocol).

Are there anything I should try in the above code?






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

Date: Wed, 5 Feb 2003 19:50:42 +0200
From: "LFDC" <LFDC@lfdc.com>
Subject: New (open source) multipattern list/replace tool:
Message-Id: <b1ri59$5ja$1@isokari.icl.fi>

For your interest:
Searches, list or replaces huge amount of patterns in one time. It is also
possible to give some formatting and validation parameters. May work fine
with Perl on occasions where huge number of patterns have to be searched and
then processed into more complex Perl regexps. GPL + fully open source
'basic library'.
www.repgrep.com




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

Date: Wed, 5 Feb 2003 13:13:57 -0500
From: "Tulan W. Hu" <twhu@lucent.com>
Subject: Re: PERL + SQL
Message-Id: <b1rk9e$qe4@netnews.proxy.lucent.com>


"fredduc" <fredduc@hotmail.com> wrote in message
> I want run an APACHE web server (no problem so far), but now I want to
> make it able to run ASP. Is it correct I need mod_perl-2.0 for it?
>
> And second question: I use a lot of (shame on me) MS Access databases.
> Is this Perl compatible with MS-SQL? Because I do have too much
> ASP-pages based on MS-SQL and NOT MySQL...

Apache::ASP module works with mod_perl




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

Date: Wed, 5 Feb 2003 18:52:08 +0000 (UTC)
From: kj <kj345@lycos.com>
Subject: Q on Guttman-Rosler
Message-Id: <b1rmgo$llk$1@reader1.panix.com>



I want to sort an array of records.  The records are strings
consisting of tab-delimited fields.  The field I want to sort by
represents a float (in ASCII).  Furthermore, the first field
represents the record's (1-based) position in the array.  Therefore,
after sorting the array, I must update the value of the first field
in each record.

Currently, I do something like:

  my $i = 1;
  @sorted_records =
    map { $_->[0] = $i++; join "\t", @$_ }
      sort { $b->[5] <=> $a->[5] }
        map [ split /\t/, $_ ], @records;

but I would like to use the Guttman-Rosler Transform (packed-default
sort) instead.

It seems to me that the best way to extract the sort field, and to
update the position field afterwards, is to first transform the
record into an anonymous array (as I do above).  The problem is
that I don't know how to turn this anonymous array into a payload
suitable for the packed-default sort, and how to append it to the
packed key.  Any help would be much appreciated.

TIA,

KJ



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

Date: Wed, 05 Feb 2003 19:48:37 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Q on Guttman-Rosler
Message-Id: <x7d6m6mru3.fsf@mail.sysarch.com>

>>>>> "k" == kj  <kj345@lycos.com> writes:

  k> I want to sort an array of records.  The records are strings
  k> consisting of tab-delimited fields.  The field I want to sort by
  k> represents a float (in ASCII).  Furthermore, the first field
  k> represents the record's (1-based) position in the array.  Therefore,
  k> after sorting the array, I must update the value of the first field
  k> in each record.

  k> Currently, I do something like:

  k>   my $i = 1;
  k>   @sorted_records =
  k>     map { $_->[0] = $i++; join "\t", @$_ }
  k>       sort { $b->[5] <=> $a->[5] }
  k>         map [ split /\t/, $_ ], @records;

  k> but I would like to use the Guttman-Rosler Transform (packed-default
  k> sort) instead.

  k> It seems to me that the best way to extract the sort field, and to
  k> update the position field afterwards, is to first transform the
  k> record into an anonymous array (as I do above).  The problem is
  k> that I don't know how to turn this anonymous array into a payload
  k> suitable for the packed-default sort, and how to append it to the
  k> packed key.  Any help would be much appreciated.

since you need to change a field later, why not keep the split records
around and just sort on their floats with their index numbers as the
payload.

the paper at http://sysarch.com/perl/sort_paper.html shows how to do a
packed sort (either endian) for a float. just append the index number
and that will be used to reorder the input records to output
records. and you can then add the updated index number (similar to what
you do above.

this is rough (untested) code for how i would do it. it could be
converted to the tighter map/sort/map if desired but it is fairly
complex so i would keep it this way.


# this was copied from the sort paper. it could be improved to assign
# into the symbol table one of two different subs. it would make the
# endian test be purely compile time.

BEGIN {
  my $big_endian =
    pack('N', 1) eq
    pack('L', 1);
  sub double_sort ($) {
    ($big_endian ?
      pack 'd', $_[0] :
      reverse pack 'd', $_[0]) ^
      ($_[0] < 0 ? "\xFF" x 8 :
          "\x80" . "\x00" x 7)
  }
}

# untested but should work and be faster than the above:

BEGIN {
  no strict 'refs' ; 

  *{'double_sort'} = pack('N', 1) eq pack('L', 1) ?
		sub ($) { pack 'd', $_[0] ^
				($_[0] < 0 ?
					"\xFF" x 8 : "\x80" . "\x00" x 7)
		} :
		sub ($) {
			reverse pack 'd', $_[0] ^
				($_[0] < 0 ?
					"\xFF" x 8 : "\x80" . "\x00" x 7)
		} ;
   }


# this just splits the records into a LoL

my @pre_sort_records = map [ split /\t/ ], @records ;

# this creates a packed sort key based on the float with the index for payload

my @sort_output = sort map double_sort( $_->[5] ) . $_->[0], @pre_sort_records ;

# this gets the sorted indices and uses them to to index into the
# pre-sorted records. it then assigns the new index number and makes a
# tabbed record out of it.

my $i ;
my @post_sort_records = map {

		my $row = $pre_sort_records[ $_ ] ;
		$row->[0] = ++$i ;
		join "\t", @{$row}

	} map substr( $_, 8 ), @sort_output ;




 



-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class


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

Date: Wed, 5 Feb 2003 20:56:48 +0000 (UTC)
From: kj <kj345@lycos.com>
Subject: Re: Q on Guttman-Rosler
Message-Id: <b1rtqg$o94$1@reader1.panix.com>

In <x7d6m6mru3.fsf@mail.sysarch.com> Uri Guttman <uri@stemsystems.com> writes:

<snip>

>since you need to change a field later, why not keep the split records
>around and just sort on their floats with their index numbers as the
>payload.

That's the way to go.  Thanks!

kj



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

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


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