[29770] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1013 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 8 00:09:42 2007

Date: Wed, 7 Nov 2007 21:09:07 -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, 7 Nov 2007     Volume: 11 Number: 1013

Today's topics:
    Re: &Compress::Zlib::gzopen and Scalar::Util errors <nospam@somewhere.com>
    Re: CPU limits <ben@morrow.me.uk>
    Re: How Does One Implement a Timer in Perl? <m@rtij.nl.invlalid>
        Net::Server + IPC::Shareable == decent performance ? <david.jacobowitz@gmail.com>
        Newbie doesn't quite understand pointers with hashes. <keeresarge@nowhere.com>
    Re: Newbie doesn't quite understand pointers with hashe <jurgenex@hotmail.com>
    Re: Newbie doesn't quite understand pointers with hashe <uri@stemsystems.com>
        Obtaining column type in Oracle table <seannakasone@yahoo.com>
    Re: problems building perl modules, path question <mmccaws@comcast.net>
    Re: problems building perl modules, path question <ben@morrow.me.uk>
    Re: Replace without back reference <ben@morrow.me.uk>
        simple question reag search and replace <arvindkannan1@gmail.com>
    Re: simple question reag search and replace <noreply@gunnar.cc>
    Re: simple question reag search and replace <krahnj@telus.net>
    Re: simple question reag search and replace <jimsgibson@gmail.com>
        thread <dontmewithme@got.it>
    Re: Using perl to watch other programs <ben@morrow.me.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 7 Nov 2007 18:17:44 -0500
From: "Thrill5" <nospam@somewhere.com>
Subject: Re: &Compress::Zlib::gzopen and Scalar::Util errors
Message-Id: <SNadnaQrBKAF2q_anZ2dnUVZ_vGinZ2d@comcast.com>

I would suggest backing out the security update to get your production 
system up and running and then testing your applications on another machine 
to figure out what you need to do to get your apps working with the security 
update.


"Tim Boyer" <tim@denmantire.com> wrote in message 
news:ti12j3pbf5cv48a6rd12a42lv3ji3km0j2@4ax.com...
> I'm running Red Hat Enterprise version 5 in a mixture of 32 and 64 bit
> environments.  There was a Perl security update last night, updating perl
> 5.8.8-10. to 5.8.8-10_02.
>
> Since then, I've been having problems running a number of perl 
> applications.
> For instance, SpamAssassin:
>
> [root@roosevelt scripts]# spamassassin --lint
> Use of uninitialized value in concatenation (.) or string at
> /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/Scalar/Util.pm line 30.
> Use of uninitialized value in concatenation (.) or string at
> /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/Scalar/Util.pm line 30.
>
> or CPAN:
>
> cpan> install Bundle::CPAN
> CPAN: Storable loaded ok
> Going to read /root/.cpan/Metadata
>  Database was generated on Sun, 19 Aug 2007 04:36:49 GMT
> CPAN: LWP::UserAgent loaded ok
> Fetching with LWP:
>  http://mirror.hyperian.net/CPAN/authors/01mailrc.txt.gz
> Use of uninitialized value in concatenation (.) or string at
> /usr/lib/perl5/5.8.8/i386-linux-thread-multi/Scalar/Util.pm line 30.
> Going to read /root/.cpan/sources/authors/01mailrc.txt.gz
> Undefined subroutine &Compress::Zlib::gzopen called at
> /usr/lib/perl5/5.8.8/CPAN.pm line 5721.
>
> I've ?fixed? the Scalar::Util problem by doing a force install 
> Scalar::Util.
> I've tried to do the same with Compress::Zlib, but with less luck:
>
> cpan> install Compress::Zlib
> Running install for module Compress::Zlib
> Running make for P/PM/PMQS/Compress-Zlib-2.007.tar.gz
> Undefined subroutine &Compress::Zlib::gzopen called at
> /usr/lib/perl5/5.8.8/CPAN.pm line 5721.
>
> So apparently I can't install Compress::Zlib until I get Compress::Zlib
> working.  This is... a conundrum.
>
> Pointers in the right direction greatly appreciated.
>
> -- 
> tim boyer
> tim@denmantire.com 




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

Date: Thu, 8 Nov 2007 02:42:00 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: CPU limits
Message-Id: <ok9a05-57s.ln1@osiris.mauzo.dyndns.org>


Quoth "alexxx.magni@gmail.com" <alexxx.magni@gmail.com>:
> Inspired by the recent posting of "FAQ 8.39 How do I set CPU limits?",
> I hoped to solve this problem, that I always had with computationally
> intensive scripts - namely that the CPU usage goes to 100%, and a very
> noisy fan starts.
> I'd much prefer to be able to set my script's CPU usage at - say - 75%
> or similar...
> 
> In the FAQ I saw that this possibility is in the BSD::Resource module,
> but unfortunately I work in Linux.

As others have mentioned, BSD::Resource works perfectly well under
Linux.

> Moreover, I'm not certain that even under BSD this could be possible:
> setrlimit seems to allow you just to kill processes going beyond your
> given threshold.

setrlimit sends a trappable signal when you reach your soft limit. The
problem is there is no rlimit for 'percentage of CPU used': I'm not even
sure it's a terribly well-defined property. Apart from anything else,
you don't really want your script to be using 75% CPU; you just want the
CPU to be 25% idle. Have you looked to see if there is some ACPI stuff
you could use to request this? I remember reading about some 'laptop
mode' for Linux which cut down the amount of CPU time available to
preserve power.

Ben



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

Date: Wed, 7 Nov 2007 23:32:07 +0100
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: How Does One Implement a Timer in Perl?
Message-Id: <pan.2007.11.07.22.31.00@rtij.nl.invlalid>

On Wed, 07 Nov 2007 09:59:42 +0100, Josef Moellers wrote:

> jordilin wrote:
>> Take a look at
>> http://www.perl.com/doc/manual/html/pod/perlfunc/alarm.html
> 
> Using alarm introduces a potential race condition: 1. you set up an
> alarm to fire in 5s
> 2. you request the response
> 3. the reponse arrives within 1s
> 4. dur to high load, further execution is delayed by 4.5s 5. the alarm
> fires, you throw away a perfectly valid reply.

Just test for success first, for timeout later.

M4


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

Date: Wed, 07 Nov 2007 18:24:22 -0800
From:  David Jacobowitz <david.jacobowitz@gmail.com>
Subject: Net::Server + IPC::Shareable == decent performance ?
Message-Id: <1194488662.188032.267870@v23g2000prn.googlegroups.com>


Hello, this is a question for all the perl people out there who have
written internet servers.

I'm currently have a perl-based server that acts as a hub for a simple
message passing scheme. Clients periodically connect, send a message
to a user (the server puts the message in an in-memory queue for the
recipient, and check for their own messages, with the server splatting
back out the clients message queue and then deleting it.

Each transaction is small and short, and I have everything working
pretty well with a single instance server of Net::Server. And I'm not
doing anything funky with select(); I'm just answering and completing
each transaction in order. This seems to make sense to me, because
there is really not much work per transaction over and above reading
and writing data to the socket.

The thing is, I want this server to be able to take hundreds or maybe
thousands of connections per second. This will never work with a
single process (I don't think. My laptop seems to saturate around 600
xactions/sec, but then the laptop is also running the client processes
as well)

With Net::Server, turning a server into a pre-forked server is pretty
easy. But then each process is independent from that point forward,
and so obviously message queues won't be shared between them. So, I'm
thinking of using IPC::Shared.

But, with all the overhead of IPC will this be any faster than the
single process? Is there an easy way to see where the cycles are
going? If most of the cycles are going to data-structure maintenance,
then I don't see a point in doing this work. If most of them are going
to handling socket stuff, then it would be a win, assuming it works.

Has anyone here made such a server? I'm curious for hints.

As an aside, my application does not require that any user be able to
leave a message for any other user, so it would be okay to segment the
message queues into groups. But for this to work, I'd need a way to
make sure that each client connection matches up with the same server
process on sequential accesses. I could do this, of course, by putting
another server in front of the other servers whose only job in life is
to track which back-end server the client first connected with and
then keep sending the client to the same back-end server on subsequent
connections. But in this case, I'm just creating more or less the same
bottleneck again.

Hints and ideas very much welcome.

thanks,
-- dave j



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

Date: Thu, 08 Nov 2007 04:00:29 -0000
From: keersarge <keeresarge@nowhere.com>
Subject: Newbie doesn't quite understand pointers with hashes.
Message-Id: <13j52etd7b45g1c@corp.supernews.com>

Help a newbie moving way too far out in left field, given my current
knowledge of Perl - but it is fun, anyway.

(Perl 5.8.8 on Debian Etch.)

I am building an object to build some HTML forms.  My routine reads in a
config file that has the following line.

 ...
<input type="text" name="Address" value=$submithash{Address} size="40">
 ...

I want to replace the hash key with the actual value. The Perl script
reads the file in line by line is parsed out on the spaces. The following
is not really the program, just a boiled down test script that I am using
to try to understand what is going on.

 ...
  $z = <F1>;    #read a line
  @parsearray = split(' ', $z); #break it apart at the spaces
  $parsearray[3] =~ s/value=//; #get rid of all but the hash key
 ...

Now $parsearray[3] holds the string    $submithash{Address}.

I can't get from the string representation of the hash key to the actual
value (although I have discovered a ton of interesting stuff while
trying).

If I print $parsearray[3], I get the string $submithash{Address}.

print \$parsearray[3] gives me a SCALAR pointer.

print \%parsearray[3] blows up on a use strict error.

Anybody?

Thanks
Keersarge

(Late of Delphi, which is the only thing I regret leaving behind when I
left Windows).


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

Date: Thu, 08 Nov 2007 04:51:23 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Newbie doesn't quite understand pointers with hashes.
Message-Id: <fBwYi.6336$Cc.3796@trndny09>

keersarge wrote:
> <input type="text" name="Address" value=$submithash{Address}
> size="40"> ...
>
> I want to replace the hash key with the actual value.

I think you got the terminology wrong. Assuming
    $submithash{Address}
was code (it is not, it is data) and there was a hash %submithash then the 
hash key would be 'Address'.

[code snipped]
>  $parsearray[3] =~ s/value=//; #get rid of all but the hash key
>
> Now $parsearray[3] holds the string    $submithash{Address}.

I.e. the content of $parsearray[3] is data, just as it is supposed to be.

> I can't get from the string representation of the hash key to the
> actual value (although I have discovered a ton of interesting stuff
> while trying).
>
> If I print $parsearray[3], I get the string $submithash{Address}.

That is the data that is stored in the fourth element of the array 
$parsearray

> print \$parsearray[3] gives me a SCALAR pointer.

And that is the address to that fourth element.

It is not totally clear what you are trying to do but it appears as if you 
are trying to execute data as if it were program code. The proper tool for 
that is eval(), details see the man page.
 However be warned that many people consider eval() quite dangerous and 
rightfully so because unless used very carefully it opens a huge barn door 
to code injection attacks.

jue 




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

Date: Thu, 08 Nov 2007 05:00:51 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Newbie doesn't quite understand pointers with hashes.
Message-Id: <x7tznxxrem.fsf@mail.sysarch.com>

>>>>> "JE" == Jürgen Exner <jurgenex@hotmail.com> writes:


  JE> It is not totally clear what you are trying to do but it appears
  JE> as if you are trying to execute data as if it were program
  JE> code. The proper tool for that is eval(), details see the man
  JE> page.  However be warned that many people consider eval() quite
  JE> dangerous and rightfully so because unless used very carefully it
  JE> opens a huge barn door to code injection attacks.

what the OP really needs is a proper templating system. string eval is a
poor man's version of that and as you said, dangerous. also it is
overkill for this. of course i will recommend Template::Simple since it
can do this sort of templating with little effort on the part of the OP.

classify this as a classic XY problem as they needed a templater but
thought that some form of wacky perl interpolation would work.

uri

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


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

Date: Wed, 7 Nov 2007 14:18:17 -1000
From: Sean Nakasone <seannakasone@yahoo.com>
Subject: Obtaining column type in Oracle table
Message-Id: <Pine.WNT.4.64.0711071416470.2672@ctfanxnfba.unjnvvnaryrpgevp.arg>

Using the Oracle module, how does one obtain the type of a column in a 
table?  For example, how do we know if a column is a VARCHAR or a NUMBER?



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

Date: Wed, 07 Nov 2007 13:29:47 -0800
From:  mmccaws2 <mmccaws@comcast.net>
Subject: Re: problems building perl modules, path question
Message-Id: <1194470987.365471.313150@v23g2000prn.googlegroups.com>

On Nov 7, 12:12 pm, elsiddik <elsid...@gmail.com> wrote:
> On Nov 7, 7:05 pm, mmccaws2 <mmcc...@comcast.net> wrote:
>
> > On Nov 7, 8:59 am, Ben Morrow <b...@morrow.me.uk> wrote:
>
> > > Quoth mmccaws2 <mmcc...@comcast.net>:
>
> > > > On Oct 29, 2:53 pm, Ben Morrow <b...@morrow.me.uk> wrote:
> > > > > Quoth Ron Bergin <r...@i.frys.com>:
>
> > > > > > Try doing:
>
> > > > > > $sudobash
> > > > > > [pass your login credentials]
>
> > > > > > #perl-MCPAN -e shell
>
> > > > > > Note the difference between the $ prompt and the # prompt.
>
> > > > > It would be better to avoid performing the Makefile.PL and make s=
teps as
> > > > > root, if possible. Since CPAN (at least recent versions) has supp=
ort for
> > > > > usingsudofor make install, it would be better to take advantage o=
f it.
>
> > > > So, I think I have made a few mistakes here and I need to correct
> > > > them.  I had installed several modules by getting into perl -MCPAN =
-e
> > > > shell using sudo.  The reason is I get this error message
>
> > > > $ perl -MCPAN -e shell
> > > > CPAN: File::HomeDir loaded ok (v0.66)
> > > > mkdir /home/mccannm/.cpan/CPAN: Permission denied at /opt/perl_32/l=
ib/
> > > > 5.8.8/CPAN/HandleConfig.pm line 539
>
> > > > when I tried logging in as my self.
> > > > What happened is this, right after the reinstallation of perl, we're
> > > > on 5.8.8 now, I need to install a module that required root access.=
  I
> > > > had tried to install that module previously and it said trying to
> > > > install the module I needed root access.  It was the POE module for
> > > > non-blocking ping.  I used sudo perl -MCPAN -e shell to intall it.
> > > > Since then I can't install any module without using sudo perl -MCPA=
N -
> > > > e shell.
>
> > > What has happened is that running CPAN under sudo has created
> > > /home/mccannm/.cpan as root, so you can't run CPAN as yourself any mo=
re.
> > > You need to su(do) to root, and either delete the entire directory or
> > > chown -R it to yourself. Then you need to set CPAN up to use sudo to
> > > install (as yourself):
>
> > >     $ perl -MCPAN -eshell
> > >     cpan> o conf make_install_make_command "sudo make"
> > >     cpan> o conf mbuild_install_build_command "sudo ./Build"
> > >     cpan> o conf commit
> > >     cpan> quit
> > >     $
>
> > > You will of course need sudo rights to perform both those commands; b=
ut
> > > it seems as though you have localhost=3D(root) ALL rights anyway.
>
> > > > Also, do I uninstall the ones that I have already installed as root=
 or
> > > > do I change file permissions for directories, I really don't
> > > > understand this part of administration.
>
> > > No, all the modules already installed should be fine (you might want =
to
> > > check that everything under /opt/perl_32/lib is owned by root). It's
> > > just your CPAN config that's been messed up.
>
> > > Ben
>
> > well chown -R worked.
>
> > now the next part, and sorry for being so dense, But I don't sudo perl
> > -MCPAN -e shell but run those commands after entering perl -MCPAN -e
> > shell.  Correct?
>
> > also the /opt/perl_32/lib/5.8.8/ has a lot of files with read only
> > permissions.  Would the correct approach be chmod -R 644 /opt/perl_32/
> > lib/5.8.8/  or is that too broad of a command?
>
> > $ ls -l /opt/perl_32/lib/5.8.8/
>
> > gives
>
> > total 4784
> > dr-xr-xr-x   3 bin        bin             96 Nov  2 12:54 ActivePerl
> > -r--r--r--   1 bin        bin           3112 Aug  3 05:50
> > ActivePerl.pm
> > dr-xr-xr-x   2 bin        bin             96 Nov  2 12:54 ActiveState
> > -r--r--r--   1 bin        bin           2594 Aug  3 05:50
> > AnyDBM_File.pm
> > dr-xr-xr-x   3 bin        bin             96 Nov  2 12:54 Apache
> > drwxr-xr-x   2 root       sys             96 Nov  6 21:58 App
> > dr-xr-xr-x   4 bin        bin             96 Nov  2 12:54 Archive
> > dr-xr-xr-x   2 bin        bin             96 Nov  2 12:54 Attribute
> > -r--r--r--   1 bin        bin          11794 Aug  3 05:50
> > AutoLoader.pm
> > -r--r--r--   1 bin        bin          15699 Aug  3 05:50 AutoSplit.pm
> > dr-xr-xr-x   2 bin        bin             96 Nov  2 12:54 B
> > -r--r--r--   1 bin        bin          28524 Aug  3 05:50 Benchmark.pm
> > dr-xr-xr-x   3 bin        bin             96 Nov  2 12:54 Bundle
> > dr-xr-xr-x   3 bin        bin           8192 Nov  2 12:54 CGI
> > -r--r--r--   1 bin        bin         249942 Aug  3 05:50 CGI.pm
> > dr-xr-xr-x   4 bin        bin           8192 Nov  3 07:18 CPAN
> > -r--r--r--   1 root       sys         441448 Sep 28 00:06 CPAN.pm
> > dr-xr-xr-x   2 bin        bin             96 Nov  2 12:54 Carp
> > -r--r--r--   1 bin        bin           7608 Aug  3 05:50 Carp.pm
> > dr-xr-xr-x   2 bin        bin             96 Nov  2 12:54 Class
> > dr-xr-xr-x   3 bin        bin             96 Nov  2 12:54 Convert
> > -r--r--r--   1 bin        bin          19229 Aug  3 05:50 DB.pm
> > dr-xr-xr-x   2 bin        bin           8192 Nov  2 12:54 DBM_Filter
> > -r--r--r--   1 bin        bin          14415 Aug  3 05:50
> > DBM_Filter.pm
> > dr-xr-xr-x   3 bin        bin             96 Nov  2 12:54 Data
> > dr-xr-xr-x   2 bin        bin             96 Nov  2 12:54 Devel
> > dr-xr-xr-x   2 bin        bin           8192 Nov  2 12:54 Digest
> > -r--r--r--   1 bin        bin          10316 Aug  3 05:50 Digest.pm
> > -r--r--r--   1 bin        bin           1899 Aug  3 05:50 DirHandle.pm
> > -r--r--r--   1 bin        bin          16897 Aug  3 05:50 Dumpvalue.pm
> > dr-xr-xr-x   2 bin        bin           8192 Nov  2 12:54 Encode
> > -r--r--r--   1 bin        bin           4519 Aug  3 05:50 English.pm
> > -r--r--r--   1 bin        bin           5170 Aug  3 05:50 Env.pm
> > dr-xr-xr-x   2 bin        bin             96 Nov  2 12:54 Exporter
> > -r--r--r--   1 bin        bin          14481 Aug  3 05:50 Exporter.pm
> > dr-xr-xr-x   6 bin        bin           8192 Nov  2 12:54 ExtUtils
> > -r--r--r--   1 bin        bin           5208 Aug  3 05:50 Fatal.pm
> > dr-xr-xr-x   3 bin        bin           8192 Nov  2 12:54 File
> > -r--r--r--   1 bin        bin           5405 Aug  3 05:50 FileCache.pm
> > -r--r--r--   1 bin        bin           6771 Aug  3 05:50
> > FileHandle.pm
> > dr-xr-xr-x   2 bin        bin             96 Nov  2 12:54 Filter
> > -r--r--r--   1 bin        bin           5668 Aug  3 05:50 FindBin.pm
> > dr-xr-xr-x   3 bin        bin             96 Nov  2 12:54 Font
> > dr-xr-xr-x   2 bin        bin             96 Nov  2 12:54 Getopt
> > dr-xr-xr-x   4 bin        bin           8192 Nov  2 12:54 HTML
> > dr-xr-xr-x   5 bin        bin           8192 Nov  2 12:54 HTTP
> > dr-xr-xr-x   3 bin        bin             96 Nov  2 12:54 I18N
> > dr-xr-xr-x  36 bin        bin           8192 Nov  2 12:55
> > IA64.ARCHREV_0-thread-multi
> > dr-xr-xr-x   2 bin        bin             96 Nov  2 12:55 IO
> > dr-xr-xr-x   2 bin        bin             96 Nov  2 12:55 IPC
> > dr-xr-xr-x   4 bin        bin           8192 Nov  2 12:55 LWP
> > -r--r--r--   1 bin        bin          21427 Jul 19 23:16 LWP.pm
> > dr-xr-xr-x   3 bin        bin           8192 Nov  2 12:55 Locale
> > -r--r--r--   1 bin        bin           1141 Nov 27  2003 MD5.pm
> > dr-xr-xr-x   4 bin        bin           8192 Nov  2 12:55 Math
> > dr-xr-xr-x   2 bin        bin           8192 Nov  2 12:55 Memoize
> > -r--r--r--   1 bin        bin          35275 Aug  3 05:50 Memoize.pm
> > dr-xr-xr-x   3 bin        bin             96 Nov  2 12:55 Module
> > -r--r--r--   1 bin        bin          16122 Aug  3 05:50 NEXT.pm
> > dr-xr-xr-x   5 bin        bin           8192 Nov  6 22:04 Net
> > dr-xr-xr-x   6 bin        bin           8192 Nov  2 12:55 PPM
> > dr-xr-xr-x   3 bin        bin             96 Nov  2 12:55 PerlIO
> > -r--r--r--   1 bin        bin          10928 Aug  3 05:50 PerlIO.pm
> > dr-xr-xr-x   4 bin        bin           8192 Nov  2 12:55 Pod
> > dr-xr-xr-x   3 bin        bin             96 Nov  2 12:55 SOAP
> > dr-xr-xr-x   2 bin        bin             96 Nov  2 12:55 Search
> > -r--r--r--   1 bin        bin           1070 Aug  3 05:50
> > SelectSaver.pm
> > -r--r--r--   1 bin        bin          13203 Aug  3 05:50
> > SelfLoader.pm
> > -r--r--r--   1 bin        bin           8457 Aug  3 05:50 Shell.pm
> > -r--r--r--   1 bin        bin          28651 Aug  3 05:50 Switch.pm
> > -r--r--r--   1 bin        bin           4794 Aug  3 05:50 Symbol.pm
> > drwxr-xr-x   4 root       sys           8192 Nov  6 21:58 TAP
> > dr-xr-xr-x   3 bin        bin           8192 Nov  2 12:55 Term
> > dr-xr-xr-x   4 bin        bin           8192 Nov  6 21:58 Test
> > -r--r--r--   1 bin        bin          28863 Aug  3 05:50 Test.pm
> > dr-xr-xr-x   2 bin        bin           8192 Nov  2 12:55 Text
> > dr-xr-xr-x   2 bin        bin             96 Nov  2 12:55 Thread
> > -r--r--r--   1 bin        bin          10152 Aug  3 05:50 Thread.pm
> > dr-xr-xr-x   2 bin        bin           8192 Nov  2 12:55 Tie
> > dr-xr-xr-x   2 bin        bin             96 Nov  2 12:55 Time
> > dr-xr-xr-x   2 bin        bin             96 Nov  2 12:55 UDDI
> > -r--r--r--   1 bin        bin           4052 Aug  3 05:50 UNIVERSAL.pm
> > dr-xr-xr-x   4 bin        bin           8192 Nov  2 12:55 URI
> > -r--r--r--   1 bin        bin          30307 Nov  5  2004 URI.pm
> > dr-xr-xr-x   3 bin        bin             96 Nov  2 12:55 Unicode
> > dr-xr-xr-x   2 bin        bin             96 Nov  2 12:55 User
> > dr-xr-xr-x   3 bin        bin             96 Nov  2 12:55 WWW
> > dr-xr-xr-x   8 bin        bin           8192 Nov  2 12:55 XML
> > dr-xr-xr-x   3 bin        bin             96 Nov  2 12:55 XMLRPC
> > -r--r--r--   1 bin        bin            838 Aug  3 05:50 abbrev.pl
> > -r--r--r--   1 bin        bin           1298 Aug  3 05:50 assert.pl
> > -r--r--r--   1 bin        bin          12844 Aug  3 05:50
> > attributes.pm
> > -r--r--r--   1 bin        bin           4238 Aug  3 05:50 autouse.pm
> > -r--r--r--   1 bin        bin           6524 Aug  3 05:50 base.pm
> > -r--r--r--   1 bin        bin           7368 Aug  3 05:50 bigfloat.pl
> > -r--r--r--   1 bin        bin           8959 Aug  3 05:50 bigint.pl
> > -r--r--r--   1 bin        bin          11937 Aug  3 05:50 bigint.pm
> > -r--r--r--   1 bin        bin          14966 Aug  3 05:50 bignum.pm
> > -r--r--r--   1 bin        bin           4476 Aug  3 05:50 bigrat.pl
> > -r--r--r--   1 bin        bin          10694 Aug  3 05:50 bigrat.pm
>
> ...
>
> read more =BB

I now get this error using perl -MCPAN -e shell

$ perl -MCPAN -e shell
/usr/lib/hpux32/dld.so: Unable to find library 'libperl.so'.

the permissions for this is
 ls -l /opt/perl_64/lib/5.8.8/IA64.ARCHREV_0-thread-multi-LP64/CORE/
libperl.so
-r-xr-xr-x   1 bin        bin        4324272 Sep 13 23:24 /opt/perl_64/
lib/5.8.8/IA64.ARCHREV_0-thread-multi-LP64/CORE/libperl.so

what should the settings be for libperl.so?

Mike





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

Date: Thu, 8 Nov 2007 02:26:41 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: problems building perl modules, path question
Message-Id: <1o8a05-57s.ln1@osiris.mauzo.dyndns.org>


Quoth mmccaws2 <mmccaws@comcast.net>:
> On Nov 7, 12:12 pm, elsiddik <elsid...@gmail.com> wrote:
> > On Nov 7, 7:05 pm, mmccaws2 <mmcc...@comcast.net> wrote:
> > > On Nov 7, 8:59 am, Ben Morrow <b...@morrow.me.uk> wrote:
> > > >
> > > >     $ perl -MCPAN -eshell
> > > >     cpan> o conf make_install_make_command "sudo make"
> > > >     cpan> o conf mbuild_install_build_command "sudo ./Build"
> > > >     cpan> o conf commit
> > > >     cpan> quit
> > > >     $
[snip]
> > > > No, all the modules already installed should be fine (you might want to
> > > > check that everything under /opt/perl_32/lib is owned by root).
> > >
> > > well chown -R worked.

Good.

> > > now the next part, and sorry for being so dense, But I don't sudo perl
> > > -MCPAN -e shell but run those commands after entering perl -MCPAN -e
> > > shell.  Correct?

Correct. Hence the '$' prompt.

> > > also the /opt/perl_32/lib/5.8.8/ has a lot of files with read only
> > > permissions.  Would the correct approach be chmod -R 644 /opt/perl_32/
> > > lib/5.8.8/  or is that too broad of a command?

No! Don't touch anything in there: that's core perl stuff. Why would you
think it should be writable?

> > > $ ls -l /opt/perl_32/lib/5.8.8/
> >
> > > gives

[lots of stuff that looks fine]

> > ...
> >
> > read more »

If you're going to quote someone, please do so in a comprehensible
manner. Google Groups ne Usenet.

> I now get this error using perl -MCPAN -e shell
> 
> $ perl -MCPAN -e shell
> /usr/lib/hpux32/dld.so: Unable to find library 'libperl.so'.

Well... what else have you changed? If you've been messing about with
the permissions of .../lib/5.8.8 then put things back the way they were.

> the permissions for this is
>  ls -l /opt/perl_64/lib/5.8.8/IA64.ARCHREV_0-thread-multi-LP64/CORE/
> libperl.so
> -r-xr-xr-x   1 bin        bin        4324272 Sep 13 23:24 /opt/perl_64/
> lib/5.8.8/IA64.ARCHREV_0-thread-multi-LP64/CORE/libperl.so

Uh, why are you showing me a listing for a perl that lives under
/opt/perl_64 when before you were asking about a perl that lived under
/opt/perl_32? Are you mixing up 32- and 64-bit perls? That probably
won't work.

> what should the settings be for libperl.so?

Whatever the ActiveState installer left them as. CPAN.pm won't have
touched them.

Ben



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

Date: Thu, 8 Nov 2007 02:31:26 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Replace without back reference
Message-Id: <u09a05-57s.ln1@osiris.mauzo.dyndns.org>


Quoth Jim Gibson <jimsgibson@gmail.com>:
> 
> I thought of another way:
> 
>   $str = s/CD/CF/g;
> 
> It's probably about the same as look-behind, but let's throw it into
> the benchmark program and see:
> 
> #!/usr/local/bin/perl
> use strict;
> use warnings;
> use Benchmark qw(cmpthese);
> 
> my $str = 'ABCDEFGHCDIJCXKLCDMNOPC';
> my $s;
> 
> cmpthese( 1_000_000, {
> 
>   'BckRef' => sub{ ($s = $str)  =~ s/(C)D/$1F/g; },
>   'Subst' => sub{ ($s = $str) =~ s/CD/CF/g; },
>   'LkBnd' => sub{ ($s = $str) =~ s/(?<=C)D/F/g; },
>   'Index' => sub{
>     $s = $str;
>     while( (my $pos = index($s,'CD') ) > -1 ) {
>       substr($s,($pos+1),1,'F');
>     }
>   }
> });
> 
>            Rate BckRef  LkBnd  Index  Subst
> BckRef 263158/s     --   -47%   -61%   -73%
> LkBnd  500000/s    90%     --   -25%   -48%
> Index  666667/s   153%    33%     --   -31%
> Subst  970874/s   269%    94%    46%     --
> 
> Surprising, no?

No. Capturing is sloooooooow. Apart from that, I would expect the regex
engine to be much faster than your index/substr construction, mostly
because it uses fewer Perl ops. With such a simple pattern the regex
will be optimised into the equivalent of index anyway, and the rx engine
proper won't even be invoked.

If you're really interested, you'll need to benchmark this all again
with 5.10. A lot of work has gone into making the optimiser catch more
'simple' cases.

Ben



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

Date: Wed, 07 Nov 2007 14:56:17 -0800
From:  sivga <arvindkannan1@gmail.com>
Subject: simple question reag search and replace
Message-Id: <1194476177.554213.74490@57g2000hsv.googlegroups.com>

Hi all i need to search for a particular string and replace it in a
file

for eg :input file has

stock 3 99999 6 13456000 -market 1 100 5600 shift 2 rshit 36
stock 300 99999 6 13456000 -market 2 300 5700 shift 2 rshit 312
stock 31234 99999 6 13456000 -market 3 400 5700 shift 2 rshit 3675
stock 456 99999 6 13456000 -market 4 200 5800 shift 2 rshit 30

 .....

99999 in the above lines needs to be replaced with 77777 so the o/p
after replace will be

stock 3 77777 6 13456000 -market 1 100 5600 shift 2 rshit 36
stock 300 77777 6 13456000 -market 2 300 5700 shift 2 rshit 312

How do i do this ?

This does not seem to work ..

while ($line = <AG>) {

  if ($line =~ /stock[ ]+([99999])*/ ) {
   print " The stock is  $line";
   $line =~ s/stock[ ]+([99999])*/stock[ ]+([77777])*/;

}
}


Thanks for the help



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

Date: Thu, 08 Nov 2007 00:33:57 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: simple question reag search and replace
Message-Id: <5pf0bhFqutmdU1@mid.individual.net>

sivga wrote:
> while ($line = <AG>) {
> 
>   if ($line =~ /stock[ ]+([99999])*/ ) {

     if ( $line =~ /stock.+\b99999\b/ ) {

>    print " The stock is  $line";
>    $line =~ s/stock[ ]+([99999])*/stock[ ]+([77777])*/;

     $line =~ s/\b99999\b/77777/;

Where did you get the idea of using square brackets that way?

Have you seen the extensive Perl documentation on regular expressions?

     perldoc perlrequick
     perldoc perlreref
     perldoc perlretut
     perldoc perlre

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Wed, 07 Nov 2007 23:52:42 GMT
From: "John W. Krahn" <krahnj@telus.net>
Subject: Re: simple question reag search and replace
Message-Id: <47324F8E.8A15F285@telus.net>

sivga wrote:
> 
> Hi all i need to search for a particular string and replace it in a
> file
> 
> for eg :input file has
> 
> stock 3 99999 6 13456000 -market 1 100 5600 shift 2 rshit 36
> stock 300 99999 6 13456000 -market 2 300 5700 shift 2 rshit 312
> stock 31234 99999 6 13456000 -market 3 400 5700 shift 2 rshit 3675
> stock 456 99999 6 13456000 -market 4 200 5800 shift 2 rshit 30
> 
> .....
> 
> 99999 in the above lines needs to be replaced with 77777 so the o/p
> after replace will be
> 
> stock 3 77777 6 13456000 -market 1 100 5600 shift 2 rshit 36
> stock 300 77777 6 13456000 -market 2 300 5700 shift 2 rshit 312
> 
> How do i do this ?
> 
> This does not seem to work ..
> 
> while ($line = <AG>) {
> 
>   if ($line =~ /stock[ ]+([99999])*/ ) {

Anything between [ and ] is a character class and any duplicate
characters are discarded so [99999] and [9] and [9999999999999999] all
do exactly the same thing.  Your pattern says that there are only spaces
between 'stock' and '99999' but your data says that there is a number
between them as well.


>    print " The stock is  $line";
>    $line =~ s/stock[ ]+([99999])*/stock[ ]+([77777])*/;

The right hand side of the substitution is just a string *not* a regular
expression.


> }
> }



John
-- 
use Perl;
program
fulfillment


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

Date: Wed, 07 Nov 2007 15:52:46 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: simple question reag search and replace
Message-Id: <071120071552469497%jimsgibson@gmail.com>

In article <1194476177.554213.74490@57g2000hsv.googlegroups.com>, sivga
<arvindkannan1@gmail.com> wrote:

> Hi all i need to search for a particular string and replace it in a
> file
> 
> for eg :input file has
> 
> stock 3 99999 6 13456000 -market 1 100 5600 shift 2 rshit 36
> stock 300 99999 6 13456000 -market 2 300 5700 shift 2 rshit 312
> stock 31234 99999 6 13456000 -market 3 400 5700 shift 2 rshit 3675
> stock 456 99999 6 13456000 -market 4 200 5800 shift 2 rshit 30
> 
> .....
> 
> 99999 in the above lines needs to be replaced with 77777 so the o/p
> after replace will be
> 
> stock 3 77777 6 13456000 -market 1 100 5600 shift 2 rshit 36
> stock 300 77777 6 13456000 -market 2 300 5700 shift 2 rshit 312
> 
> How do i do this ?
> 
> This does not seem to work ..
> 
> while ($line = <AG>) {
> 
>   if ($line =~ /stock[ ]+([99999])*/ ) {

Your regex does not match because there is a number (e.g., '3') between
'stock' and '99999'. 

The '[' and ']' characters create a 'custom character class' that will
match any single character that is part of the class. If you are only
trying to match a space, there is no need to enclose the space ([ ]).

[99999] is a character class comprising the character 9, and is
therefore the same as [9].

If you want to capture all the members of a character class, put the
'*' inside the parenthesis. ([9])* captures only the _last_ 9.

There is no need to capture anything because you do not use what has
been captured.

>    print " The stock is  $line";
>    $line =~ s/stock[ ]+([99999])*/stock[ ]+([77777])*/;

The right side of the substitution operator is not a regular
expression. Therefore, the characters "[]+()*" are plain characters and
will added to the replacement string.

> 
> }
> }

You probably want to do something like this:

  while(<AG>) {
    s/99999/77777/;
  }

or, if that is not specific enough, this will work on your sample input:

  while(<AG>) {
    s/stock(\s+\d+\s+)99999/stock${1}77777/;
  }

-- 
Jim Gibson

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: Thu, 08 Nov 2007 04:15:12 +0100
From: Larry <dontmewithme@got.it>
Subject: thread
Message-Id: <dontmewithme-5CCA23.04151208112007@news.tin.it>

Hi peeps,

        below is the code of a script that spawns a new thread whenever 
it gets a new request:

#!/usr/bin/perl -w

use strict;
use warnings;
use IO::Socket::INET;
use Data::Dumper;
use threads;
use IO::Handle;
STDOUT->autoflush(1);

my $sock = IO::Socket::INET->new(
                           LocalPort => '65001',
                           Proto => 'tcp',
                           Reuse => 1,
                           Listen => 1,
                           Type => SOCK_STREAM
                        ) || die $!;

$sock->listen();

while ( my $client = $sock->accept() )
{

   if ($client)
   {
      $client->autoflush(1);
      
      my $thr = threads->new(\&manage, $client);

      for my $t (threads->list()) {
         printf Dumper(\$t) . " has tid = %d\n", $t->tid();
      }
   }
}

sub manage {

   my $client = shift;
   my $data = <$client>;
   print "$data\n";
   sleep 5;
   syswrite $client, "Hello World!";
   close($client);

}

__END__;

now, I'd like to have all the threads killed before a new thread gets 
spawnd...can it actually be done??

thanks


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

Date: Thu, 8 Nov 2007 02:36:13 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Using perl to watch other programs
Message-Id: <t99a05-57s.ln1@osiris.mauzo.dyndns.org>


Quoth Bill H <bill@ts1000.us>:
> On Nov 7, 10:14 am, Ben Morrow <b...@morrow.me.uk> wrote:
> >
> > The easiest way to do this is with setrlimit: then the OS will kill it
> > for you.
> 
> What is setrlimit?

man 2 setrlimit

Your shell probably has a ulimit builtin that calls setrlimit, or you
can call it from Perl with BSD::Resource. You will want to call it in a
wrapper around the program that you're trying to apply the limit to;
something like

    #!/bin/sh

    ulimit -t 70
    exec /path/to/real/binary

Ben



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

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 V11 Issue 1013
***************************************


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