[22712] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4933 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 4 18:05:53 2003

Date: Sun, 4 May 2003 15:05:08 -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           Sun, 4 May 2003     Volume: 10 Number: 4933

Today's topics:
        beep on win32 <schnoz@adelphia.net>
    Re: beep on win32 <jurgenex@hotmail.com>
    Re: beep on win32 <goodcall__1@hotmail.com>
        boolean operations on hash values? <henq _ replace 0 by o <hvtijen@h0tmail.c0m>>
    Re: boolean operations on hash values? <tassilo.parseval@rwth-aachen.de>
        calculating wait time <schnoz@adelphia.net>
    Re: calculating wait time <jurgenex@hotmail.com>
        clearing stdin <schnoz@adelphia.net>
    Re: code optimization and readability <nas@ANTISPAMnasland.nu>
        Controlling external device with Perl <upro@gmx.net>
    Re: Controlling external device with Perl <please@no.spam>
    Re: Controlling external device with Perl <upro@gmx.net>
        converting a perl script into an exe file (The Mosquito ScriptKiddiot)
    Re: downloading a page <nobody@dev.null>
    Re: downloading a page <samj@austarmetro.com.au>
        get most recent file with net::ftp (jdlail)
        how to find hash elements that match a RE? <ah@siol.net>
    Re: how to find hash elements that match a RE? <rick.delaney@rogers.com>
    Re: how to find hash elements that match a RE? <bwalton@rochester.rr.com>
    Re: Is it possible to pass @somethig and $something_els <michael.p.broida@boeing.com>
        mod_perl subroutine/modules and variables problem <ntnewsNOSPAM@hrz3.hrz.tu-darmstadt.de>
    Re: mod_perl subroutine/modules and variables problem (Sam Holden)
    Re: no speed differences with mod_perl? (Randal L. Schwartz)
    Re: no speed differences with mod_perl? <Juha.Laiho@iki.fi>
    Re: no speed differences with mod_perl? <ntnewsNOSPAM@hrz3.hrz.tu-darmstadt.de>
    Re: no speed differences with mod_perl? <ntnewsNOSPAM@hrz3.hrz.tu-darmstadt.de>
    Re: no speed differences with mod_perl? (Sam Holden)
    Re: Perl Editor : Whats Recommended <michael.p.broida@boeing.com>
    Re: Re: Controlling external device with Perl <removeX_stevensx4000x@earthlinxk.next>
        sending username and password for rsync (Amit Kaushal)
    Re: sending username and password for rsync <ddunham@redwood.taos.com>
    Re: Sort array of numbers <jurgenex@hotmail.com>
    Re: Sort array of numbers <barryk2@SPAM-KILLER.mts.net>
    Re: uniquifying and accumulating <spam@thecouch.homeip.net>
    Re: Why Lisp sucks ( Re: Announcement: The regex coach  <bongie@gmx.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 04 May 2003 19:35:08 GMT
From: Lee&James <schnoz@adelphia.net>
Subject: beep on win32
Message-Id: <3EB56B68.F98587EB@adelphia.net>

Can anyone tell me how to make the speaker beep on windows XP?

Thanks,

James




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

Date: Sun, 04 May 2003 20:06:37 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: beep on win32
Message-Id: <hpeta.11415$gf3.10692@nwrddc03.gnilink.net>

Lee&James wrote:
> Can anyone tell me how to make the speaker beep on windows XP?

Same way as in Unix: print "\a";

jue




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

Date: Sun, 04 May 2003 20:11:26 GMT
From: "Jack D." <goodcall__1@hotmail.com>
Subject: Re: beep on win32
Message-Id: <Oteta.134400$dh1.4291526@news0.telusplanet.net>

"Lee&James" <schnoz@adelphia.net> wrote in message
news:3EB56B68.F98587EB@adelphia.net...
> Can anyone tell me how to make the speaker beep on windows XP?

Is is one way.. there *are* more...

perl -e "print chr(7);"

--
Jack D.
Remove '__' from address if replying by e-mail.




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

Date: Sun, 4 May 2003 16:26:05 +0200
From: "henq" <henq _ replace 0 by o <hvtijen@h0tmail.c0m>>
Subject: boolean operations on hash values?
Message-Id: <3eb522fe$0$3561$1b62eedf@news.euronet.nl>

hi c.l.p.m.,


I hav problems undestanding how I should test for true/false values that are
stored as hash values. The following piece of code should return true if
login is not required or is required and the logged_in flag is valid:

   my $r = not $self->{logged_in_required} || \
            $self->{logged_in_required} && $self->{session}{logged_in};


In $self->{logged_in_required} I store '1' for true, and leave it undef for
false. In the latter case, does the evaluation work out as wanted, it looks
like

   not $self->{logged_in_required}

always gives false, because $self->.. is a non-null pointer? If I put

   not (0 + $self->{logged_in_required})

I get the result I want but surely, There Must Be A Simpler Way. Must I use
scalar?


TIA

~henq




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

Date: 4 May 2003 15:09:31 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: boolean operations on hash values?
Message-Id: <b93afb$4jb$1@nets3.rz.RWTH-Aachen.DE>

Also sprach henq:

> I hav problems undestanding how I should test for true/false values that are
> stored as hash values. The following piece of code should return true if
> login is not required or is required and the logged_in flag is valid:
> 
>    my $r = not $self->{logged_in_required} || \
>             $self->{logged_in_required} && $self->{session}{logged_in};

The above has the wrong precedence. It gets parsed as

    not( $self->{logged_in_required} || ... );

I assume you want

    my $r = ! $self->{logged_in_required 
            or
            $self->{logged_in_required} && $self->{session}{logged_in};

!, && and || bind more tightly than their wordy counterparts 'not',
'and' and 'or'. You can always use parens to disambiguate such
expressions when in doubt.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Sun, 04 May 2003 19:42:26 GMT
From: Lee&James <schnoz@adelphia.net>
Subject: calculating wait time
Message-Id: <3EB56D1C.78ED2D30@adelphia.net>

I want to do something like this:

$start = time;
clear stdin;
print "prompt message\n";
$junk = <STDIN>;
$end = time;

$duration = $start - $end;
print $duration."\n";

This only gives me a granularity of seconds. Can someone tell me how to
get a granularity of milliseconds?

Thanks,

James





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

Date: Sun, 04 May 2003 20:08:29 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: calculating wait time
Message-Id: <1reta.11417$gf3.6804@nwrddc03.gnilink.net>

Lee&James wrote:
> This only gives me a granularity of seconds. Can someone tell me how
> to get a granularity of milliseconds?

The FAQ can: "perldoc -q second"
         How can I measure time under a second?

jue




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

Date: Sun, 04 May 2003 19:36:42 GMT
From: Lee&James <schnoz@adelphia.net>
Subject: clearing stdin
Message-Id: <3EB56BC7.FD2900AA@adelphia.net>

On a windows platform I want to clear stdin before putting out a message
and then reading stdin. Can someone tell me how to do this?

Thx,

James




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

Date: Sun, 04 May 2003 14:13:49 GMT
From: "Chris H." <nas@ANTISPAMnasland.nu>
Subject: Re: code optimization and readability
Message-Id: <xe9ta.19319$g41.1447863@news1.east.cox.net>

welp, i updated the code at the links i provided...its getting a lot better,
but still so much left to do. hoping perhaps i can get it trimmed down,
then turned into a module and preload it under mod_perl so i can benefit
from both mod_perls module cache, but also H::T's. i turned on caching for
one of the calls, but im not really sure if its using it or not right now.

dont know why i havent used H::T until now, but i appreciate you guys giving
me the info, i picked it up in literally no time. its syntax hilariously
easy to absorb, and it trimmed quite a lot of code from my template.pl
script thus far. now all thats left is to finish what i started...

-chris h.


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

Date: Sun, 04 May 2003 19:15:49 +0200
From: upro <upro@gmx.net>
Subject: Controlling external device with Perl
Message-Id: <87y91mzl8a.fsf@gmx.net>

Hi!

Now this might be a strange question, but is it possible to control an
external device, via parallel or serial port, using Perl as
programming language?

Thank You In Advance!

-- 
Michael

r-znvy: zvpunry.wryqra  jro.qr (chg gur "@" jurer vg svgf...)
ab fcnz cyrnfr


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

Date: Sun, 04 May 2003 18:42:33 +0100
From: Chris Lowth <please@no.spam>
Subject: Re: Controlling external device with Perl
Message-Id: <Hfcta.2987$LQ2.63914@newsfep4-glfd.server.ntli.net>

upro wrote:

> Hi!
> 
> Now this might be a strange question, but is it possible to control an
> external device, via parallel or serial port, using Perl as
> programming language?
> 
> Thank You In Advance!
> 

Probably - it all depends on what you mean by "control", what the device is 
and what operating system you are using. But if your device can be 
"controlled" by any programming language, then chances are high that you 
can also "control" it with perl.

I think more detail is needed.

Chris
-- 
My real address is: chris at lowth dot sea oh em
-> OpenSource e-mail virus protection : http://protector.sourceforge.net
-> iptables configuration wizards : http://www.lowth.com/LinWiz


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

Date: Sun, 04 May 2003 19:36:38 +0200
From: upro <upro@gmx.net>
Subject: Re: Controlling external device with Perl
Message-Id: <87ptmyzk9l.fsf@gmx.net>

Chris Lowth <please@no.spam> writes:

> upro wrote:
>
>> Hi!
>> 
>> Now this might be a strange question, but is it possible to control an
>> external device, via parallel or serial port, using Perl as
>> programming language?
>> 
>> Thank You In Advance!
>> 
>
> Probably - it all depends on what you mean by "control", what the device is 
> and what operating system you are using. But if your device can be 
> "controlled" by any programming language, then chances are high that you 
> can also "control" it with perl.
>
> I think more detail is needed.
>
> Chris

I meant sonething like witching on and off a lamp with a self-made
circuit, which I give signals from the parallel port (as you can read
in the coffee-howto). I use Linux, and I'd have to switch on and off
one electricity in one of the pins from the parallel port...

What do you think?

-- 
Michael

r-znvy: zvpunry.wryqra  jro.qr (chg gur "@" jurer vg svgf...)
ab fcnz cyrnfr


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

Date: 04 May 2003 21:26:28 GMT
From: anotherway83@aol.comnospam (The Mosquito ScriptKiddiot)
Subject: converting a perl script into an exe file
Message-Id: <20030504172628.16083.00000766@mb-m25.aol.com>

hey,

i need to write a perl script and convert it into an exe which can be then be
either linked to or called by my program...what program do i need to do this?

thanks alot


--The Mosquito Scriptkiddiot. 
"There are two sides to every story...and then there is what really happened."
;p





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

Date: Sun, 04 May 2003 14:09:48 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: downloading a page
Message-Id: <3EB51EE5.1030205@dev.null>



Sam Jesse wrote:

> I am not getting the page from the address yahoo.com as a $res. even thoug I
> am not up to that level where I can understand every line of the code below.
> I copied it from the LWP module documentations. I get Bad Luck this time
> printed.
> Thanks
> Sam
> #!/perl -w
> use strict;
> # Create a user agent object
> use LWP::UserAgent;
> my $ua = LWP::UserAgent->new;
> $ua->agent("MyApp/0.1 ");  # Create a request
> my $req = HTTP::Request->new(POST => 'http://www.yahoo.com');
> $req->content_type('application/x-www-form-urlencoded');
> $req->content('match=www&errors=0');  # Pass request to the user agent and
> get a response back
> my $res = $ua->request($req);  # Check the outcome of the response
> if ($res->is_success) {
>     print $res->content;
> } else {
>     print "Bad luck this time\n";
> }



Omit lines 8 and 9:

$req->content_type('application/x-www-form-urlencoded');
$req->content('match=www&errors=0');

They are inappropriate for this site. Then you'll be OK.






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

Date: Sun, 04 May 2003 20:27:17 GMT
From: "Sam Jesse" <samj@austarmetro.com.au>
Subject: Re: downloading a page
Message-Id: <3eb577a4@news.comindico.com.au>


"Andras Malatinszky" <nobody@dev.null> wrote in message
news:3EB51EE5.1030205@dev.null...
>
>
> Sam Jesse wrote:
>
> > I am not getting the page from the address yahoo.com as a $res. even
thoug I
> > am not up to that level where I can understand every line of the code
below.
> > I copied it from the LWP module documentations. I get Bad Luck this time
> > printed.
> > Thanks
> > Sam
> > #!/perl -w
> > use strict;
> > # Create a user agent object
> > use LWP::UserAgent;
> > my $ua = LWP::UserAgent->new;
> > $ua->agent("MyApp/0.1 ");  # Create a request
> > my $req = HTTP::Request->new(POST => 'http://www.yahoo.com');
> > $req->content_type('application/x-www-form-urlencoded');
> > $req->content('match=www&errors=0');  # Pass request to the user agent
and
> > get a response back
> > my $res = $ua->request($req);  # Check the outcome of the response
> > if ($res->is_success) {
> >     print $res->content;
> > } else {
> >     print "Bad luck this time\n";
> > }
>
>
>
> Omit lines 8 and 9:
>
> $req->content_type('application/x-www-form-urlencoded');
> $req->content('match=www&errors=0');
>
> They are inappropriate for this site. Then you'll be OK.
>
>
>
>
thanks, that worked but I don't understand why? and what if I change the
site to another url? is there some good step by step reading on how to use
the LWP. the documentations are not that simple.
later I will need to parse the html. do I save it to a file, or a place in
memory or do it on the fly?  I guss I need to do more homework and if you
can recommend some good LWP reading I will be greatful

thanks
Sam




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

Date: 4 May 2003 07:22:07 -0700
From: jdlail@hotmail.com (jdlail)
Subject: get most recent file with net::ftp
Message-Id: <e32bb269.0305040622.d6b566e@posting.google.com>

How do retrieve only the most recent file from an ftp directory usint net::ftp?

I need to get the most recent file with a *.zip extension.

-- jack lail


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

Date: Sun, 04 May 2003 21:26:03 GMT
From: Andrej Hocevar <ah@siol.net>
Subject: how to find hash elements that match a RE?
Message-Id: <slrnbbb1g6.2ir.ah@sonet.utopija.linux>

Hello.
I was wondering if there's a nice way to get certain elements from a
hash that match a given RE. For example, why doesn't this work?

sub getel($) {
    grep(/$_[0]/ig, keys %hash)
};

print "$hash{&getel('RE')}";

Whereas this does:

$el = \&getel('RE');

print "$hash{$$el}";

What about (this one is completely mad and of course doesn't work!):

print "$hash{grep(/RE/ig, keys %hash)}"

Is there no way of getting the element like I wanted in the fitst
example? For the moment it's not important that many could have
matched; let's say that's not possible. Thus is there an elegant way
of retrieving such an elementi, maybe along the lines of my third
example? 

Thanks,

    andrej

-- 
echo ${girl_name} > /etc/dumpdates


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

Date: Sun, 04 May 2003 21:49:37 GMT
From: Rick Delaney <rick.delaney@rogers.com>
Subject: Re: how to find hash elements that match a RE?
Message-Id: <m3he8a1ixb.fsf@cs839290-a.mtth.phub.net.cable.rogers.com>

Andrej Hocevar <ah@siol.net> writes:

> Hello.
> I was wondering if there's a nice way to get certain elements from a
> hash that match a given RE. For example, why doesn't this work?
> 
> sub getel($) {
>     grep(/$_[0]/ig, keys %hash)
> };
> 
> print "$hash{&getel('RE')}";

Because you're calling getel() in scalar context which means the grep
is in scalar context and returns the number of matches.  To print all
matches, use a hash slice:

    print "@hash{getel('RE')}";

> 
> Whereas this does:
> 
> $el = \&getel('RE');
> 
> print "$hash{$$el}";

This works because \ imposes list context for no good reason.

> What about (this one is completely mad and of course doesn't work!):
> 
> print "$hash{grep(/RE/ig, keys %hash)}"

Scalar context again.

-- 
Rick Delaney
rick.delaney@rogers.com


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

Date: Sun, 04 May 2003 22:03:59 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: how to find hash elements that match a RE?
Message-Id: <3EB58E0F.2090600@rochester.rr.com>

Andrej Hocevar wrote:

> Hello.
> I was wondering if there's a nice way to get certain elements from a
> hash that match a given RE. For example, why doesn't this work?
> 
> sub getel($) {
>     grep(/$_[0]/ig, keys %hash

> };
> 
> print "$hash{&getel('RE')}";

@--------^
It does work if you use a hash slice.  A hash slice needs an @


> 
> Whereas this does:
> 
> $el = \&getel('RE');
> 
> print "$hash{$$el}";

That one doesn't work either, unless you have only one element that matches.


> 
> What about (this one is completely mad and of course doesn't work!):
> 
> print "$hash{grep(/RE/ig, keys %hash)}"

@--------^
That one works too if you use a hash slice as above.


> 
> Is there no way of getting the element like I wanted in the fitst
> example? For the moment it's not important that many could have
> matched; let's say that's not possible. Thus is there an elegant way
> of retrieving such an elementi, maybe along the lines of my third
> example? 


You will need the @ notation for a hash slice even if only one (or none) 
match.


 ...


One other point:  You use a sub prototype, and then call the sub with 
the & prefix to disable prototypes.  Why are you doing that?

>     andrej

-- 
Bob Walton



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

Date: Sun, 4 May 2003 21:08:30 GMT
From: "Michael P. Broida" <michael.p.broida@boeing.com>
Subject: Re: Is it possible to pass @somethig and $something_else to sub
Message-Id: <3EB5814E.543D124A@boeing.com>

"Tassilo v. Parseval" wrote:
> 
> Also sprach Michael P. Broida:
> 
> > Tad McClellan wrote:
> >>
> >> Michael P. Broida <michael.p.broida@boeing.com> wrote:
> >> >
> >> >       Umm, what is the actual REASON for not using & there?
> >>
> >>    perldoc perlsub
> >>
> >>        To call subroutines:
> >>        ...
> >>        &NAME(LIST);   # Circumvent prototypes.
> >>        &NAME;         # Makes current @_ visible to called subroutine.
> >
> >           Ah!  Thus far in my Perl usage, I haven't used function
> >           prototypes.  I --WANTED-- to use them, but that's when
> >           I was having the problem with/without the "&" and the
> >           only way I could get rid of it was to USE the "&".  I
> >           was trying to set them up similar to C/C++ forward
> >           references to functions; I may have been specifying
> >           the prototypes incorrectly or something equally dumb.
> >           <grin>
> 
> I suspect that you declared the subroutines "too late" for any prototype
> to have an effect. Before the first call to the subroutine, the
> prototype must already be set up. You can do this with a
> forward-declaration:
> 
>     sub func (\@);
>     ...
>     func(@array);
> 
>     sub func (\@) {
>         # body
>     }
> 
> Or you simply declare the functions on top of your programs:
> 
>     sub func (\@) {
>         # body
>     }
>     ...
>     func(@array);
> 
> >           Well, I'll play with using () and NOT using & and try to
> >           figure out the prototypes so I'm "clean".  <grin>
> 
> 'perldoc perlsub' (subsection "Prototypes") shows how you can mimic the
> behaviour of Perl built-ins with prototypes. With the help of this list
> you should be able to set up the desired prototype.

	OK, part of my confusion is probably the similarity of the terms
	"forward declaration", "prototype", "declaration", etc between
	Perl and what I'm used to in C/C++.  It seems that they don't all
	mean the same things between the languages.

	I'll dig into that perldoc section you mentioned; I already see
	some parts that I was doing VERY wrong when I thought I was using
	a prototype.  <grin>

		Thanks!
			Mike


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

Date: Sun, 4 May 2003 20:10:52 +0200
From: "alex" <ntnewsNOSPAM@hrz3.hrz.tu-darmstadt.de>
Subject: mod_perl subroutine/modules and variables problem
Message-Id: <b93l3c$9ic$01$1@news.t-online.com>

hi

i've got some big problems understanding the subroutines calling in perl and
the namespaces (don't know if this is the right word). why will the
following result in a undefined subroutine error?

i've got a "config.pm" file located in D:\InetPub\domain\test\config.pm

[config.pm]
#c:/programme/perl/bin/perl.exe -w
package config;
require 5.003;
use strict;

sub auth {
 use CGI 'cookie';
 my $id=0;
 my $pass='';
    ($id,$pass)=split(/#/,cookie('username'),2);
 return ($id,$pass);
}

now if i try to call this routine in a script located in D:\InetPub\domain\
[test.cgi]
#c:/programme/perl/bin/perl.exe -w
require "D:/InetPub/domain/test/config.pm";

if ((test::config::auth(1))[1] eq $pass) {
 ...
}

additional to this i set some vars inside the config.pm
[config.pm]
$dsn='dsn_name';
$dbuser='user';
$dbpass='pass';

[test.cgi]
our $dsn='';
our $dbuser='';
our $dbpass='';
require "D:/InetPub/domain/test/config.pm";
print "$dsn";

and now after the require the vars are not filled with the values in
config.pm - why this?


Alex




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

Date: 4 May 2003 18:23:58 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: mod_perl subroutine/modules and variables problem
Message-Id: <slrnbbamlu.lfr.sholden@flexal.cs.usyd.edu.au>

On Sun, 4 May 2003 20:10:52 +0200,
	alex <ntnewsNOSPAM@hrz3.hrz.tu-darmstadt.de> wrote:
> hi
> 
> i've got some big problems understanding the subroutines calling in perl and
> the namespaces (don't know if this is the right word). why will the
> following result in a undefined subroutine error?
> 
> i've got a "config.pm" file located in D:\InetPub\domain\test\config.pm
> 
> [config.pm]
> #c:/programme/perl/bin/perl.exe -w
> package config;
          ^^^^^^
> require 5.003;
> use strict;
> 
> sub auth {
>  use CGI 'cookie';
>  my $id=0;
>  my $pass='';
>     ($id,$pass)=split(/#/,cookie('username'),2);
>  return ($id,$pass);
> }
> 
> now if i try to call this routine in a script located in D:\InetPub\domain\
> [test.cgi]
> #c:/programme/perl/bin/perl.exe -w
> require "D:/InetPub/domain/test/config.pm";
> 
> if ((test::config::auth(1))[1] eq $pass) {
       ^^^^^^^^^^^^

The package in the config.pm file is config.

You have used test::config above. Those are completely seperate things,
Hence it isn't going to work.

Change one or the other...

> [test.cgi]
> our $dsn='';
> our $dbuser='';
> our $dbpass='';
> require "D:/InetPub/domain/test/config.pm";
> print "$dsn";
> 
> and now after the require the vars are not filled with the values in
> config.pm - why this?

Now you haven't specified any package at all.

Make up your mind. If config.pm places things in a package, then you need
to access them via that package. You can't choose random different names
depending on what mood you are in...


-- 
Sam Holden



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

Date: Sun, 04 May 2003 13:43:39 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: "alex" <ntnews@hrz3.hrz.tu-darmstadt.de>
Subject: Re: no speed differences with mod_perl?
Message-Id: <00c0a542653cd872997a87332ce23ec4@TeraNews>

>>>>> "alex" == alex  <ntnewsNOSPAM@hrz3.hrz.tu-darmstadt.de> writes:

alex> hi
alex> i have installed the "theoryx5.uwinnipeg.ca" - Perl 5.8/Apache2/mod_perl
alex> 1.99-10 distribution - but after all configured and the startup.pl changes
alex> with "use DBI" and "use DBD-ODBC" i cannot see any speed differences as
alex> without mod_perl... whats wrong? i thought mod_perl is about 20-30 times
alex> faster and is caching the DB connections... but it looks very slow.
alex> Benchmark gives me same times as without mod_perl. i haven't changed
alex> anything inside the perl scripts - could i change something?

Are your scripts running under mod_cgi, or one of the mod_perl
handlers (Apache::PerlRun, Apache::Registry, etc)?  What does
$ENV{GATEWAY_INTERFACE} return?  If it doesn't match /Perl/, you're
still using mod_cgi, and there will definitely be no speedup.

Also, the very first hit won't be much faster.  The speedup comes
from both non-forking and loading the perl code into memory once
and re-using it many times.

-- 
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: Sun, 04 May 2003 14:07:01 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: no speed differences with mod_perl?
Message-Id: <b936l8$o9v$1@ichaos.ichaos-int>

"alex" <ntnewsNOSPAM@hrz3.hrz.tu-darmstadt.de> said:
>i have installed the "theoryx5.uwinnipeg.ca" - Perl 5.8/Apache2/mod_perl
>1.99-10 distribution - but after all configured and the startup.pl changes
>with "use DBI" and "use DBD-ODBC" i cannot see any speed differences as
>without mod_perl... whats wrong? i thought mod_perl is about 20-30 times
>faster and is caching the DB connections... but it looks very slow.
>Benchmark gives me same times as without mod_perl. i haven't changed
>anything inside the perl scripts - could i change something?

What mod_perl gives you is that it removes
- time to load Perl
- time to compile your script
- time to open the DB connection
 ... when your script is used through the WWW interface. So, it's
better way to run perl scripts than through the CGI interface. If,
however, your programs are stand-alone (i.e. not producing content
to Web browsers) then mod_perl doesn't apply at all.

When the script itself is fast, these delays become the determining
factor for your overall site performance, especially at high hit
rates. F.ex. consider of a page composed of half dozen frames, each
produced on-the-fly with a perl script (but none doing any long-running
db queries or performing heavy processing). When a user hits this page,
six Perl interpreters get loaded, six scripts get compiled and run,
perhaps couple of the scripts also open a db connection. Here not
loading the Perls and not compiling the scripts over and over has a huge
benefit.

But if the script itself is slow (say, taking 2-3 seconds or more to
execute), and the hit rate of your site isn't that huge, then there's
not much help from mod_perl.
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)


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

Date: Sun, 4 May 2003 16:05:58 +0200
From: "alex" <ntnewsNOSPAM@hrz3.hrz.tu-darmstadt.de>
Subject: Re: no speed differences with mod_perl?
Message-Id: <b936o6$1o5$04$1@news.t-online.com>

hi

> Are your scripts running under mod_cgi, or one of the mod_perl
> handlers (Apache::PerlRun, Apache::Registry, etc)?  What does
i don't know - how to find out? and how to change?

> $ENV{GATEWAY_INTERFACE} return?  If it doesn't match /Perl/, you're
> still using mod_cgi, and there will definitely be no speedup.
it will return: CGI/1.1

> Also, the very first hit won't be much faster.  The speedup comes
> from both non-forking and loading the perl code into memory once
> and re-using it many times.
yes i know - the first hit is slow... but it will not change after more hits
:-(


Alex




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

Date: Sun, 4 May 2003 16:24:10 +0200
From: "alex" <ntnewsNOSPAM@hrz3.hrz.tu-darmstadt.de>
Subject: Re: no speed differences with mod_perl?
Message-Id: <b937qb$96f$02$1@news.t-online.com>

it's a webpage, and its my development server... now huge hits yet *g*


Alex




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

Date: 4 May 2003 15:20:09 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: no speed differences with mod_perl?
Message-Id: <slrnbbabt9.jag.sholden@flexal.cs.usyd.edu.au>

On Sun, 4 May 2003 16:05:58 +0200,
	alex <ntnewsNOSPAM@hrz3.hrz.tu-darmstadt.de> wrote:
> hi
> 
>> Are your scripts running under mod_cgi, or one of the mod_perl
>> handlers (Apache::PerlRun, Apache::Registry, etc)?  What does
> i don't know - how to find out? and how to change?

By checking the environment variable mentioned below.

perl.apache.org has a reasonable amount of documentation on how to use
mod_perl.
 
>> $ENV{GATEWAY_INTERFACE} return?  If it doesn't match /Perl/, you're
>> still using mod_cgi, and there will definitely be no speedup.
> it will return: CGI/1.1

In which case it isn't running under mod_perl.

But your use of 'will' instead of 'does' may indicate you didn't bother
actually testing...

> 
>> Also, the very first hit won't be much faster.  The speedup comes
>> from both non-forking and loading the perl code into memory once
>> and re-using it many times.
> yes i know - the first hit is slow... but it will not change after more hits
>:-(

Which is what you would expect using CGI.

-- 
Sam Holden



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

Date: Sun, 4 May 2003 21:09:56 GMT
From: "Michael P. Broida" <michael.p.broida@boeing.com>
Subject: Re: Perl Editor : Whats Recommended
Message-Id: <3EB581A4.BCD9BA31@boeing.com>

"Eric J. Roode" wrote:
> 
> "Michael P. Broida" <michael.p.broida@boeing.com> wrote in
> news:3EB30C9A.907E5D53@boeing.com:
> 
> > Chris wrote:
> >>
> >> Is there an editor that will allow me to clearly see code thats in {
> >> }.  I have a perl script that has lots of nested { } brackets and its
> >> hard for me to tell where the code stops and which else statements
> >> belong to which if. Will homesite do this or is there something else
> >> available?
> >
> >      I like Emacs.  It has a Perl mode that can handle indentation
> >      (though you might not like its default style) and font coloring
> >      so you can see variables, comments, functionnames, etc. among
> >      the rest of the language elements.
> 
> The indenting style, like just about everything else in emacs, is
> incredibly customizable.

	That's why I mentioned they might not like the "Default" style.
	I've made a couple of tiny changes, but left it mostly alone.

> Emacs's Cperl-mode will also highlight a matching brace or parenthesis when
> you move the cursor over one.  Also, Meta-Control-b and Meta-Control-f will
> move the cursor forward and backward over matching braces.

	Many of Emacs' modes will do that, not just CPerl-mode.

		Mike


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

Date: Sun, 04 May 2003 21:10:31 GMT
From: mbS <removeX_stevensx4000x@earthlinxk.next>
Subject: Re: Re: Controlling external device with Perl
Message-Id: <oj4bbvkvl5c1tn0921lgja637c24mrcer1@4ax.com>

On or around Sun, 04 May 2003 19:36:38 +0200, there was a message,
possibly from upro <upro@gmx.net>, as follows:

>I meant sonething like witching on and off a lamp with a self-made
>circuit, which I give signals from the parallel port (as you can read
>in the coffee-howto). I use Linux, and I'd have to switch on and off
>one electricity in one of the pins from the parallel port...

I've controlled labs with a 488 bus/board and with parallel ports,
by calling assembler routines through C.  You should be able to call
C functions from Perl through the Extension Interface,
so there is your hook.  

(Places like National Instruments used to
sell C libraries for controlling devices in real time, too.)

You need to set up a little testing setup for the lines coming from
the back of your computer so you can test when you've turned something
on or off.   A cheap voltmeter and a 'break out box' will do.

Probably best to get everything working with C and assembler
before trying to hook the result into Perl.  (I  havn't actually tried
this with Perl, but have done it with high level things like X Windows
and MS windows).    You'll need documents
for the internal addresses of device controllers  used by your Op
system so you can access them with the assembler calls.

Then, at the lamp end, you need some kind of amplifier and
switch to respond to the lines coming from the computer.  More
complex devices may have their own specialized controllers.   It's all
conceptually very simple, but it sucks down many hours while you try
to get things to actually work, assembling just the right parts that
will work together, talking to various device techs by email, etc... 

Sound like fun?
HTH
m
http://www.mbstevens.com/






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

Date: 4 May 2003 07:07:01 -0700
From: amit@billdesk.com (Amit Kaushal)
Subject: sending username and password for rsync
Message-Id: <4c63c8fc.0305040607.4200d4b4@posting.google.com>

Hi,

I am starting off in perl so please excuse any mistakes and do guide
me in the corerct direction. Thanks.

I have Perl version 5.005_03 built for sun4-solaris. The os is solaris
2.6.

what i want to do is automate/ cron the rsync login. The rsync version
is rsync  version 2.5.6  protocol version 26.

I have to, from my machine, initiate the rsync protocoal and log in to
another machine on a different network. Right now i am doing it
manually.
The steps are as follows:

1) rsync -avvv -e ssh  rsync@xxx.xxx.xxx.xxx:files_outgoing/ 
/home/amit/files/UPLOADED/

The screen output is as follows:

opening connection using ssh xxx.xxx.xxx.xxx -l rsync rsync --server
--sender -vvvlogDtpr . files_outgoing/
rsync@xxx.xxx.xxx.xxx's password: 

Now at this point i have to manually enter the password.

I want to cron this activity, for doing that i need to send the step 1
and the password in step two. As i am trying to cron it, i am unable
to pass the password. I have been told that i can do it using perl.

Will someone point me in the correct direction or post a generic
script so that after reading it i would be in a position to write the
script.

TIA,
best regards
Amit Kaushal
amit@billdesk.com
9820422993


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

Date: Sun, 04 May 2003 21:50:11 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: sending username and password for rsync
Message-Id: <mWfta.202$Pn5.24727768@newssvr15.news.prodigy.com>

Amit Kaushal <amit@billdesk.com> wrote:

> 1) rsync -avvv -e ssh  rsync@xxx.xxx.xxx.xxx:files_outgoing/ 
> /home/amit/files/UPLOADED/

> I want to cron this activity, for doing that i need to send the step 1
> and the password in step two. As i am trying to cron it, i am unable
> to pass the password. I have been told that i can do it using perl.

The prompts are from ssh, so you are really asking to automate an ssh
login.

Basically you create a key for the client account and place the public
information in the authorized_keys file of the server account.  If the
key has no passphrase, then there will be no prompt to access the
account.  Make sure you understand the ramifications of that.

-- 
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: Sun, 04 May 2003 13:09:41 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Sort array of numbers
Message-Id: <pi8ta.11228$gf3.1636@nwrddc03.gnilink.net>

012 wrote:
> Hi
> I'm looking for a way to sort aray of numbers. When I use the regular
> sort I get:
> 0 1 10 11 2 3 4 5 6 7 8 9
>
> Is there a simple way to handle that?

Did you bother to have even a cursory glance at the documention for the
functions that you are using?

Is there anything in the examples
     # sort lexically
    [...]
     # sort numerically ascending
    [...]
    # sort numerically descending
    [...]
that you don't understand or have problems with?

If yes then please ask more specifically and everyone will be happy to
explain.
If no then READ THE F****** MANUAL!

jue








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

Date: Sun, 4 May 2003 08:29:22 -0500
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: Sort array of numbers
Message-Id: <MPG.191ed1a9f3ecd62d9897ba@news.mts.net>

[This followup was posted to comp.lang.perl.misc]

In article <3eb4d870@news.012.net.il>, 012 (motis@lyciumnetworks.com) 
says...
> Hi
> I'm looking for a way to sort aray of numbers. When I use the regular sort I
> get:
> 0 1 10 11 2 3 4 5 6 7 8 9
> 
> Is there a simple way to handle that?
> Thanks
> Moti
> 
> 
> 

@numbers = (0, 1, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9);

@sorted = sort { $a <=> $b } @numbers;


-- 
---------

Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com


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

Date: Sun, 04 May 2003 11:24:10 -0400
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: uniquifying and accumulating
Message-Id: <Dgata.458$yv2.25465@weber.videotron.net>

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

Julian Day wrote:
> Hi,
> 
> Looking for an idiomatic (that is concise and perlish) way to flatten
> a list of names while accumulating associated values:
> 
> Before:
> 
> john:10
> john:2
> robert:15
> robert:20
> sally:4
> 
> After:
> 
> john:12
> robert:35
> sally:4
> 
> 
> I'm surely missing something obvious (and can, accordingly, feel the
> flames licking at my heels ;-) but somehow I can't seem to get it
> right.
> 
> /Julian

As consise and as perlish as they get :-) (not too maintainable though):

perl -F: -nale '$n{$F[0]}+=$F[1]; END{print map{"$_:$n{$_}\n"} keys %n}' 
inputfile > outputfile

inputfile can be ignored to feed data via STDIN. "> outputfile" can be 
ignored to spit out the results to STDOUT.

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+tTCeeS99pGMif6wRAoE2AJ0WHhUu2wKtXNt1Tmc75KAVWuIs4wCeJpQW
wo7hHMkbMbUW7HOCgZPZ7bw=
=q+mK
-----END PGP SIGNATURE-----



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

Date: Sun, 04 May 2003 20:14:39 +0200
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: Why Lisp sucks ( Re: Announcement: The regex coach )
Message-Id: <1506569.UUtObXQ0fa@nyoga.dubu.de>

Michael Carman wrote:
> Still, it looks like an interesting little tool; and a useful one for
> learning about and playing with regexes.

Those using the KDE desktop might be interested in kregexpeditor[1],
which can be used to build regexes either textual or with drag'n'drop. 
The current version in KDE CVS also highlights matches in a given text.

Ciao,
        Harald

[1] http://www.blackie.dk/KDE/KRegExpEditor/
-- 
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Interesting Error Messages #7:
Volume in Drive C: TOO_LOUD! 



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

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


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