[24990] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7240 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 13 14:06:57 2004

Date: Wed, 13 Oct 2004 11: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           Wed, 13 Oct 2004     Volume: 10 Number: 7240

Today's topics:
        [newbie] shtml question <dontmesswithme@got.it>
    Re: [newbie] shtml question <mritty@gmail.com>
    Re: [newbie] shtml question <nospam@bigpond.com>
    Re: [newbie] shtml question <dontmesswithme@got.it>
    Re: [newbie] shtml question <mritty@gmail.com>
    Re: building anonymous arrays and adding reference to m (wana)
        Concatenating an array into one string? <a@a.com>
    Re: Concatenating an array into one string? <mritty@gmail.com>
    Re: Concatenating an array into one string? <sbryce@scottbryce.com>
    Re: Concatenating an array into one string? <usa1@llenroc.ude.invalid>
    Re: Concatenating an array into one string? <sbryce@scottbryce.com>
    Re: Concatenating an array into one string? <jurgenex@hotmail.com>
    Re: Concatenating an array into one string? <autismuk@autismuk.muralichucks.freeserve.co.uk>
    Re: Concatenating an array into one string? <jurgenex@hotmail.com>
    Re: Concatenating an array into one string? <jurgenex@hotmail.com>
    Re: Concatenating an array into one string? <mritty@gmail.com>
    Re: Concatenating an array into one string? <shawn.corey@sympatico.ca>
    Re: getting telnet banner (krakle)
    Re: Help!  Sendmail on Mac OS X Server <usa1@llenroc.ude.invalid>
    Re: Lagrange Interpolating Polynomial <bik.mido@tiscalinet.it>
    Re: Lagrange Interpolating Polynomial <goofy_headed_punk@msn.com>
    Re: Lagrange Interpolating Polynomial (Anno Siegel)
    Re: One liner to produce string of n '?'s separated by  <tadmc@augustmail.com>
    Re: One liner to produce string of n '?'s separated by  <richard@zync.co.uk>
    Re: One liner to produce string of n '?'s separated by  <mritty@gmail.com>
        Perl to monitor server stats <mirak63@carolina.rr.com>
    Re: Perl to monitor server stats <tadmc@augustmail.com>
    Re: Perl to monitor server stats <mirak63@carolina.rr.com>
    Re: Perls system() call fails in a cgi-file running on  (Mr. Zeus)
    Re: Perls system() call fails in a cgi-file running on  (Malcolm Dew-Jones)
        Q re sysopen() and more... <bik.mido@tiscalinet.it>
    Re: Range lookup <tadmc@augustmail.com>
    Re: String and Array Programming in Perl <dwall@fastmail.fm>
    Re: Using a variable size with the repetition quantifie (Philippe Aymer)
    Re: Using a variable size with the repetition quantifie (Philippe Aymer)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 13 Oct 2004 14:21:11 GMT
From: Larry <dontmesswithme@got.it>
Subject: [newbie] shtml question
Message-Id: <dontmesswithme-12FA99.16174413102004@twister1.tin.it>

Hi folks!

Maybe this has been covered before but I didn'd find anything helpful on 
google.
I've a  .shtml?k=1000 kind of page,here's the code:

--
<html>
 <!-- #exec cgi="www.yousite.com/cgi-bin/page.cgi" -->
</html>
--

Now, I'd like to pass the "k" value to "page.cgi" (before .shtml page 
being parsed by the server)

Can It actually be done? (If not,I'll be in a mess!!!)


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

Date: Wed, 13 Oct 2004 14:39:20 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: [newbie] shtml question
Message-Id: <s6bbd.10$v_6.6@trndny04>

"Larry" <dontmesswithme@got.it> wrote in message
news:dontmesswithme-12FA99.16174413102004@twister1.tin.it...
> Hi folks!
>
> Maybe this has been covered before but I didn'd find anything helpful
on
> google.
> I've a  .shtml?k=1000 kind of page,here's the code:
> --
> <html>
>  <!-- #exec cgi="www.yousite.com/cgi-bin/page.cgi" -->
> </html>
> --
>
> Now, I'd like to pass the "k" value to "page.cgi" (before .shtml page
> being parsed by the server)
>
> Can It actually be done? (If not,I'll be in a mess!!!)

Your question is not about Perl.  Your question is about Server Side
Includes and Web Servers.  You can determine if this question is about
Perl by asking yourself "Would anything about this question change if my
cgi program were written in C instead of Perl?".  The answer here is No.
Learning how to partition your problem is an important first step in
solving your problem.

Paul Lalli

P.S. Despite myself, your question made me curious.  Browsing for about
20 seconds at Apache's documentation returned this page, that will
probably help you: http://httpd.apache.org/docs/mod/mod_include.html





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

Date: Thu, 14 Oct 2004 01:34:11 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: [newbie] shtml question
Message-Id: <2t507nF1rat4uU1@uni-berlin.de>

Larry wrote:

> Hi folks!
> 
> Maybe this has been covered before but I didn'd find anything helpful on
> google.
> I've a  .shtml?k=1000 kind of page,here's the code:
> 
> --
> <html>
>  <!-- #exec cgi="www.yousite.com/cgi-bin/page.cgi" -->
> </html>
> --
> 
> Now, I'd like to pass the "k" value to "page.cgi" (before .shtml page
> being parsed by the server)
> 
> Can It actually be done? (If not,I'll be in a mess!!!)

Mixing server side includes & cgi can be fraught with danger. Try html
templates instead. 
http://search.cpan.org/~samtregar/HTML-Template-2.7/Template.pm

You might be able to pass a variable by ...page.cgi?k=1000 but I dont have a
clue how this interacts with ssi.

gtoomey


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

Date: Wed, 13 Oct 2004 17:43:36 GMT
From: Larry <dontmesswithme@got.it>
Subject: Re: [newbie] shtml question
Message-Id: <dontmesswithme-FEC453.19401013102004@twister2.tin.it>

In article <2t507nF1rat4uU1@uni-berlin.de>,
 Gregory Toomey <nospam@bigpond.com> wrote:


> 
> Mixing server side includes & cgi can be fraught with danger. Try html
> templates instead. 
> http://search.cpan.org/~samtregar/HTML-Template-2.7/Template.pm
> 
> You might be able to pass a variable by ...page.cgi?k=1000 but I dont have a
> clue how this interacts with ssi.
> 
> gtoomey

Well, I know what you're talking about.

But I badly need to sort this problem out!!!

so forget about TEMPLATE...i need to pass a query string to my cgi script
 ...


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

Date: Wed, 13 Oct 2004 18:00:40 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: [newbie] shtml question
Message-Id: <c3ebd.69$OK1.31@trndny06>

"Larry" <dontmesswithme@got.it> wrote in message
news:dontmesswithme-FEC453.19401013102004@twister2.tin.it...
> In article <2t507nF1rat4uU1@uni-berlin.de>,
>  Gregory Toomey <nospam@bigpond.com> wrote:
>
> But I badly need to sort this problem out!!!
>
> so forget about TEMPLATE...i need to pass a query string to my cgi
script
> ...

Apparently you don't need to sort it out badly enough to read the
documentation I sent in my previous post.

Paul Lalli




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

Date: 13 Oct 2004 07:35:30 -0700
From: ioneabu@yahoo.com (wana)
Subject: Re: building anonymous arrays and adding reference to main array
Message-Id: <bf0b47ca.0410130635.2a05dffc@posting.google.com>

> Anyhow your orginial problem is much more simply done...
> 
> my @array3;
> {
>     my @array2 = @array1;
>     push @array3, [ splice @array2, 0, 100 ] while @array2;
> }
> 
> Of course if you don't need to preserve @array1 then you can consume it 
> directly and do away with @array2.
> 
> If you look at previous threads asking substancially the same question 
> you'll see many other solutions using slices and map() but I think the 
> one using splice and while is the most elegant.

I am sorry to have asked a question that is answered so clearly in
Programming Perl.  I did a little reading after posting it and wished
I could retract my easily answered question.

On the other hand, I am glad that I did now because the splice thing
is really cool.  I have my book open now to p. 793 (3rd ed.
revised,updated).  I really have to read this book at least once and
probably 2,3 times before asking basic questions.  I need a time warp
to go into so I will have a few weeks to read and no real time will
have passed.

Thanks! 

wana


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

Date: Wed, 13 Oct 2004 15:53:19 +0100
From: "Rapier" <a@a.com>
Subject: Concatenating an array into one string?
Message-Id: <1097679208.554.0@nnrp-t71-02.news.clara.net>

Hi,
I have an array I want to concatenate into one string without \n's in the 
code below all I get in the output for jobcat is 1111 why? How do I correct 
this code?

$test[0] = "one\n";
$test[1] = "two\n";
$test[2] = "three\n";


$jobcat = "";
$i = 0;
foreach(@test)
{
$jobcat .= chomp($test[$i]);
$i++;
}

print ("jobcat=$jobcat\n");

Thanks in advance.




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

Date: Wed, 13 Oct 2004 15:11:59 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Concatenating an array into one string?
Message-Id: <3Bbbd.40$OK1.15@trndny06>

"Rapier" <a@a.com> wrote in message
news:1097679208.554.0@nnrp-t71-02.news.clara.net...
> Hi,
> I have an array I want to concatenate into one string without \n's in
the
> code below all I get in the output for jobcat is 1111 why?

Please read the documentation for the functions you use.
perldoc -f chomp
It does not return the chomp'ed string.

How do I correct
> this code?
>
> $test[0] = "one\n";
> $test[1] = "two\n";
> $test[2] = "three\n";
>
>
> $jobcat = "";
> $i = 0;
> foreach(@test)
> {
> $jobcat .= chomp($test[$i]);
> $i++;
> }

Why are you keeping a counter and also using a foreach-style loop?
Within that loop, each element of @test is assigned to $_.  There is no
need for $i at all.

This entire program can be written better as simply:

#!/usr/bin/perl
use strict;
use warnings;
my @test;
$test[0] = "one\n";
$test[1] = "two\n";
$test[2] = "three\n";
chomp @test;
my $jobcat = join '', @test;
print $jobcat;
#or instead of the above two lines, simply:
print @test;
__END__

Paul Lalli




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

Date: Wed, 13 Oct 2004 09:15:49 -0600
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: Concatenating an array into one string?
Message-Id: <10mqhl23d1uibdf@corp.supernews.com>

Rapier wrote:

> Hi,
> I have an array I want to concatenate into one string without \n's in the 
> code below all I get in the output for jobcat is 1111 why? How do I correct 
> this code?
> 
> $test[0] = "one\n";
> $test[1] = "two\n";
> $test[2] = "three\n";
> 
> 
> $jobcat = "";
> $i = 0;
> foreach(@test)
> {
> $jobcat .= chomp($test[$i]);
> $i++;
> }
> 
> print ("jobcat=$jobcat\n");

chomp returns the number of characters deleted.

-----------

use warnings;
use strict;

my @test;

$test[0] = "one\n";
$test[1] = "two\n";
$test[2] = "three\n";

my $jobcat = "";

foreach(@test)
{
      chomp;
      $jobcat .= $_;
}

print "jobcat = $jobcat\n";

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

use warnings;
use strict;

my @test;

$test[0] = "one\n";
$test[1] = "two\n";
$test[2] = "three\n";

my $jobcat = join '', @test;
$jobcat =~ s/\n//g;

print "$jobcat\n";



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

Date: 13 Oct 2004 15:18:03 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: Concatenating an array into one string?
Message-Id: <Xns9581733F3A3D5asu1cornelledu@132.236.56.8>

"Rapier" <a@a.com> wrote in
news:1097679208.554.0@nnrp-t71-02.news.clara.net: 

> I have an array I want to concatenate into one string without \n's in
> the code below all I get in the output for jobcat is 1111 why?

Sometimes I regain my faith in humanity ... Then I lose it again. 

> $jobcat .= chomp($test[$i]);

Read perldoc -f chomp and see what chomp returns.

Sinan.


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

Date: Wed, 13 Oct 2004 09:19:01 -0600
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: Concatenating an array into one string?
Message-Id: <10mqhr18268dq23@corp.supernews.com>

Paul Lalli wrote:

> chomp @test;

I've got the Camel book open right in front of me, and I missed that!

I should have known that if I posted code, someone would find a better 
way to do it!



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

Date: Wed, 13 Oct 2004 15:23:22 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Concatenating an array into one string?
Message-Id: <KLbbd.87$dI6.50@trnddc03>

Rapier wrote:
> Hi,
> I have an array I want to concatenate into one string without \n's in
> the code below all I get in the output for jobcat is 1111 why? How do
> I correct this code?

You are missing:

    use warnings; use strict;

> $test[0] = "one\n";
> $test[1] = "two\n";
> $test[2] = "three\n";

This is easier written as:

    my @test = ("one\n", "two\n", "three\n");

> $jobcat = "";

No need to initialize $jobcat, Perl does it automatically for you when you 
declare the variable:

    my $jobcat;

> $i = 0;
> foreach(@test)
> {
> $jobcat .= chomp($test[$i]);
> $i++;
> }

Ouch, this whole loop hurts!
- What do you need the $i for when you are looping through each element 
anyway?
- Why are you not using $_ but $test[$i]?
- why chomp() each element individually?
- why individually append the elements?

Just replace the whole mess with a simple

    $jobcat = join '', chomp @test;

> print ("jobcat=$jobcat\n");

Ok, that line seems to be fine.

jue






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

Date: Wed, 13 Oct 2004 16:25:16 +0100
From: Paul Robson <autismuk@autismuk.muralichucks.freeserve.co.uk>
Subject: Re: Concatenating an array into one string?
Message-Id: <pan.2004.10.13.15.25.15.591573@autismuk.muralichucks.freeserve.co.uk>

On Wed, 13 Oct 2004 15:53:19 +0100, Rapier wrote:

> Hi,
> I have an array I want to concatenate into one string without \n's in the 
> code below all I get in the output for jobcat is 1111 why? How do I correct 
> this code?
> 
> $test[0] = "one\n";
> $test[1] = "two\n";
> $test[2] = "three\n";
> 
> 
> $jobcat = "";
> $i = 0;
> foreach(@test)
> {	
> $jobcat .= chomp($test[$i]);
> $i++;
> }
> 
> print ("jobcat=$jobcat\n");
> 
> Thanks in advance.

The reason it doesn't work is chomp returns the number of characters
removed when "chomping" which is 1 (the \n character) - which is
"stringified" into "1" which is concatenated to $jobcat so you get
"111" - three 1's concatenated.

You could change your solution to write 

chomp($test[$i]);
$jobcat .= $test[$i];

But it's not a neat "Perl" solution. In Perl you do not need the
equivalent index variable. (the $i).

You can use $_  - just for (@test) will give you all the elements in order
in $_

To index iterate the array in order (not sure if for (@arr) guarantees
this ?) you can use for $my i (0..$#test) - $#test is the last index value
of array @test.

#
#	for all elements in @test chomp them. $_ becomes $test[0] through 2 
#
chomp for (@test);
#
#	Perls join function joins all the scalars together in a string 
#	the first parameter is the seperator - in this case the empty string. 
#
my $jobcat = join("",@test);



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

Date: Wed, 13 Oct 2004 15:27:29 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Concatenating an array into one string?
Message-Id: <BPbbd.89$dI6.22@trnddc03>

Jürgen Exner wrote:

Aaarrrggg

> Just replace the whole mess with a simple
>
>    $jobcat = join '', chomp @test;

Of course this needs to be

chomp @test;
$jobcat = join '', @test;

Thou shalt not 'improve' code after pasting it into your news reader.

jue 




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

Date: Wed, 13 Oct 2004 16:00:18 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Concatenating an array into one string?
Message-Id: <micbd.9$Kp6.0@trnddc08>

Paul Robson wrote:
> chomp($test[$i]);
> $jobcat .= $test[$i];
>
> But it's not a neat "Perl" solution.

Agree. A more perlish solution is

    chomp @test;
    $jobcat = join '', @test;

jue




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

Date: Wed, 13 Oct 2004 17:06:18 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Concatenating an array into one string?
Message-Id: <egdbd.109$Ud7.32@trndny01>

"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:KLbbd.87$dI6.50@trnddc03...
> Just replace the whole mess with a simple
>
>     $jobcat = join '', chomp @test;

This, of course, contains exactly the same error that the original did.
chomp does not return the modified strings.

Paul Lalli




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

Date: Wed, 13 Oct 2004 13:01:05 -0400
From: Shawn Corey <shawn.corey@sympatico.ca>
Subject: Re: Concatenating an array into one string?
Message-Id: <3adbd.32983$3C6.1313262@news20.bellglobal.com>

Jürgen Exner wrote:
>>$jobcat = "";
> 
> 
> No need to initialize $jobcat, Perl does it automatically for you when you 
> declare the variable:
> 
>     my $jobcat;

No it doesn't, notice the difference?
	--- Shawn

#!/usr/bin/perl

use strict;
use warnings;

my $not_initialized;
print "not initialized = $not_initialized\n";

my $initialized = '';
print "initialized = $initialized\n";

__END__


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

Date: 13 Oct 2004 09:28:14 -0700
From: krakle@visto.com (krakle)
Subject: Re: getting telnet banner
Message-Id: <237aaff8.0410130828.73662209@posting.google.com>

l v <lv@aol.com> wrote in message news:<41681305$1_4@127.0.0.1>...
> Zebee Johnstone wrote:
> > In comp.lang.perl.misc on Fri, 08 Oct 2004 22:43:28 -0500
> > l v <lv@aol.com> wrote:
> > 
> >>Try using Net::Telnet's getlines ......  untested snippet follows ...
> >>
> >>$t = new Net::Telnet (Timeout => $secs,
> >>                       Prompt => "/$serverName:.+/");
> >>$mode = $t->errmode('return');
> >>
> >>$t->open("$serverName.xxx.com");
> >>@lines = $t->getlines;
> >>$t->close;
> >>
> > 
> > 
> > As I said, Net::Telnet doesn't appear to return things till you log on.
> > 
> > This snippet times out and produces nothing.
> > 
> > Zebee
> 
> Well, well, well, a bit snippy aren't we.  I'm not sure then why I 
> wasted more time on *your* problem.  But I did....
> 

Well it did time out and produce nothing... So... :-)


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

Date: 13 Oct 2004 13:38:13 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: Help!  Sendmail on Mac OS X Server
Message-Id: <Xns9581625213A54asu1cornelledu@132.236.56.8>

"Michael Vilain <vilain@spamcop.net>" wrote in news:vilain-
844F91.02154213102004@comcast.dca.giganews.com:

> In article <Xns9580D6A74A2Dasu1cornelledu@132.236.56.8>,
>  "A. Sinan Unur" <usa1@llenroc.ude.invalid> wrote:
> 
>> "Michael Vilain <vilain@spamcop.net>" wrote in
>> news:vilain-55EBED.17552612102004@comcast.dca.giganews.com: 
>> 
>> > Unfortunately, my hosting company won't change their perl or php 
>> > configuration for me, so I'm stuck using what works. 
>> 
>> Not true.
>> 
>> perldoc -q lib
>> 

Please read below.

 ...

> These guys are cheaper, but they're in Lopoc, a 6-hour drive.  I asked 
> and they also won't install additional CPAN modules on their system.

Please read the FAQ that I mention above. :)

> With my current ISP, I get a UNIX sysadmin with 20+ years experience on 
> the 2nd ring most times between 7am-12am weekdays and 8am-10pm weekends. 
> They do backups daily and maintain a climate controlled computer center 
> with network monitoring.

That is great. But the main point of my post was not to recommend you a new  
ISP. Please read the answer to the FAQ I mentioned above.

Sinan.


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

Date: Wed, 13 Oct 2004 16:01:12 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Lagrange Interpolating Polynomial
Message-Id: <34dqm0d1v8pijnfpv53uhre5r7kuhdl7kk@4ax.com>

On 13 Oct 2004 07:36:19 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:

<OT>
>There *is* a Newtonian method (different from Lagrange's) for polynomial
>interpolation, but that doesn't seem to be what you are talking about.

Since we're taliking about mathematics now, by any chance do you
happen to be a relative to C.L. Siegel?

(I would have sent you an e-mail, but I don't know if you accept
unsolicited correspondence.)
</OT>


Michele
-- 
>It's because the universe was programmed in C++.
No, no, it was programmed in Forth.  See Genesis 1:12:
"And the earth brought Forth ..."
- Robert Israel in sci.math, thread "Why numbers?"


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

Date: Wed, 13 Oct 2004 10:29:59 -0500
From: Brian Troutwine <goofy_headed_punk@msn.com>
Subject: Re: Lagrange Interpolating Polynomial
Message-Id: <pan.2004.10.13.15.29.58.12339@msn.com>

On Tue, 12 Oct 2004 19:48:29 -0700, Bidek wrote:

> Brian,
>   Have you tries the Newton's method instead, here's a suggestion.

Thanks, but I'm not looking for roots, I'm fitting a curve to a set of
points. I've got my algorithm down, I'm just trying to speed things up a
bit (using BigRat really kills the time).

On the other hand, I'll probably end up writing more pattern finding
programs, and if I need roots, I'll give yours a shot.

Thanks again.


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

Date: 13 Oct 2004 16:26:30 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Lagrange Interpolating Polynomial
Message-Id: <ckjkvm$hrv$1@mamenchi.zrz.TU-Berlin.DE>

Michele Dondi  <bik.mido@tiscalinet.it> wrote in comp.lang.perl.misc:
> On 13 Oct 2004 07:36:19 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
> Siegel) wrote:
> 
> <OT>
> >There *is* a Newtonian method (different from Lagrange's) for polynomial
> >interpolation, but that doesn't seem to be what you are talking about.
> 
> Since we're taliking about mathematics now, by any chance do you
> happen to be a relative to C.L. Siegel?

No, I'm not.

Anno


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

Date: Wed, 13 Oct 2004 09:04:14 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: One liner to produce string of n '?'s separated by commas ... ?
Message-Id: <slrncmqdeu.37t.tadmc@magna.augustmail.com>

Richard Gration <richard@zync.co.uk> wrote:

> I can't think of anything shorter
> 
> 	$n = 10;
> 	$vals = join ',', split //,'?' x $n;


{  local $" = ',';
   $vals = "@{[ ('?') x $n ]}";
}


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


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

Date: Wed, 13 Oct 2004 16:54:40 +0100
From: "Richard Gration" <richard@zync.co.uk>
Subject: Re: One liner to produce string of n '?'s separated by commas ... ?
Message-Id: <ckjj40$8or$1@news.freedom2surf.net>

In article <ckj69c$4up$1@news.freedom2surf.net>, "Richard Gration"
<richard@zync.co.uk> wrote:


> Anyone for golf?
> I can't think of anything shorter
> 
> 	$n = 10;
> 	$vals = join ',', split //,'?' x $n;
> In case anyone was wondering, this _is_ SQL related ;-)

Such creativity :-)

I think I will use Paul's solution. Cheers all


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

Date: Wed, 13 Oct 2004 17:03:58 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: One liner to produce string of n '?'s separated by commas ... ?
Message-Id: <2edbd.108$Ud7.105@trndny01>

"Richard Gration" <richard@zync.co.uk> wrote in message
news:ckjj40$8or$1@news.freedom2surf.net...
> In article <ckj69c$4up$1@news.freedom2surf.net>, "Richard Gration"
> <richard@zync.co.uk> wrote:
>
>
> > Anyone for golf?
> > I can't think of anything shorter
> >
> > $n = 10;
> > $vals = join ',', split //,'?' x $n;
> > In case anyone was wondering, this _is_ SQL related ;-)
>
> Such creativity :-)
>
> I think I will use Paul's solution. Cheers all

Really?  Personally I like Tad's better...

Paul Lalli




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

Date: Wed, 13 Oct 2004 10:44:38 -0400
From: "KWall" <mirak63@carolina.rr.com>
Subject: Perl to monitor server stats
Message-Id: <YM6dncZr7NvKovDcRVn-rA@giganews.com>

Hello. Has anyone ever used PERL to monitor Windows server statistics? Is 
there a book or a place to start?

Thanks,
Kairm
karim.wall@acs-inc.com 




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

Date: Wed, 13 Oct 2004 09:54:10 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Perl to monitor server stats
Message-Id: <slrncmqgci.3eb.tadmc@magna.augustmail.com>

KWall <mirak63@carolina.rr.com> wrote:

> Has anyone ever used PERL 


Not that I know of, because I don't think there is a programming
language named "PERL".

There is one named "Perl". Is that what you meant to say?


> to monitor Windows server statistics?


What kind of server?

HTTP? SMTP? FTP? ...


If a "web server" then what kind of web server?

IIS?  Apache? ...


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


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

Date: Wed, 13 Oct 2004 11:15:18 -0400
From: "KWall" <mirak63@carolina.rr.com>
Subject: Re: Perl to monitor server stats
Message-Id: <bYudnSMsdvsU2_DcRVn-ug@giganews.com>

I'd like to be able to pull Windows server stats like those in Task Manager 
and push them into a database for reporting. CPU utilization, RAM in use, 
stuff like that. I can already pull hard disk stats but haven't seen any 
modules that Windows server stats.

KLW


"Tad McClellan" <tadmc@augustmail.com> wrote in message 
news:slrncmqgci.3eb.tadmc@magna.augustmail.com...
> KWall <mirak63@carolina.rr.com> wrote:
>
>> Has anyone ever used PERL
>
>
> Not that I know of, because I don't think there is a programming
> language named "PERL".
>
> There is one named "Perl". Is that what you meant to say?
>
>
>> to monitor Windows server statistics?
>
>
> What kind of server?
>
> HTTP? SMTP? FTP? ...
>
>
> If a "web server" then what kind of web server?
>
> IIS?  Apache? ...
>
>
> -- 
>    Tad McClellan                          SGML consulting
>    tadmc@augustmail.com                   Perl programming
>    Fort Worth, Texas 




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

Date: 13 Oct 2004 08:27:59 -0700
From: mister_x_sun@hotmail.com (Mr. Zeus)
Subject: Re: Perls system() call fails in a cgi-file running on win2k and apache
Message-Id: <e5b9e7c7.0410130727.4138d489@posting.google.com>

James Willmore <jwillmore@adelphia.net> wrote in message news:<QMudnafgOMguevbcRVn-oQ@adelphia.com>...
> Mr. Zeus wrote:
> > I am running a UseMod wiki and tried to implement some system calls
> > using the perl command system(@args). In my case it was a call of an
> > executable file.
> > Path to the file was fully given as well as the proper settings of
> > @args.
> > Independant of the function (dos-command or exe) I am calling it
> > doesn't work.
> > 
> > The system I am using is:
> > W2K SR2
> > apache 2.0.50 (win32)
> > Perl 5.8.4
> > 
> > Are there additional mods necessary in the apache config?
> > What to do exactly?
> > 
> > Thanks for your help
> > Zeus
> 
> You have provided no code, so we can't see *what* you're trying to do. 
> All we know for certain is that you have some issue with using 'system'.
> 
> Try *reading* the Perl documentation on using 'system' ("perldoc -f 
> system" on the command line -or- visit http://www.perldoc.com/ and 
> search for 'system').
> 
> HTH
> 
> Jim
Hello Jim,
sorry, I thought everything is given...

Here the code:

$TtH         = "\"c:/programme/apache
group/apache2/cgi-bin/tth.exe\"";
$mode = "";
@args = ($TtH, "-L -t -r -w0 $mode", "<tth_in.dat", ">tth_out.dat",
"2>tth_err.dat");
system(@args)== 0
  or die "system @args failed: $?";

Here the result:

system "c:/programme/apache group/apache2/cgi-bin/tth.exe" -L -t -r
-w0  <tth_in.dat >tth_out.dat 2>tth_err.dat failed: 256 at
C:\Programme\Apache Group\Apache2\cgi-bin\wikitth.pl line 3252.

The file tth_in.dat exists, tth_out.dat does not and is not generated.
Calling the exe at command-line exactly as given in the errormsg
works.

Hope this helps to understand the problem - need more info?
Zeus


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

Date: 13 Oct 2004 10:34:52 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Perls system() call fails in a cgi-file running on win2k and apache
Message-Id: <416d673c@news.victoria.tc.ca>

Mr. Zeus (mister_x_sun@hotmail.com) wrote:
: I am running a UseMod wiki 

(caveat: I don't know UseMod wiki)

:and tried to implement some system calls
: using the perl command system(@args). 

Some isp's disable the system command within perl.  (Perhaps they 
recompile perl to do this).

So I wonder, does the perl interpreter on your host support the system()  
call at all?


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

Date: Wed, 13 Oct 2004 16:01:14 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Q re sysopen() and more...
Message-Id: <htbqm01po15ph1lufrq3idaatdps83sp3f@4ax.com>

I apologize if the subject is not really appopriate to this post, but
I really couldn't think of a better one...

To come to the point, I have a process that (partially) daemonizes and
uses a mechanism to prevent having more than one instance running on
any given machine.

As of it is now, I must say that it has been working perfectly for
quite a while and I've not had any problem with it. Basically the key
code snippet is as follows:

  my $lockfile = "$lockdir/$pfx-$host";
  sysopen my $lock, $lockfile, O_CREAT | O_EXCL 
    or die "$0 already running on $host\n";
  my $havelock = 1;
  # ...

However (also) for learning purposes, I've been thinking of improving
it to cope with the unlikely possibility that a badly crashed machine
prevented my signal handlers or C<END> block to take care of lockfile
removal.

So the additional steps that I'm taking into account are:

(i) writing the pid of the running instance into the lockfile and
check for its existence,
(ii) once (i) is done, then also check that the process corresponding
to the stored pid corresponds to a program called like $0.

Now, the questions are: would (i) be a good idea? Would (ii) be a good
idea too?

Also, (and on a Perl-related basis, finally!) if the answers to the
above questions are positive, then when I open a file with sysopen(),
can/should I subsequently use the "standard" IO operators (i.e. those
I'd use with an open()ed file) and functions to read and write to it?

As for the point (ii) above, since the program is to be run on Linux
anyway, it would seem sensible to me to read the relevant info from
/proc myself (don't know if it could be doable under other UNICES): is
it recommended to use some module or ad hoc code instead?

Last, since I'm not much confident with this kind of programming,
could you please be so kind and post some explicit minimal code
snippet?


TIA,
Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Wed, 13 Oct 2004 09:29:58 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Range lookup
Message-Id: <slrncmqev6.37t.tadmc@magna.augustmail.com>

Yash <yashgt@yahoo.com> wrote:
> I have a set of ranges such as
><0.1%


It will be a bit easier if you normalize the range representation:

   0.0-0.1%


> 0.1-0.2%
> 0.2-0.3%


Errr, so which one of those ranges is 0.2 supposed to be in?


> and I have to identify the range that contains an input value such as
> 1.25. The above set of ranges is not fixed and is configurable in a
> text file.


---------------------------------------
#!/usr/bin/perl
use warnings;
use strict;

my @desc = <DATA>;
chomp @desc;
my @ranges = map { [ /([\d.]+)-([\d.]+)/ ] } @desc; # extract lo/hi

my $num = 1.25;
print "$num is in range $desc[ in_range($num) ]\n";

sub in_range {
   my($n) = @_;

   foreach my $i ( 0 .. $#ranges ) {
      return $i if $num >= $ranges[$i][0] and $num < $ranges[$i][1];
   }
   return -1;
}

__DATA__
0.0-0.1%
0.1-0.2%
0.2-0.3%
0.3-0.4%
0.4-0.5%
0.5-0.6%
0.6-0.7%
0.7-0.8%
0.8-0.9%
0.9-1.0%
1.0-1.5%
1.5-2.0%
2.0-2.5%
2.5-3.0%
3-20%
20-30%
30-40%
40-100%
---------------------------------------


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


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

Date: Wed, 13 Oct 2004 13:42:32 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: String and Array Programming in Perl
Message-Id: <Xns958162C3BE9BBdkwwashere@216.168.3.30>

Tad McClellan <tadmc@augustmail.com> wrote:

> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>> A. Sinan Unur <usa1@llenroc.ude.invalid> wrote in
>> comp.lang.perl.misc: 
>> 
>>> I think it was Tad who put it most eloquently: You can't just
>>> make s**t up and expect it to work!
>> 
>> I've always heard it attributed to MJD, though the quote as I
>> know it also contains the word "retardo".
> 
> 
> That's how I found the link I posted, I googled for "retardo
> perl". 
> 
>:-)

I remembered the phrase, "The error mesage is GOD", seeing a clip of 
MJD *screaming* it, and that he had posted his list of Good Advice to 
usenet. From the Google usenet archive:

http://groups.google.com/groups?selm=a6ukat%24a4b%241%40plover.com

"Of course it doesn't work!  That's because you don't know what you 
are doing!"

(Sounds like some of my programs.)


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

Date: 13 Oct 2004 06:40:34 -0700
From: aymerphilippe@hotmail.com (Philippe Aymer)
Subject: Re: Using a variable size with the repetition quantifier
Message-Id: <47971ff0.0410130540.54d10db5@posting.google.com>

Jeff 'japhy' Pinyan <pinyaj@rpi.edu> wrote in message news:<Pine.SOL.3.96.1041012152434.11683A-100000@vcmr-86.server.rpi.edu>...
> On 12 Oct 2004, Philippe Aymer wrote:
> 
> >Now, I still have a trouble. Because:
> >
> >/X(\d)((??{"\\w{$1}"}))/
> >
> >works, but in my string, I also have to match newline. So I did:
> >
> >/X(\d)(??{"\\w{$1}"})/s
> >
> >which doesn't work (seems to apply only to //, not things within
> >(?..)), then:
> 
> The /s modifier only affects the '.' metacharacter.  \w doesn't match \n.

oups... I should have written:

/X(\d)(??{".{$1}"})/s

that's what I'm using ("xyz" in my example coule be anything, even non
printable char).

> >/X(\d)(??{"[\\w\n]{$1}"})/
> >
> >which doesn't work neither... (?)
> 
> This should work:
> 
>   /X(\d)((??{ "[\\w\\n]{$1}" }))/

ok, I have trouble with my fingers... I'm using ".\\n", but no it's
not working.

So I try this program:

my $string = "DA3xyzB4ab\nc";

print "==>$string<==" . "\n\n";

if ($string =~ /
	D
	(
		A
		(\d)
		(?{ print "===>$2<===\n"; })
		( (??{ "[\\w\\n]{$2}" }) )
		(?{ print "===>$3<===\n"; })
	)
	(
		B
		(\d)
		(?{ print "===>$5<===\n"; })
		( (??{ "[\\w\\n]{$5}" }) )
		(?{ print "===>$6<===\n"; })
	)
/xs) {
	print "\n";
	print "DATA : =>$1<= " . length($1) . "\n";
	print "DATA : =>$4<= " . length($4) . "\n";
}

The second pattern : "[.\\n]{$5}" doesn't work... If I replace "." by
"\\w" for this example it works, but I need to match "." (everything)
not "\w".

Thanks again!

Phil.


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

Date: 13 Oct 2004 06:53:51 -0700
From: aymerphilippe@hotmail.com (Philippe Aymer)
Subject: Re: Using a variable size with the repetition quantifier
Message-Id: <47971ff0.0410130553.26e5ec9b@posting.google.com>

Jeff 'japhy' Pinyan <pinyaj@rpi.edu> wrote in message news:<Pine.SOL.3.96.1041012152434.11683A-100000@vcmr-86.server.rpi.edu>...
> On 12 Oct 2004, Philippe Aymer wrote:
> 
> >Now, I still have a trouble. Because:
> >
> >/X(\d)((??{"\\w{$1}"}))/
> >
> >works, but in my string, I also have to match newline. So I did:
> >
> >/X(\d)(??{"\\w{$1}"})/s
> >
> >which doesn't work (seems to apply only to //, not things within
> >(?..)), then:
> 
> The /s modifier only affects the '.' metacharacter.  \w doesn't match \n.
> 
> >/X(\d)(??{"[\\w\n]{$1}"})/
> >
> >which doesn't work neither... (?)
> 
> This should work:
> 
>   /X(\d)((??{ "[\\w\\n]{$1}" }))/

By the way, when writing my question, I found one solution (is there
another one TIMTOWTDI ?):

([^\\n]|\\n){$1}

it works!

Regards,

Phil.


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

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


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