[28550] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9914 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 1 03:05:53 2006

Date: Wed, 1 Nov 2006 00:05: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, 1 Nov 2006     Volume: 10 Number: 9914

Today's topics:
        [ANNOUNCE] Emacs modules for Perl programming (Jari Aalto+mail.perl)
        Abysmal performance of Net::SFTP (and I have GMP & Pari usenet@DavidFilmer.com
    Re: FAQ 2.2 How can I get a binary version of perl? <brian.d.foy@gmail.com>
    Re: FAQ 3.25 Where can I learn about CGI or Web program <brian.d.foy@gmail.com>
    Re: FAQ 4.29 How can I count the number of occurrences  <brian.d.foy@gmail.com>
    Re: Homemade youtube style (Flash??) videos? <jurgenex@hotmail.com>
    Re: Homemade youtube style (Flash??) videos? <ignoramus18920@NOSPAM.18920.invalid>
    Re: Interesting behaviour with lexical variable <ced@blv-sam-01.ca.boeing.com>
    Re: killing processes using perl (artsd) (reading news)
    Re: killing processes using perl (artsd) (reading news)
    Re: killing processes using perl (artsd) <rvtol+news@isolution.nl>
        Mailbox-style directory hashing s1037989@gmail.com
    Re: Mailbox-style directory hashing <tadmc@augustmail.com>
    Re: Mailbox-style directory hashing s1037989@gmail.com
        new CPAN modules on Wed Nov  1 2006 (Randal Schwartz)
    Re: Perl equivalent to unix script (reading news)
    Re: Perl equivalent to unix script <ignoramus18920@NOSPAM.18920.invalid>
    Re: Problem installing ExtUtils::Command from CPAN <sisyphus1@nomail.afraid.org>
        Regular Expression Question Why Doesn't this Match? <needin4mation@gmail.com>
    Re: Use of uninitialized variable with print << HTMLEND <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 01 Nov 2006 05:24:40 GMT
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: [ANNOUNCE] Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_1162358652@rtfm.mit.edu>

Archive-name: perl-faq/emacs-lisp-modules
Posting-Frequency: 2 times a month
Maintainer: Jari Aalto A T cante net

Announcement: "What Emacs lisp modules can help with programming Perl"

    Preface

        Emacs is your friend if you have to do anything comcerning software
        development: It offers plug-in modules, written in Emacs lisp
        (elisp) language, that makes all your programmings wishes come
        true. Please introduce yourself to Emacs and your programming era
        will get a new light.

    Where to find Emacs/XEmacs

        o   Unix:
            http://www.gnu.org/software/emacs/emacs.html
            http://www.xemacs.org/

        o   Unix Windows port (for Unix die-hards):
            install http://www.cygwin.com/  which includes native Emacs 21.x.
            and XEmacs port

        o   Pure Native Windows port
            http://www.gnu.org/software/emacs/windows/ntemacs.html
            ftp://ftp.xemacs.org/pub/xemacs/windows/setup.exe

        o   More Emacs resources at
            http://tiny-tools.sourceforge.net/  => Emacs resource page

Emacs Perl Modules

    Cperl -- Perl programming mode

        http://math.berkeley.edu/~ilya/software/emacs/
        by Ilya Zakharevich

        CPerl is major mode for editing perl files. Also included in
        latest Emacs, but newest version is at Ilya's site. Note that
        the directrory at CPAN is out of date:
        http://www.cpan.org/modules/by-authors/id/ILYAZ/cperl-mode/

        Compared to default `perl-mode' that comes with Emacs, this
        one has more features.

    TinyPerl -- Perl related utilities

        http://tiny-tools.sourceforge.net/

        If you ever wonder how to deal with Perl POD pages or how to find
        documentation from all perl manpages, this package is for you.
        Couple of keystrokes and all the documentaion is in your hands.

        o   Instant function help: See documentation of `shift', `pop'...
        o   Show Perl manual pages in *pod* buffer
        o   Grep through all Perl manpages (.pod)
        o   Follow POD references e.g. [perlre] to next pod with RETURN
        o   Coloured pod pages with `font-lock'
        o   Separate `tiperl-pod-view-mode' for jumping topics and pages
            forward and backward in *pod* buffer.

        o   Update `$VERSION' variable with YYYY.MMDD on save.
        o   Load source code into Emacs, like Devel::DProf.pm
        o   Prepare script (version numbering) and Upload it to PAUSE
        o   Generate autoload STUBS (Devel::SelfStubber) for you
            Perl Module (.pm)

    TinyIgrep -- Perl Code browsing and easy grepping

        [TinyIgrep is included in Tiny Tools Kit]

        To grep from all installed Perl modules, define database to
        TinyIgrep. There is example file emacs-rc-tinyigrep.el that shows
        how to set up dattabases for Perl5, Perl4 whatever you have
        installed

        TinyIgrep calls Igrep.el to to do the search, You can adjust
        recursive grep options, set search case sensitivity, add user grep
        options etc.

        You can find latest `igrep.el' module at
        <http://groups.google.com/groups?group=gnu.emacs.sources> The
        maintainer is Jefin Rodgers <kevinr@ihs.com>.

    TinyCompile -- To Browse grep results in Emacs *compile* buffer

        TinyCompile is a minor mode for *compile* buffer from where
        you can collapse unwanted lines or shorten file URLs:

            /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file1:NNN: MATCHED TEXT
            /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file2:NNN: MATCHED TEXT

            -->

            cd /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/
            file1:NNN: MATCHED TEXT
            file1:NNN: MATCHED TEXT

End



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

Date: 31 Oct 2006 17:30:40 -0800
From: usenet@DavidFilmer.com
Subject: Abysmal performance of Net::SFTP (and I have GMP & Pari)
Message-Id: <1162344640.624551.69420@f16g2000cwb.googlegroups.com>

Greetings.

I am having terrible problems with very poor performance when using
Net::SFTP.  Specifically, it takes about 10 seconds for a machine to
transfer a 1 MB file to itself (localhost), and this is a brand new,
very FAST, lightly loaded server (and I can replicate this problem on
other machines as well).  Using ordinary FTP takes 0.4 seconds, and
doing the same thing with commandline sftp completes the task in the
blink of an eye.

I ***DO*** have Math::GMP::BigInt installed (as well as
Math::Pari::BigInt), and a diagnostic dump of %INC indicates these are
being called (see below). Enabling SFTP debug mode shows that I am not
experiencing any long pauses (ie, I get a handle in 0.8 seconds, and
transfers occur at a steady - though slow - pace without any pauses).

It is doubtful that I have the option to use Net::SSH2 (because the
servers do not have libssh2 and I probably won't be able to do anything
about that).  I really need to figure out why Net::SFTP is behaving so
poorly.  I really appreciate any insight anyone can offer.

Here is my test script:

#!/usr/bin/perl
   use strict; use warnings;
   use Net::SFTP;

   #Create with: dd if=/dev/urandom of=/tmp/1mb.junk bs=1024 count=1024
   my $testfile = "/tmp/1mb.junk";

   my %comm = (
      user     => 'myuserid',
      password => 'mypassword',
      ssh_args => [ cipher   => 'blowfish-cbc' ],
      debug    => 0,
   );

   my $sftp = Net::SFTP->new('localhost', %comm) or die "oops: $@";

   $sftp->put ($testfile, "$testfile.test")
      or die("ftp put failed ", $sftp->message);

   END{
      print map{"$_\n"} sort keys %INC;   #check for GMP/Pari
   }

__END__


The blowfish cipher is indeed the "fastest" (as the docs indicate).  I
tried the other available ciphers with inferior results:
   arcfour    14 seconds
   3des-cbc   22 seconds


The "interesting" parts of the %INC dump (in the END block of the test
script) look like this (and validate that GMP/Pari are being called):

   Convert/ASN1                         MIME/Base64
   Convert/ASN1/IO                      Math/BigInt
   Convert/ASN1/_decode                 Math/BigInt/GMP
   Convert/ASN1/_encode                 Math/GMP
   Convert/ASN1/parser                  Math/Pari
   Convert/PEM                          Net/SFTP
   Convert/PEM/CBC                      Net/SFTP/Attributes
   Convert/PEM/ErrorHandler             Net/SFTP/Buffer
   Crypt/Blowfish                       Net/SFTP/Constants
   Crypt/DH                             Net/SFTP/Util
   Crypt/DSA                            Net/SSH/Perl
   Crypt/DSA/Key                        Net/SSH/Perl/Agent
   Crypt/DSA/Key/PEM                    Net/SSH/Perl/Auth
   Crypt/DSA/KeyChain                   Net/SSH/Perl/Auth/Password
   Crypt/DSA/Signature                  Net/SSH/Perl/Auth/PublicKey
   Crypt/DSA/Util                       Net/SSH/Perl/AuthMgr
   Crypt/Random                         Net/SSH/Perl/Buffer
   Crypt/Random/Generator               Net/SSH/Perl/Channel
   Crypt/Random/Provider/File           Net/SSH/Perl/ChannelMgr
   Crypt/Random/Provider/devurandom     Net/SSH/Perl/Cipher
   Digest/HMAC                          Net/SSH/Perl/Cipher/Blowfish
   Digest/HMAC_MD5                      Net/SSH/Perl/Cipher/CBC
   Digest/HMAC_SHA1                     Net/SSH/Perl/Comp
   Digest/MD5                           Net/SSH/Perl/Config
   Digest/SHA1                          Net/SSH/Perl/Constants
   Digest/base                          Net/SSH/Perl/Kex
   Encode                               Net/SSH/Perl/Kex/DH1
   Encode/Alias                         Net/SSH/Perl/Key
   Encode/Config                        Net/SSH/Perl/Key/DSA
   Encode/Encoding                      Net/SSH/Perl/Mac
   Fcntl                                Net/SSH/Perl/Packet
   IO                                   Net/SSH/Perl/SSH2
   IO/Handle                            Net/SSH/Perl/Util
   IO/Select                            Net/SSH/Perl/Util/Hosts
   IO/Socket                            Net/SSH/Perl/Util/SSH2MP
   IO/Socket/INET                       Net/SSH/Perl/Util/Term
   IO/Socket/UNIX


I ran the script thorough Devel::Profile (perl -d:Profile test.pl); the
top results (> 1.0%) are:

  time elapsed (wall):   12.8377
  time running program:  9.6744  (75.36%)
  time profiling (est.): 3.1633  (24.64%)
  number of calls:       361634
  number of exceptions:  11

  %Time  Sec.  #calls  sec/call  name
  28.05  2.714 131970  0.000021  Crypt::Blowfish::encrypt
  23.32  2.256    139  0.016228  Net::SSH::Perl::Cipher::CBC::encrypt
  10.08  0.975    282  0.003458  IO::Select::select
   5.53  0.535     32  0.016733  IO::Select::can_read
   4.51  0.437 132840  0.000003  Crypt::Blowfish::crypt
   2.78  0.269     59  0.004553  Net::SSH::Perl::Util::SSH2MP::bin2mp
   2.52  0.244    144  0.001693  Net::SSH::Perl::Util::SSH2MP::mp2bin
   1.47  0.142   1035  0.000137  Net::SSH::Perl::Buffer::new
   1.25  0.121    449  0.000269  Net::SSH::Perl::Packet::read_poll_ssh2
   1.12  0.109   1041  0.000104  Net::SSH::Perl::Util::import

So the machine is definitely spending most of its time with the crypto
stuff (not I/O stuff), which is to be expected, but it is taking a LONG
time to do the crypto stuff.

I know that Math::BigInt::GMP (or Pari) is very important for SFTP
performance.  But I have both libraries and their BigInt modules
installed.  Is there ANOTHER math module that I need???

I'm happy to entertain any "try this and see what happens" ideas.

Thanks!

--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)



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

Date: Tue, 31 Oct 2006 21:43:53 -0600
From: brian d  foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 2.2 How can I get a binary version of perl?
Message-Id: <311020062143535303%brian.d.foy@gmail.com>

In article <4545b0aa$0$12144$88260bb3@free.teranews.com>, Tintin
<tintin@invalid.invalid> wrote:

> "PerlFAQ Server" <brian@stonehenge.com> wrote in message 
> news:n6og14-opb.ln1@blue.stonehenge.com...


> > 2.2: How can I get a binary version of perl?

> Surely a mention of ActivePerl is appropriate here.

Indeed, it is. I'll add it.  Thanks,

-- 
Posted via a free Usenet account from http://www.teranews.com



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

Date: Tue, 31 Oct 2006 21:43:12 -0600
From: brian d  foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 3.25 Where can I learn about CGI or Web programming in Perl?
Message-Id: <311020062143122844%brian.d.foy@gmail.com>

In article <3s9ek2di0jc1tc48tbbebnrhon0hk5he6r@4ax.com>, Michele Dondi
<bik.mido@tiscalinet.it> wrote:

> On Mon, 30 Oct 2006 18:03:03 -0800, PerlFAQ Server
> <brian@stonehenge.com> wrote:
> 
> >3.25: Where can I learn about CGI or Web programming in Perl?
> 
> Although I'm sure quite about anybody may have his/her own favourite
> resource to share, since it's also true that a lot of *bad* ones do
> float around, one may also mention Ovid's CGI Course

Ah, yes, good idea. I'll add it to the CGI Meta FAQ.  Thanks,

-- 
Posted via a free Usenet account from http://www.teranews.com



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

Date: Tue, 31 Oct 2006 21:42:14 -0600
From: brian d  foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 4.29 How can I count the number of occurrences of a substring within a string?
Message-Id: <311020062142149337%brian.d.foy@gmail.com>

In article <lmaek25ub711goots3shtq2jirbpt1mf5d@4ax.com>, Michele Dondi
<bik.mido@tiscalinet.it> wrote:

> On Fri, 27 Oct 2006 15:41:50 -0500, brian d  foy
> <brian.d.foy@gmail.com> wrote:
> 
> >In article <1161955782.576895.233190@h48g2000cwc.googlegroups.com>,
> >werwer <drubnone@yahoo.com> wrote:

> >split() in scalar context is deprecated because of its side effects.
> >See perlfunc.

> I was about to say that you're wrong and that would be in *void*
> context. However I checked and not surprisingly it turned out that *I*
> am wrong. Still, one may wonder why *that* behaviour was chosen in the
> first place: 

The answer always seems to be "it made sense at the time" :)

-- 
Posted via a free Usenet account from http://www.teranews.com



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

Date: Wed, 01 Nov 2006 02:11:27 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Homemade youtube style (Flash??) videos?
Message-Id: <jnT1h.7948$gf5.6849@trndny01>

Ignoramus18920 wrote:
> That's all nice. What I would like, though, is to also add
> functionality to generate whatever Youtube is doing to make videos
> that you can see embedded in a page, with the pause and resume buttons
> etc. I assume that it is a Flash presentation.

Well, just show us the HTML output that you want your Perl CGI script to 
generate (expected behaviour), the relevant part of your existing Perl code 
(such that we can investigate what is not working), and the the current 
output of your script (observed behaviour).
I'm sure someone can help you to fix the script such that it will generate 
the desired output.

If it is something else you are looking for then you are in the wrong NG.

Oh, and BTW: Do you really believe changing your email address continuously 
will fool anyone?

jue 




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

Date: Wed, 1 Nov 2006 02:55:29 +0000 (UTC)
From: Ignoramus18920 <ignoramus18920@NOSPAM.18920.invalid>
Subject: Re: Homemade youtube style (Flash??) videos?
Message-Id: <e5ns2.kr6.19.1@news.alt.net>

On Wed, 01 Nov 2006 02:11:27 GMT, Jürgen Exner <jurgenex@hotmail.com> wrote:
> Ignoramus18920 wrote:
>> That's all nice. What I would like, though, is to also add
>> functionality to generate whatever Youtube is doing to make videos
>> that you can see embedded in a page, with the pause and resume buttons
>> etc. I assume that it is a Flash presentation.
>
> Well, just show us the HTML output that you want your Perl CGI script to 
> generate (expected behaviour), the relevant part of your existing Perl code 
> (such that we can investigate what is not working), and the the current 
> output of your script (observed behaviour).
> I'm sure someone can help you to fix the script such that it will generate 
> the desired output.

I posted a sample page in this thread. 

i

> If it is something else you are looking for then you are in the wrong NG.
>
> Oh, and BTW: Do you really believe changing your email address continuously 
> will fool anyone?
>
> jue 
>
>


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

Date: Tue, 31 Oct 2006 22:54:51 GMT
From: Charles DeRykus <ced@blv-sam-01.ca.boeing.com>
Subject: Re: Interesting behaviour with lexical variable
Message-Id: <J80vnD.8G2@news.boeing.com>

Ferry Bolhar wrote:
> Michele Dondi:
> 
>>   print '[anon]';
>>   print &$_ for
>>     map { my $x=$_; sub () { $x } }
>>     qw/foo bar baz/;
> 
> In this code, "sub" acts as an _operator_ and therefore
> is evaluated for every loop iteration at run-time, yielding
> a new value for $x each time.
> 
>>   print '[named]';
>>   print &$_ for
>>     map { my $x=$_; sub foo () { $x }; \&foo }
>>     qw/foo bar baz/;
> 
> In this code, "sub" acts as a _declarator_, getting
> evaluated only once because the function declaration
> is processed at compile time. Therefore, the first value
> for $x will be retained. It's jst another kind of loop as
> in my example.
> 
> Still leaving the question open, why, when declaring
> your second example as function and call it in the main
> code, Perl will issue the "will not stay shared" message,
> while running the code as-is, it does not, as in these
> examples:
> 
> {                                   sub f {
>    my $r;                          my $r;
>    sub x { $r }                  sub x { $r }
> }                                  }
> 
> -- No message --         Variable "$r" will not stay shared...
> 
> And still leaving the question open, why this code _works_
> as expected:
> 
> {
>   my $r = 1;
>   sub f { print $r }
>   f();       # print 1
>   $r++;
>   f();       # print 2
> }
> 
> although, as mentioned in previous postings, in this case,
> function f is evaluated (compiled) only once?
> 
> BTW: again, when writing this as function, Perl still will
> issue the "will not stay shared" message, although here,
> $r will stay shared!

One of the key issues seems to be nesting of sub's rather than
just nesting a sub in a bare block.

Full diagnostics for instance clarify precisely the behaviour
of the examples in your intial post :

echo 'Variable "$num" will not stay shared' | splain -v

(W closure) An inner (nested) named subroutine is referencing a
lexical variable defined in an outer subroutine.

When the inner subroutine is called, it will probably see the value of
the outer subroutine's variable as it was before and during the *first*
call to the outer subroutine; in this case, after the first call to the
outer subroutine is complete, the inner and outer subroutines will no
longer share a common value for the variable.  In other words, the
variable will no longer be shared.

Furthermore, if the outer subroutine is anonymous and references a
lexical variable outside itself, then the outer and inner subroutines
will never share the given variable.

This problem can usually be solved by making the inner subroutine
anonymous, using the sub {} syntax.  When inner anonymous subs that
reference variables in outer subroutines are called or referenced, they
are automatically rebound to the current values of such variables.

-- 
Charles DeRykus




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

Date: Wed, 01 Nov 2006 03:58:36 GMT
From: "Mumia W. (reading news)" <paduille.4060.mumia.w@earthlink.net>
Subject: Re: killing processes using perl (artsd)
Message-Id: <MXU1h.538$ig4.433@newsread2.news.pas.earthlink.net>

On 10/31/2006 12:37 PM, andreas wrote:
> Hello all,
> 
> I'm using an unstable debian distribution (Debian 2.6.18-3) and at some
> day I found several artsd processes running in the process list. Normally
> there should be only one sound server.
> 
> Now I started thinking about how to reduce the artsd process count using a
> perl script and wrote something which works and can possibly be used to
> remove any processes (cron etc.)
> 
> #!/usr/bin/perl -w
> # file: killartsd.pl
> # kill additional artsd processes - only one is required! 
> # (c)2006 Andreas Mueller andreas%at%poipoi.de 
> #####################################
> 
> # get artsd process ids from ps piped into a sed script 
> $plist=qx'ps h -C artsd | sed "s/\(\([ 0-9]*\|[0-9]*\).*\)/\2/g"';
> 
> # remove space+newline to form a list of pids 
> $plist =~ s/ \n/,/g;
> 
> # remove the ugly last comma in that list $plength=length($plist);
> $plist=substr($plist,0,$plength-1) unless $plength < 1 ;
> 
> # convert result to an array because kill() wants an array, isn't it?
> @parray=split(/,/,$plist);
> 
> # how many process ids are there?
> $numproc=@parray;
> 
> # kill all unless there is only one or none
> kill ('KILL',@parray) unless $numproc < 2 ;
> 
> My question is whether one knows a better way to do the whole thing
> or parts of the script?
> 
> best regards
> -andreas

#!/bin/sh
PIDLIST=`ps h -C artsd -o %p`
for arpid in $PIDLIST
do
     echo "Would kill $arpid"
done
--------------------------
#!/usr/bin/perl
use strict;
use warnings;
use Carp qw(carp croak);
my @pids = `ps h -C mysqld` =~ m/^ +(\d+)/mg;
print "PIDS: @pids\n";
kill (15, $_) or carp("Failure: $! for $_")
   for (@pids);

__END__

Note: the second program (in Perl) attempts to kill mysqld.

-- 
paduille.4060.mumia.w@earthlink.net



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

Date: Wed, 01 Nov 2006 06:58:41 GMT
From: "Mumia W. (reading news)" <paduille.4060.mumia.w@earthlink.net>
Subject: Re: killing processes using perl (artsd)
Message-Id: <BAX1h.641$ig4.123@newsread2.news.pas.earthlink.net>

On 10/31/2006 09:58 PM, Mumia W. (reading news) wrote:
> On 10/31/2006 12:37 PM, andreas wrote:
>> Hello all,
>>
>> I'm using an unstable debian distribution (Debian 2.6.18-3) and at some
>> day I found several artsd processes running in the process list. Normally
>> there should be only one sound server.
>>
>> Now I started thinking about how to reduce the artsd process count 
>> using a
>> perl script and wrote something which works and can possibly be used to
>> remove any processes (cron etc.)
>>
>> #!/usr/bin/perl -w
>> # file: killartsd.pl
>> # kill additional artsd processes - only one is required! # (c)2006 
>> Andreas Mueller andreas%at%poipoi.de 
>> #####################################
>>
>> # get artsd process ids from ps piped into a sed script $plist=qx'ps h 
>> -C artsd | sed "s/\(\([ 0-9]*\|[0-9]*\).*\)/\2/g"';
>>
>> # remove space+newline to form a list of pids $plist =~ s/ \n/,/g;
>>
>> # remove the ugly last comma in that list $plength=length($plist);
>> $plist=substr($plist,0,$plength-1) unless $plength < 1 ;
>>
>> # convert result to an array because kill() wants an array, isn't it?
>> @parray=split(/,/,$plist);
>>
>> # how many process ids are there?
>> $numproc=@parray;
>>
>> # kill all unless there is only one or none
>> kill ('KILL',@parray) unless $numproc < 2 ;
>>
>> My question is whether one knows a better way to do the whole thing
>> or parts of the script?
>>
>> best regards
>> -andreas
> 
> #!/bin/sh
> PIDLIST=`ps h -C artsd -o %p`
> for arpid in $PIDLIST
> do
>     echo "Would kill $arpid"
> done
> --------------------------
> #!/usr/bin/perl
> use strict;
> use warnings;
> use Carp qw(carp croak);
> my @pids = `ps h -C mysqld` =~ m/^ +(\d+)/mg;
> print "PIDS: @pids\n";
> kill (15, $_) or carp("Failure: $! for $_")
>   for (@pids);
> 
> __END__
> 
> Note: the second program (in Perl) attempts to kill mysqld.
> 

Uhhh, I wish all news-servers supported cancels. The programs I wrote 
kill all the servers--not only the extra ones.

Let me try that again:

#!/bin/sh
PIDLIST=`ps h -C artsd -o %p | sed -ne '2,$p'`
for arpid in $PIDLIST
do
     echo "Would kill $arpid"
done
-----------------------------------
#!/usr/bin/perl
use strict;
use warnings;
use Carp qw(carp croak);
my @pids = `ps h -C artsd` =~ m/^ +(\d+)/mg;
shift @pids;
print "PIDS: @pids\n";
kill (15, $_) or carp("Failure: $! for $_")
   for (@pids);


-- 
paduille.4060.mumia.w@earthlink.net



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

Date: Wed, 1 Nov 2006 08:44:04 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: killing processes using perl (artsd)
Message-Id: <ei9mrr.1f8.1@news.isolution.nl>

andreas schreef:


> Now I started thinking about how to reduce the artsd process count
> using a perl script and wrote something which works and can possibly
> be used to remove any processes (cron etc.)
> 
> #!/usr/bin/perl -w
> # file: killartsd.pl
> # kill additional artsd processes - only one is required!
> # (c)2006 Andreas Mueller andreas%at%poipoi.de
> #####################################

Remove the -w, and add:

  use warnings ;
  use strict ;

> # get artsd process ids from ps piped into a sed script
> $plist=qx'ps h -C artsd | sed "s/\(\([ 0-9]*\|[0-9]*\).*\)/\2/g"';

Whitespace is cheap. The sed-stuff can also be done in Perl of course. 
See "Pipe Opens" in perlopentut.

That regex doesn't mean what you think it means. Compare to:
  s/ *\([0-9]*\).*/\1/g


> # remove space+newline to form a list of pids
> $plist =~ s/ \n/,/g;
> 
> # remove the ugly last comma in that list $plength=length($plist);
> $plist=substr($plist,0,$plength-1) unless $plength < 1 ;
> 
> # convert result to an array because kill() wants an array, isn't it?
> @parray=split(/,/,$plist);

In stead of the 8 lines above, try this:

  my @parray = split / \n/, $plist ;


> # how many process ids are there?
> $numproc=@parray;
> 
> # kill all unless there is only one or none
> kill ('KILL',@parray) unless $numproc < 2 ;
> 
> My question is whether one knows a better way to do the whole thing
> or parts of the script?



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

  my @pids = do
  { local $/ ;
    open my $ph, '-|', 'ps h -C artsd' or die "open ps: $!" ;
    <$ph> =~ m/^ *([0-9]+)/gm ;
  } ;

  print "Pa: ", getppid(), "\n" ;
  print "Me: $$\n\n" ;
  print "kill '$_'\t?\n" for @pids ;

-- 
Affijn, Ruud

"Gewoon is een tijger."


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

Date: 31 Oct 2006 15:40:04 -0800
From: s1037989@gmail.com
Subject: Mailbox-style directory hashing
Message-Id: <1162338004.290232.3140@b28g2000cwb.googlegroups.com>

I whipped up this quick and ugly script and I wanted to post it for
code review and others' benefit.

With an array such as:
qw(aaaa aaab aaac bbbb bccc bcdd bcee bcff cccc dddd)

The program returns:
# perl list2fs.pl 2
/a/aa/aaa/aaaa/aaaa
/a/aa/aaa/aaab/aaab
/a/aa/aaa/aaac/aaac
/b/bb/bbbb
/b/bc/bcc/bccc
/b/bc/bcd/bcdd
/b/bc/bce/bcee
/b/bc/bcf/bcff
/c/cccc
/d/dddd

Now as you can see, what this program does is take a list of filenames
and "hashifies" it like mailbox storing allowing no more than 2 (or
whatever $ARGV[0] is) filenames to be in a single directory.  The
point, obviously, is if you have 100000 filenames and ext3 won't store
100000 files in a single directory, you can use this technique to break
them down.

I had to make it recursive because I'm dealing with unknown data.  I
don't know that 3 levels or even 6 levels will suffice.  Therefore, the
recursion figures it out.

Now, that said, this is NOT intended for "hashifying" mail storage
dirs.  It IS intended to "hashify" a HUGE list of filenames.
Unfortunately this code is VERY inefficient.  So, I post it here so
people can see my idea if it helps, and so that people can maybe direct
me to an existing CPAN module that would accomplish the same thing?
Or, perhaps someone likes what I've started and wants to help improve
the code?

---------------------
#!/usr/bin/perl -w

use strict;
$ARGV[0] ||= 1;

#my @list = map { chomp; $_ } <STDIN>;
my @list = @_ = qw(aaaa aaab aaac bbbb bccc bcdd bcee bcff cccc dddd);

my %hash = a(1, \@list);
b('', %hash);

sub a {
        my %list = map { lc(substr($_, 0, $_[0])) => 1 } @{$_[1]};
        my %hash = ();
        foreach my $hash ( keys %list ) {
                my @hash = grep { lc(substr($hash, 0)) eq lc(substr($_,
0, length($hash))) } @{$_[1]};
                if ( $#hash >= $ARGV[0] ) {
                        %{$hash{$hash}} = a($_[0]+1, \@hash);
                } elsif ( $#hash >= 0 ) {
                        %{$hash{$hash}} = map { lc($_) => 1 } @hash;
                } elsif ( $#hash == -1 ) {
#                       %{$hash{$hash}} = ();
                }
        }
        return %hash;
}

sub b {
        my ($root, %hash) = @_;
        foreach ( sort keys %hash ) {
                if ( ref $hash{$_} eq 'HASH' ) {
                        b($root.'/'.$_, %{$hash{$_}});
                } else {
                        print "$root/$_\n";
                }
        }
}



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

Date: Tue, 31 Oct 2006 18:30:27 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Mailbox-style directory hashing
Message-Id: <slrnekfql3.6kb.tadmc@tadmc30.august.net>

s1037989@gmail.com <s1037989@gmail.com> wrote:

> Or, perhaps someone likes what I've started and wants to help improve
> the code?
>
> ---------------------
> #!/usr/bin/perl -w


   use warnings;

Lexical warnings are a big improvement over global warnings.


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


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

Date: 31 Oct 2006 21:13:20 -0800
From: s1037989@gmail.com
Subject: Re: Mailbox-style directory hashing
Message-Id: <1162358000.515720.82940@b28g2000cwb.googlegroups.com>


Tad McClellan wrote:
> s1037989@gmail.com <s1037989@gmail.com> wrote:
>
> > Or, perhaps someone likes what I've started and wants to help improve
> > the code?
> >
> > ---------------------
> > #!/usr/bin/perl -w
>
>
>    use warnings;
>
> Lexical warnings are a big improvement over global warnings.

Interesting...!  Why is that?

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



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

Date: Wed, 1 Nov 2006 05:42:11 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Wed Nov  1 2006
Message-Id: <J81EIB.yJ2@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

AnyEvent-2.0
http://search.cpan.org/~mlehmann/AnyEvent-2.0/
provide framework for multiple event loops
----
Audio-XMMSClient-0.02
http://search.cpan.org/~flora/Audio-XMMSClient-0.02/
Interface to the xmms2 music player
----
Bundle-CPAN-1.854
http://search.cpan.org/~andk/Bundle-CPAN-1.854/
Bundle to optimize the behaviour of CPAN.pm
----
Bundle-Parrot-0.4.6_01
http://search.cpan.org/~particle/Bundle-Parrot-0.4.6_01/
Bundle of modules required for developing and testing Parrot
----
Bundle-SZABGAB-0.01
http://search.cpan.org/~szabgab/Bundle-SZABGAB-0.01/
Bundle of some "stable" version of modules
----
Class-Simple-0.04
http://search.cpan.org/~sullivan/Class-Simple-0.04/
Simple Object-Oriented Base Class
----
Config-LotusNotes-0.23
http://search.cpan.org/~albers/Config-LotusNotes-0.23/
Access Lotus Notes/Domino configuration
----
EOL-v0.0.2
http://search.cpan.org/~twylie/EOL-v0.0.2/
This module aids in the conversion of text file newline characters within the context of other perl code; includes command line executable.
----
File-Copy-Recursive-0.29
http://search.cpan.org/~dmuey/File-Copy-Recursive-0.29/
Perl extension for recursively copying files and directories
----
Geo-Spline-0.01
http://search.cpan.org/~mrdvt/Geo-Spline-0.01/
Calculate geographic locations between GPS fixes.
----
Mail-Audit-2.212
http://search.cpan.org/~rjbs/Mail-Audit-2.212/
Library for creating easy mail filters
----
Net-Google-Calendar-0.5
http://search.cpan.org/~simonw/Net-Google-Calendar-0.5/
programmatic access to Google's Calendar API
----
Number-Phone-Normalize-0.10_20061031
http://search.cpan.org/~cfaerber/Number-Phone-Normalize-0.10_20061031/
Normalizes format of Phone Numbers.
----
Object-InsideOut-2.17
http://search.cpan.org/~jdhedden/Object-InsideOut-2.17/
Comprehensive inside-out object support module
----
PPI-1.199_01
http://search.cpan.org/~adamk/PPI-1.199_01/
Parse, Analyze and Manipulate Perl (without perl)
----
SRU-0.95
http://search.cpan.org/~bricas/SRU-0.95/
Search and Retrieval by URL
----
SVN-Notify-Config-0.0901
http://search.cpan.org/~jpeacock/SVN-Notify-Config-0.0901/
Config-driven Subversion notification
----
SVN-Notify-Mirror-0.03401
http://search.cpan.org/~jpeacock/SVN-Notify-Mirror-0.03401/
Keep a mirrored working copy of a repository path
----
Sledge-Plugin-AutoTmplDirname-0.01
http://search.cpan.org/~tokuhirom/Sledge-Plugin-AutoTmplDirname-0.01/
auto generate the template directory name
----
UML-Class-Simple-0.02
http://search.cpan.org/~agent/UML-Class-Simple-0.02/
Render simple UML class diagrams, often by loading the code.
----
UML-Class-Simple-0.03
http://search.cpan.org/~agent/UML-Class-Simple-0.03/
Render simple UML class diagrams, by loading the code
----
WWW-BugMeNot-0.01
http://search.cpan.org/~kentaro/WWW-BugMeNot-0.01/
Get anonymously shared accounts for online services from BugMeNot
----
WWW-PkgFind-1.3.1
http://search.cpan.org/~bryce/WWW-PkgFind-1.3.1/
Spiders given URL(s) mirroring wanted files and triggering post-processing (e.g. tests) against them.
----
XML-Traverse-ParseTree-0.03
http://search.cpan.org/~mbusik/XML-Traverse-ParseTree-0.03/
iterators and getters for xml-access
----
threads-1.47
http://search.cpan.org/~jdhedden/threads-1.47/
Perl interpreter-based threads
----
vptk-2.16
http://search.cpan.org/~felixl/vptk-2.16/
Perl/Tk Visual resource editor (canvas edition)


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
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: Wed, 01 Nov 2006 03:58:33 GMT
From: "Mumia W. (reading news)" <paduille.4060.mumia.w@earthlink.net>
Subject: Re: Perl equivalent to unix script
Message-Id: <JXU1h.535$ig4.109@newsread2.news.pas.earthlink.net>

> Quoth "Mike" <mikedawg@gmail.com>:
>> Ok. . . Well, I'm sure here comes another dumb question.  I'm fairly
>> handy with unix and unix scripting, however, I'm terrible at perl.
>>
>> What I'm looking to do with a perl script is the equivalent of the
>> following unix (bash) script:
>>
>> cat tempfile1 | sort > newfile2; rm tempfile1
>>
>> I'm not completely comfortable with file handling in perl, and I think
>> it should be easy to do, but I've been unsuccessful in trying to do it.

It looks like a one-liner in Perl.

perldoc File::Slurp
perldoc -f sort


-- 
paduille.4060.mumia.w@earthlink.net


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

Date: Wed, 1 Nov 2006 04:45:58 +0000 (UTC)
From: Ignoramus18920 <ignoramus18920@NOSPAM.18920.invalid>
Subject: Re: Perl equivalent to unix script
Message-Id: <e5ub8.338.17.1@news.alt.net>

On Wed, 01 Nov 2006 03:58:33 GMT, Mumia W. (reading news) <paduille.4060.mumia.w@earthlink.net> wrote:
>> Quoth "Mike" <mikedawg@gmail.com>:
>>> Ok. . . Well, I'm sure here comes another dumb question.  I'm fairly
>>> handy with unix and unix scripting, however, I'm terrible at perl.
>>>
>>> What I'm looking to do with a perl script is the equivalent of the
>>> following unix (bash) script:
>>>
>>> cat tempfile1 | sort > newfile2; rm tempfile1
>>>
>>> I'm not completely comfortable with file handling in perl, and I think
>>> it should be easy to do, but I've been unsuccessful in trying to do it.
>
> It looks like a one-liner in Perl.
>
> perldoc File::Slurp
> perldoc -f sort
>
>

Now try sorting a 4 GB file with that... Something that GNU sort can
easily do...

i


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

Date: Wed, 1 Nov 2006 10:31:37 +1100
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Problem installing ExtUtils::Command from CPAN
Message-Id: <4547ddfa$0$29329$afc38c87@news.optusnet.com.au>


"Vincent Foley" <vfoley@gmail.com> wrote in message
news:1162296362.431983.202500@k70g2000cwa.googlegroups.com...
 .
 .
>
> Also, I would be interested to know if you guys think I should compile
> Perl5 from scratch instead of using the Ubuntu-provided packages; I
> know the Ruby guys strongly recommend against using the Debian package
> of Ruby because it lacks all sorts of modules that are normally
> installed by default.
>

On my Mandrake box I leave the perl that comes with the OS (in /usr/bin)
alone - since the OS actually needs it, and I don't want to inadvertently
jigger something up.

Instead the perl that *I* use on that box (which I built myself from source)
is in /usr/local/bin.

I think it's good general advice to do it that way. It might not be
*necessary* to do that .... but it's a fairly safe way of going about
things.

Cheers,
Rob




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

Date: 31 Oct 2006 19:51:45 -0800
From: "jm" <needin4mation@gmail.com>
Subject: Regular Expression Question Why Doesn't this Match?
Message-Id: <1162353105.579594.252160@m7g2000cwm.googlegroups.com>


/([\w\s\.\'\-]*)

does not match this:

    My Fictional Co.

But it does match

    Product by abc company

I don't understand why it matches the second one, but not the first.
Doesn't my expresionsay match anything that has a word, space, dot,
apostrophe, or a hyphen, one or more times?  Thefirst one has a . in it
and it should work.  It does work on others like:

    Dr. Smith's

Thank you for any help.



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

Date: Tue, 31 Oct 2006 18:22:34 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Use of uninitialized variable with print << HTMLEND (and $ENV)
Message-Id: <slrnekfq6a.6fc.tadmc@tadmc30.august.net>

kevinwhite@bellsouth.net <kevinwhite@bellsouth.net> wrote:
> I am trying to fix some code I inherited, and there are many warnings I
> would like to clean up.  The biggest offenders are as follows:
>
> print <<"HTMLEND"; #<= this causes an uninitialized variable warning...


No it doesn't.


><html><head></head><body></body></html>
> HTMLEND


There are no variables there, so there can be no variables
with an undef value to trigger the warning.

Something else is going on, but since we have neither a complete
program, nor the actual text of the error message (hint), we
can do nothing to help you on this one...


> The second example is:
> my $htmlfile = "";
> my $hide = "";
>
> $htmlfile = param('filename');
> $hide = param('hide') || "no"; #<= what does this do?


Selects a default value of "no" if there is no "hide" parameter.


> if ($htmlfile eq "default.html")  #<= this causes an uninitialized


There there must also have been no "filename" parameter.

Maybe you should select a default for that one too?


> The third problem I have is printing environment variables when I have
> "use strict" enabled.  What is the legal way to do this?
>
> I have:
> my $n;
> my @keys;
> my @values;
> my $Item;


You should instead declare your variables upon their first use,
rather than ahead of time.


> @keys = keys %ENV;
> @values %ENV;


my @values = values %ENV;


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


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

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


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