[22075] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4297 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 20 14:06:15 2002

Date: Fri, 20 Dec 2002 11:05:11 -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           Fri, 20 Dec 2002     Volume: 10 Number: 4297

Today's topics:
        ANNOUNCE: OpenInteract 1.55 released <chris@cwinters.com>
        ANNOUNCE: SPOPS 0.72 released <chris@cwinters.com>
    Re: ARG! Anyone using Math:GMP on Solaris 8 (Daniel Berger)
    Re: enviroment variable set (Tad McClellan)
    Re: enviroment variable set <family2@aracnet.com>
    Re: enviroment variable set (Tad McClellan)
    Re: help:  perl script to make all DNA sequence Nmers? <dtweed@acm.org>
    Re: help:  perl script to make all DNA sequence Nmers? ctcgag@hotmail.com
    Re: how do I split large file into separate files? (Tad McClellan)
        how to use system to send data to a command that ask fo <nospam@nospam.org>
    Re: how to use system to send data to a command that as <ian@WINDOZEdigiserv.net>
    Re: how to use system to send data to a command that as <carlos@pez.dk>
    Re: how to use system to send data to a command that as <nospam@nospam.org>
    Re: how to use system to send data to a command that as <ian@WINDOZEdigiserv.net>
    Re: how to use system to send data to a command that as <thepoet@nexgo.de>
    Re: incorporating off-site content <wsegrave@mindspring.com>
    Re: Installing an event handler with use / require? <nobull@mail.com>
    Re: Installing an event handler with use / require? <nobull@mail.com>
    Re: part of speech tagger written in perl (Arthur T. Murray)
    Re: Precedence of => (was Re: Why does Perl handle "ret (Peter Scott)
    Re: Re: enviroment variable set <jurgenex@hotmail.com>
    Re: Replacing text strings contains more than 1 dot (Tad McClellan)
    Re: search and replace text in many files <ddunham@redwood.taos.com>
    Re: SSH: remote protocol version not found (Leaffoot)
    Re: Tied Filehandles <rick.delaney@rogers.com>
    Re: Wanted Help to implement search for my intRAnet sit (Helgi Briem)
    Re: Wierd loop/chdir behavior (Tad McClellan)
    Re: xmlgrep <mirod@xmltwig.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 20 Dec 2002 09:00:51 -0500
From: Chris Winters <chris@cwinters.com>
Subject: ANNOUNCE: OpenInteract 1.55 released
Message-Id: <3e03406c_7@news.teranews.com>

A new version (1.55) of OpenInteract has been released to
CPAN. OpenInteract is an extensible web application server built on
Apache, mod_perl, the Template Toolkit and SPOPS object persistence.

This is a minor upgrade. A few packages have been updated, you can now
subclass the interface generator which makes it easier to substitute
your own base template, you can specify a custom temporary library
directory, and some other minor changes.

Source (also via CPAN):
 http://prdownloads.sourceforge.net/openinteract/OpenInteract-1.55.tar.gz?download

Detailed changes:
 http://sourceforge.net/project/shownotes.php?group_id=16810&release_id=129206

Thanks!

Chris

-- 
Chris Winters (chris@cwinters.com)
Building enterprise-capable snack solutions since 1988.




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

Date: Fri, 20 Dec 2002 09:01:18 -0500
From: Chris Winters <chris@cwinters.com>
Subject: ANNOUNCE: SPOPS 0.72 released
Message-Id: <3e034075$1_7@news.teranews.com>

A new version (0.72) of SPOPS (Simple Perl Object Persistence with
Security) has been released to CPAN. SPOPS is a robust and powerful
module that allows you to serialize objects to DBI, LDAP and GDBM
datasources. You can create most objects without any code, just
configuration.

This release is primarily to update the documentation with the new
SPOPS website and Sourceforge project. It also has a few small
bugfixes.

URLs:

New website and SF project home:
  http://spops.sourceforge.net/
  http://sourceforge.net/projects/spops/

Download (or use CPAN):
  http://prdownloads.sourceforge.net/openinteract/SPOPS-0.72.tar.gz

Detailed changes:
 https://sourceforge.net/project/shownotes.php?group_id=69468&release_id=129209

Thanks!

Chris

-- 
Chris Winters (chris@cwinters.com)
Building enterprise-capable snack solutions since 1988.




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

Date: 20 Dec 2002 08:07:37 -0800
From: djberg96@hotmail.com (Daniel Berger)
Subject: Re: ARG! Anyone using Math:GMP on Solaris 8
Message-Id: <6e613a32.0212200807.1f40f814@posting.google.com>

Chucky <chuck.carson@syrrx.com> wrote in message news:<3DFF5322.9060300@syrrx.com>...
> Here is the latest compile attempt, using gcc-3.2 on Solaris 8:
> 
> 
> 
> Rod wrote:
> > "Chucky" <chuck.carson@syrrx.com> wrote in message
> > news:3DFF457A.9020302@syrrx.com...
> > 
> >>Why is Math:GMP such a pain in the ass to build on Solaris? I need this
> >>module in order to use Net::SSH::Perl, however the underlying
> >>troublespot is the Math::Pari module. I have tried every version over
> >>the last 2 years.rm -f libpari.so.2.1.4
> /usr/local/bin/ld -o libpari.so.2.1.4 -shared -soname libpari.so.1 -lc 
> -lm kernel.o mp.o alglin1.o alglin2.o arith1.o arith2.o base1.o base2.o 
> base3.o base4.o base5.o bibli1.o bibli2.o buch1.o buch2.o buch3.o 
> buch4.o galconj.o gen1.o gen2.o gen3.o ifactor1.o polarit1.o polarit2.o 
> polarit3.o rootpol.o subgroup.o trans1.o trans2.o trans3.o elliptic.o 
> galois.o kummer.o mpqs.o nffactor.o stark.o subfield.o thue.o anal.o 
> compat.o errmsg.o es.o helpmsg.o init.o sumiter.o mpinl.o
> rm -f libpari.so.1
> rm -f libpari.so
> ln -s libpari.so.2.1.4 libpari.so.1
> ln -s libpari.so.2.1.4 libpari.so
> rm -f gp-dyn
> gcc -o gp-dyn -O3 -DGCC_INLINE -Wall -Wno-implicit -fomit-frame-pointer 
>    gp.o gp_init.o gp_rl.o highlvl.o whatnow.o plot.o plotport.o 
> -R/root/.cpan/build/Math-Pari-2.010305/pari-2.1.4/Osolaris-sparcv9 
> -R/usr/local/lib -R/usr/openwin/lib 
> -L/root/.cpan/build/Math-Pari-2.010305/pari-2.1.4/Osolaris-sparcv9 
> -L/usr/local/lib -lreadline -lncurses -L/usr/local/lib -lpari 
> -L/usr/openwin/lib -lX11 -lsocket -lnsl -ldl -lm
> ld: fatal: symbol `__dso_handle' is multiply-defined:
>          (file 
> /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.2/crtbegin.o and file 
> /usr/local/lib/libreadline.so);
> ld: fatal: symbol `_init' is multiply-defined:
>          (file /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.2/crti.o 
> and file /usr/local/lib/libreadline.so);
> ld: fatal: symbol `_start' is multiply-defined:
>          (file /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.2/crt1.o 
> and file /usr/local/lib/libreadline.so);
> ld: fatal: symbol `_fini' is multiply-defined:
>          (file /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.2/crti.o 
> and file /usr/local/lib/libreadline.so);
> ld: fatal: symbol `_lib_version' is multiply-defined:
>          (file /usr/ccs/lib/values-Xa.o and file 
> /usr/local/lib/libreadline.so);
> ld: fatal: File processing errors. No output written to gp-dyn
> collect2: ld returned 1 exit status
> make[1]: *** [gp-dyn] Error 1
> make[1]: Leaving directory 
> `/root/.cpan/build/Math-Pari-2.010305/pari-2.1.4/Osolaris-sparcv9'
> make: *** [gp] Error 2
> 
> 
> Any ideas?
> Thx,
> CC

The dreaded 'ld' error.  Whenever I get this, I generally try
rebuilding the app from scratch using gnu's ld, i.e. "./configure
--with-gnu-ld=/usr/local/bin/ld".  This usually, but not always,
solves the problem.  Some configure scripts are very bad at picking up
this option (if they even support it), so you may need to create a
symbolic link from /usr/ccs/bin - be sure to back up your original ld
first!

I should also mention that building Math::GMP through the cpan shell
has never worked for me on any platform, probably because of the way
libpari wants to be built.  So, if you happen to be trying to build
this through the shell - don't.

Regards,

Dan


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

Date: Fri, 20 Dec 2002 07:10:18 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: enviroment variable set
Message-Id: <slrnb065lq.31i.tadmc@magna.augustmail.com>

Rod <palladium@spinn.net> wrote:
> "happier" <happier_tj@hotmail.com> wrote in message
> news:atu2em$2q2ep$1@ID-137585.news.dfncis.de...

>> I need to run my perl program in cron job and before running it must set
>> some enviroment variable

> grep(do{chop;s/(.*)=(.*)/$ENV{$1}=$2/e;},`. /etc/setup/setupperlenv.sh;
> env`);
> 
> If anyone see's anthing wrong with this approach, I would appreciate a
> propper flogging because I have it running in production scripts.


1) runtime is "too late" for one of the env vars that he needs to set.

2) FAQ: What's wrong with using grep or map in a void context?
   (use for/foreach instead of grep)


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


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

Date: Fri, 20 Dec 2002 09:02:15 -0600
From: Abernathey Family <family2@aracnet.com>
Subject: Re: enviroment variable set
Message-Id: <3E0330F7.5B07DDA7@aracnet.com>

Anno Siegel wrote something moderately useful:
> 
> According to James Hou <happier_tj@hotmail.com>:
> > > happier wrote:
> > > > I need to run my perl program in cron job and before running it must
> > > > set some enviroment variable,so I write a shell script as following.I
> > > > add the shell script into cron job.But
> > >
> > > Why don't you set those env variables from your Perl script?
> > You can't change the PERL5LIB in the Perl script, because even with a
> > BEGIN block the "use" statements happen first.
> 
> Wrong reason.  A BEGIN block is executed before any subsequent "use"
> in the same file, so the environment variable will be set.  However,
> Perl only looks at the environment once at startup and not every
> time a "use" happens.  That's why setting the variable in the script
> itself doesn't have the desired effect.
> 
> If you consider changing the calling script, don't use $ENV{ PERL5LIB}
> but the "use lib ..." pragma.  This will be honored in time.
> 
> >                                                 So I have to set the
> > variables in a shell script, and then from that shell script call the
> 
> The "shell script" might as well be another Perl script, for that matter.
> However, you can set the environment directly in the crontab entry:
> 
>     55 19 * * * export PERL5LIB=/fie/foe; /path/to/script param param
> 
--snip--

Your shell script or command line approach will work. You cannot do it
with a Perl script.


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

Date: Fri, 20 Dec 2002 12:48:15 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: enviroment variable set
Message-Id: <slrnb06pff.1vo.tadmc@magna.augustmail.com>

Abernathey Family <family2@aracnet.com> wrote:
> Anno Siegel wrote something moderately useful:
>> According to James Hou <happier_tj@hotmail.com>:
>> > > happier wrote:
>> > > > I need to run my perl program in cron job and before running it must
>> > > > set some enviroment variable,so I write a shell script as following


>> >                                                 So I have to set the
>> > variables in a shell script, and then from that shell script call the
>> 
>> The "shell script" might as well be another Perl script, for that matter.


> You cannot do it
> with a Perl script.


Yes you can:

   $ENV{PERL5LIB} = '/some/path';
   system 'prog_that_uses_modules_not_in_standard_place';


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


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

Date: Fri, 20 Dec 2002 17:14:46 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: help:  perl script to make all DNA sequence Nmers?
Message-Id: <3E033B22.6D2A518A@acm.org>

isen wrote:
> does anyone have a perl script to make all possible DNA sequence Nmers
> (and put in an array preferably) when given N as an input?  Please
> reply by email (sindriATmacDOTcom) if possible.

What's the point? Isn't this isomorphic to the infinite monkeys problem?
Sure, an infinite number of monkeys will type out the works of Shakespeare,
but you're still left with the problem of sorting through all of the paper
to find them, rejecting all of the near misses:

    "To be, or not to be, that is the blickzorp ..."

-- Dave Tweed


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

Date: 20 Dec 2002 17:18:42 GMT
From: ctcgag@hotmail.com
Subject: Re: help:  perl script to make all DNA sequence Nmers?
Message-Id: <20021220121842.518$hp@newsreader.com>

Benjamin Goldberg <goldbb2@earthlink.net> wrote:
>
> Which, no offense, explains why you didn't spot what was wrong with my
> code right away.

None taken, and thanks for the explanations.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Fri, 20 Dec 2002 07:40:42 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: how do I split large file into separate files?
Message-Id: <slrnb067eq.31i.tadmc@magna.augustmail.com>

Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:

> I have a large file in which each subsection is separated by 3 line
> feeds.


Surely you meant "3 blank lines" instead?


> How can write a file for each subsection? 


Call open() each time you detect a new subsection.

I expect you've asked the wrong question.

   How can I detect the subsections?

Is probably what you were really hoping for.

The $/ (input record separator) and $. (input line number) 
special variables can help you there (perldoc perlvar).


-------------------------------
{  local $/ = "\n\n\n";
   while ( <> ) {
      open FILE, ">$ARGV.$." or die "could not open '$ARGV.$.'  $!";
      print FILE;
   }
}
-------------------------------


> Have tried and failed so
> far!


We cannot help you fix your code if you do not show us your code...


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


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

Date: Fri, 20 Dec 2002 10:42:40 -0500
From: "Christian Caron" <nospam@nospam.org>
Subject: how to use system to send data to a command that ask for input
Message-Id: <atvdph$jbu5@nrn2.NRCan.gc.ca>

Hi all,

I want my program to execute htpasswd to generate a password file in a
directory.

I tried:

#!/usr/local/bin/perl -w
use strict;

my $arguments1 = "-c";
my $arguments2 = ".htpasswd";
my $arguments3 = "username";
my $password = "password\npassword\n";
system("/usr/local/bin/htpasswd", $arguments1, $arguments2, $arguments3,
$password);


but, of course, it doesn't work. If I do this instead:

#!/usr/local/bin/perl -w
use strict;

my $arguments1 = "-c";
my $arguments2 = ".htpasswd";
my $arguments3 = "username";
system("/usr/local/bin/htpasswd", $arguments1, $arguments2, $arguments3);

it works partially as it runs the command, but ask me at the command line to
enter the password (twice). I want the Perl script to put the password in
it.

Anyone have an idea?

Thanks!

Christian




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

Date: Fri, 20 Dec 2002 15:53:53 GMT
From: "Ian.H [dS]" <ian@WINDOZEdigiserv.net>
Subject: Re: how to use system to send data to a command that ask for input
Message-Id: <39f60v8n55ins8aju96p6mf235m5re6h9m@4ax.com>
Keywords: Remove WINDOZE to reply

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

In a fit of excitement on Fri, 20 Dec 2002 10:42:40 -0500, "Christian
Caron" <nospam@nospam.org> managed to scribble:

> Hi all,
> 
> I want my program to execute htpasswd to generate a password file in
> a directory.
> 
> I tried:


[snip]


> 
> 
> but, of course, it doesn't work. If I do this instead:
> 
> #!/usr/local/bin/perl -w
> use strict;
> 
> my $arguments1 = "-c";
> my $arguments2 = ".htpasswd";
> my $arguments3 = "username";
> system("/usr/local/bin/htpasswd", $arguments1, $arguments2,
> $arguments3);  
> 
> it works partially as it runs the command, but ask me at the command
> line to enter the password (twice). I want the Perl script to put the
> password in it.
> 
> Anyone have an idea?
> 

Add -b to your switches.

$ htpasswd -cb file user password


HTH.


Regards,

  Ian

-----BEGIN xxx SIGNATURE-----
Version: PGP Personal Privacy 6.5.3

iQA/AwUBPgM9g2fqtj251CDhEQK+egCfe31YOvklIviAAZFddwVGJJMf9mQAnjtr
kVqX+fKLH/ETO4pzJNsxLG7z
=uYUr
-----END PGP SIGNATURE-----

-- 
Ian.H  [Design & Development]
digiServ Network - Web solutions
www.digiserv.net  |  irc.digiserv.net  |  forum.digiserv.net
Scripting, Web design, development & hosting.


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

Date: 20 Dec 2002 15:54:18 GMT
From: "Michael L. Hostbaek" <carlos@pez.dk>
Subject: Re: how to use system to send data to a command that ask for input
Message-Id: <slrnb06f9a.dmu.carlos@freebsdcluster.dk>

Christian Caron tried to tell us something, and all I got was:
>  it works partially as it runs the command, but ask me at the command line to
>  enter the password (twice). I want the Perl script to put the password in
>  it.
>  

Take a look at 'man htpasswd' and the '-b' flag.

-- 
Regards,
Michael L. Hostbaek
-= So long, and thanks for all the fish.. =-



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

Date: Fri, 20 Dec 2002 11:12:56 -0500
From: "Christian Caron" <nospam@nospam.org>
Subject: Re: how to use system to send data to a command that ask for input
Message-Id: <atvfi8$j6u7@nrn2.NRCan.gc.ca>


"Ian.H [dS]" <ian@WINDOZEdigiserv.net> wrote in message
news:39f60v8n55ins8aju96p6mf235m5re6h9m@4ax.com...
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> In a fit of excitement on Fri, 20 Dec 2002 10:42:40 -0500, "Christian
> Caron" <nospam@nospam.org> managed to scribble:
>
> > Hi all,
> >
> > I want my program to execute htpasswd to generate a password file in
> > a directory.
> >
> > I tried:
>
>
> [snip]
>
>
> > Anyone have an idea?
> >
>
> Add -b to your switches.
>
> $ htpasswd -cb file user password
>
>
> HTH.
>
>
> Regards,
>
>   Ian
>

nrn1# htpasswd -b
Usage: htpasswd [-c] passwordfile username
The -c flag creates a new file.

Seems like I may have an older version of htpasswd...

I'll see what I can do.

Thanks!





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

Date: Fri, 20 Dec 2002 16:26:00 GMT
From: "Ian.H [dS]" <ian@WINDOZEdigiserv.net>
Subject: Re: how to use system to send data to a command that ask for input
Message-Id: <p6h60v00h4enmvcc5fkqruckhm16phqdgm@4ax.com>
Keywords: Remove WINDOZE to reply

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

In a fit of excitement on Fri, 20 Dec 2002 11:12:56 -0500, "Christian
Caron" <nospam@nospam.org> managed to scribble:

[snip]

> nrn1# htpasswd -b
> Usage: htpasswd [-c] passwordfile username
> The -c flag creates a new file.
> 
> Seems like I may have an older version of htpasswd...
> 
> I'll see what I can do.
> 
> Thanks!

- From mine:

[tk@morris:~]$ htpasswd
Usage:
        htpasswd [-cmdps] passwordfile username
        htpasswd -b[cmdps] passwordfile username password

        htpasswd -n[mdps] username
        htpasswd -nb[mdps] username password
 -c  Create a new file.
 -n  Don't update file; display results on stdout.
 -m  Force MD5 encryption of the password.
 -d  Force CRYPT encryption of the password (default).
 -p  Do not encrypt the password (plaintext).
 -s  Force SHA encryption of the password.
 -b  Use the password from the command line rather than prompting for
it.
On Windows, TPF and NetWare systems the '-m' flag is used by default.
On all other systems, the '-p' flag will probably not work.



The -m (MD5) flag is very often used too.


Regards,

  Ian

-----BEGIN xxx SIGNATURE-----
Version: PGP Personal Privacy 6.5.3

iQA/AwUBPgNFCmfqtj251CDhEQLWQwCeJaXsLVrxA9jmNr3zWiUEX0xrJd0AoIYs
qfKhfrNSFkFJMc2B4W1ZWO90
=PVw7
-----END PGP SIGNATURE-----

-- 
Ian.H  [Design & Development]
digiServ Network - Web solutions
www.digiserv.net  |  irc.digiserv.net  |  forum.digiserv.net
Scripting, Web design, development & hosting.


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

Date: Fri, 20 Dec 2002 20:02:55 +0100
From: "Christian Winter" <thepoet@nexgo.de>
Subject: Re: how to use system to send data to a command that ask for input
Message-Id: <3e036856$0$13023$9b4e6d93@newsread2.arcor-online.net>

"Christian Caron" <nospam@nospam.org> wrote:
> Hi all,
>
> I want my program to execute htpasswd to generate a password file in a
> directory.
[snipped]

Hi,

that's a question that comes up quite often, and even
there is the -b switch to htpasswd using it isn't considered
a wise solution, as the plaintext password will appear
on the command line. It is mostly fine on a single user
system, but if there are other users the passwords may
be compromised by simply doing something like a 'ps'.

You can circumvent this by using an additional perl
module, like Expect.pm (available from CPAN) which
lets you interface with the stdin/stdout of external
commands.

If you are going to use the standard, unix-style crypt
password files, you can also install Apache::Htpasswd from
CPAN, which lets you directly alter the password files instead
of calling the external utility.

I don't know whether there is something similar for
md5 password files yet.

HTH
Christian




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

Date: Fri, 20 Dec 2002 11:02:10 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: incorporating off-site content
Message-Id: <atvj67$j50$1@slb9.atl.mindspring.net>

"bashbrothers" <bashbrothers@cox.net> wrote in message
news:kBxM9.61618$Y86.34465@news2.central.cox.net...
> If you are using a linux machine and have lynx installed (a command line

Please don't top post. Your posts will likely be ignored, as this one was,
if you don't follow the posting guidelines.

Cheers.

Bill Segraves




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

Date: 20 Dec 2002 16:35:08 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Installing an event handler with use / require?
Message-Id: <u9y96kir7n.fsf@wcl-l.bham.ac.uk>

Benjamin Goldberg <goldbb2@earthlink.net> writes:

> Overload CORE::GLOBAL::require, perhaps?

Well, Anno already said in this thread that require() wasn't
overloadable.

I must admit that I'd accepted Anno's word without checking.

I've just tried it and it seems to me that Anno spoke the truth.

Do you have any reason to believe otherwise?

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 20 Dec 2002 16:40:46 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Installing an event handler with use / require?
Message-Id: <u9r8cciqy9.fsf@wcl-l.bham.ac.uk>

Brian McCauley <nobull@mail.com> writes:

> The exported function Devel::OnLoad::add_loader_listener() would push
> stuff into a hash of arrays of coderefs in %Devel::OnLoad::handlers.

In another branh of this thread Benjamin Goldberg
<goldbb2@earthlink.net> writes:

> my %handlers;
> sub Devel::Onload::add_load_listener {
>    my ($mod, $coderef) = @_;
>    (my $file = $mod) =~ s,::,/,g;
>    push @{ $handlers{"$file.pm"} }, $coderef;
> }

Yep, that's the add_load_listener() I just described.

And, of course, %handlers can be lexical.  I'd orginally anticpated
needing to access it from within the dummy module - but then I refined
my strategy...

> The dummy My/Module.pm module would just be the single line:
> 
>   Devel::OnLoad::chain('My/Module.pm')
> 
> This subroutine would be something like:
 
sub Devel::OnLoad::chain {
    my $mod = shift;
    my $handlers = delete $handlers{$mod};
    delete $INC{$mod};
    require $mod;
    &$_ for @$handlers;
    1;
}

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 20 Dec 2002 07:08:04 -0800
From: uj797@victoria.tc.ca (Arthur T. Murray)
Subject: Re: part of speech tagger written in perl
Message-Id: <3e033254@news.victoria.tc.ca>

primo1980@hotmail.com (Jeff Green) wrote on 19 Dec 2002:
> Hello,
>
> Does anyone know of a part of speech tagger that is written in perl.

There is a page of "Rule-based heuristics for a POS tagger" at
http://www.cs.brandeis.edu/~llc/cs114/assignments/heuristics.html

There is also
"Perl: extending your pos-tagger using regular expressions and s//" at
http://www.colorado.edu/ling/courses/CourseArchives/spring99/6300/lab11.html 

> Also it would be good if its free. a perl module would be even better
>
> cheers

Arthur T. Murray
-- 
http://mind.sourceforge.net/perl.html -- Perl for Robot AI Minds;
http://www.cpan.org/authors/id/M/ME/MENTIFEX/mind.txt -- AI namespaces;
http://search.barnesandnoble.com/bookSearch/isbnInquiry.asp?ISBN=0595259227 
http://www.iuniverse.com/bookstore/book_detail.asp?isbn=0595259227 


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

Date: Fri, 20 Dec 2002 16:34:59 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: Precedence of => (was Re: Why does Perl handle "return undef;" differently then "return;")
Message-Id: <TEHM9.254050$ka.6167921@news1.calgary.shaw.ca>

In article <3E02446B.C9D307D5@earthlink.net>,
 Benjamin Goldberg <goldbb2@earthlink.net> writes:
>Brian McCauley wrote:
>> Actually, if I'd been inventing Perl from scratch then I'd have made
>> the => operator have a higher precedence than the plain comma and
>> made => give a scalar context to it's RHS.  But it's too late now - we
>> can't go back in time and change histroy.
>
>In perl6, the => operator will create 'pair' objects, rather than merely
>being a fancy comma operator.  I'm fairly sure that a consequence of
>this will be for it to give scalar context to it's RHS (and maybe to
>it's LHS, too).

Hmm, does that mean I will no longer be able to write

	$whole = join "*" => @parts;
	@cubes = map $_**3 => @nums;

etc?

Pity.

-- 
Peter Scott
http://www.perldebugged.com


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

Date: Fri, 20 Dec 2002 16:13:04 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Re: enviroment variable set
Message-Id: <kkHM9.27876$3t6.13017@nwrddc03.gnilink.net>

James Hou wrote:
>> happier wrote:
>>> I need to run my perl program in cron job and before running it must
>>> set some enviroment variable,so I write a shell script as
>>> following.I add the shell script into cron job.But
>>
>> Why don't you set those env variables from your Perl script?
> You can't change the PERL5LIB in the Perl script, because even with a
> BEGIN block the "use" statements happen first.  So I have to set the
> variables in a shell script, and then from that shell script call the
> Perl script.Can you tell me How can I set enviroment variable in
> shell script?

Ah, I see. Well, what about using your shell script as a real wrapper, i.e.
it sets the variables first and then launches your Perl script, too. Then
the Perl process will be a child of the shell script and it will inherit the
environment settings of the parent.

jue





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

Date: Fri, 20 Dec 2002 07:43:16 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Replacing text strings contains more than 1 dot
Message-Id: <slrnb067jk.31i.tadmc@magna.augustmail.com>

Eric <eric.chin@pinnacle.co.uk> wrote:

> Thanks to all who reply. I've learned something today :)


See the Posting Guidelines that are posted here weekly,
and learn even more.  :-)


[ snip TOFU ]

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


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

Date: Fri, 20 Dec 2002 17:11:22 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: search and replace text in many files
Message-Id: <_aIM9.2859$uO4.98818252@newssvr14.news.prodigy.com>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>> > And the alias definition would be:
>> > alias SRtext 'find . -type -f | xargs perlscriptname "$1" "$2"'
>> ...
>> > BobbyD
>> 
>> 
>> You could check out the File::Find module for an all-Perl solution
>> 
>> which is not platform dependent.  And won't involve firing off a
>> process for each file.

> Well, "xargs" helps with that.  But of course, as you say, there's no
> reason why a single Perl script shouldn't do all the job.

"helps".  If you're running that on Solaris, the xargs will fail on
filenames with a space in them (or a newline or a few things like that).

Alternatives could include:
1) replacing 'find' and 'xargs' on the system and calling them with
   different arguments to change the behavior.
2) Running it as 'find . -type f -print | perlscriptname ... and let the
   perl script read the filenames from stdin.  That would work with all
   files that didn't have newlines in the name.
3) Under solaris you could do find . -type f -exec perlscript $1 $2 {} +
   As exec() friendly as xargs is, but filename safe.
4) Use File::Find in the perl script and descend directly.

-- 
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: 20 Dec 2002 08:48:49 -0800
From: leaffoot@hotmail.com (Leaffoot)
Subject: Re: SSH: remote protocol version not found
Message-Id: <d7bd06a3.0212200848.74560d47@posting.google.com>

efflandt@xnet.com (David Efflandt) wrote in message news:<slrnb04vod.875.efflandt@typhoon.xnet.com>...

> ssh is port 22 unless the server has sshd listening on non-standard port 
> 21 (normally used for ftp).  Could that be why no ssh version is found?
> 

Thanks for the suggestion- I should have noted, I switched to port 21
from port 22, because when I try port 22, I get:

rlouden: Reading configuration data /.ssh/config
rlouden: Reading configuration data /etc/ssh_config
rlouden: Connecting to ftp.collectionsoftware.com, port 22.
Can't connect to ftp.collectionsoftware.com, port 22: Unknown error at
C:/Perl/site/lib/Net/SSH/Perl.pm line 210.

However, any other port gives me what I get with port 21- so I think
you are right, I should change it to port 22 and deal with this
unknown error.

Thanks!


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

Date: Fri, 20 Dec 2002 18:44:21 GMT
From: Rick Delaney <rick.delaney@rogers.com>
Subject: Re: Tied Filehandles
Message-Id: <m3ptrw4jjv.fsf@cs839290-a.mtth.phub.net.cable.rogers.com>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:

> According to Andrew Hamm <ahamm@mail.com>:
> > Tassilo v. Parseval wrote:
> > >
> > > Now both
> > >
> > >     print $myhandle @list
> > >
> > > as well as
> > >
> > >     $myhandle->print(@list)
> > >
> > > will work as expected.

[...]

> > sub garnish {
> >     ++$n;
> >     print "garnish $n\n";
> 
> Umm...  What makes you think printing something to STDOUT would make it
> appear in the output to the tied filehande?

What makes you think he doesn't want it going to STDOUT?

[...]

> As you have seen, the output appears on STDOUT.

No, as we have seen, some of the output from

   $myhandle->print(@list)

goes to STDOUT, because the print method is called but the indirect
object call

    print $myhandle @list

is not printing anything to STDOUT because the print method is not
called.

Perhaps the incomprehensible BUGS section of IO::Handle is meant to
explain this.

-- 
Rick Delaney
rick.delaney@rogers.com


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

Date: Fri, 20 Dec 2002 14:20:33 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Wanted Help to implement search for my intRAnet site of our company
Message-Id: <3e0323f1.1360735544@news.cis.dfn.de>

On Fri, 20 Dec 2002 19:03:46 +0530, "R Tamilarasan"
<tamil@quicklogic.com> wrote:

>I m setting up a INTRANET site for our company
>I m planning to put directory-search in web page.
>The requirment ::--
>I have a load of files and directories in the server disk.
>One way to search is using window-find/search utility.
>I dont want that.
>User of the intranet should be able to do the search as
>it is in the www.google.com search. It lists down all
>the files and some contents as a web page.
>Is cgi-perl usefull. I have not much idea of how to use
>it for the web applications like search-engine.

Download and install perl from www.activestate.com
and apache from www.apache.org OR get both at the
same time from www.indigostar.com
 
Read:

# the FAQ on CGI programming in:

perldoc -q CGI

# the documentation on the CGI module in:

perldoc CGI

# the documentation  on the File::Find module in:

perldoc File::Find

# the documentation on Perl Regular Expressions
# used for pattern matching in:

perldoc perlre

# read about the problems commonly encountered
# in CGI programming in:

perldoc -q 500

You may also find these sites useful:

http://www.perl.org/CGI_MetaFAQ.html
http://www.stonehenge.com/merlyn/columns.html
-- 
Regards, Helgi Briem
helgi AT decode DOT is


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

Date: Fri, 20 Dec 2002 08:00:34 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Wierd loop/chdir behavior
Message-Id: <slrnb068k2.31i.tadmc@magna.augustmail.com>

Steve Walker <J_Steven_Walker@hotmail.com> wrote:

>    @gdir=glob ($ddir);

>    foreach $dir (@gdir)


You do not need that temporary variable

   foreach $dir ( glob($ddir) )


>       chdir $work_dir ;


Just because you asked to change directories doesn't mean
you actually got what you asked for.

You should check the return value:

   chdir $work_dir or die "could not chdir to '$work_dir'  $!";


>       if (defined($dir))


What is that test for?

glob() does not return undefs.


>           chop($pwd=`/usr/bin/pwd`);


   chomp($pwd=`/usr/bin/pwd`);


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


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

Date: Fri, 20 Dec 2002 20:02:01 +0100
From: "Michel Rodriguez" <mirod@xmltwig.com>
Subject: Re: xmlgrep
Message-Id: <pan.2002.12.20.19.02.00.929059@xmltwig.com>

On Thu, 19 Dec 2002 17:05:11 +0000, bill schaller wrote:

> I need to do grep like functions on files containing mostly xml.  I
> wrote this little program that works like grep to search through
> multiple files.  You must specify a root, and each chunck of xml with
> that root is searched for additional requirements.  If matchs are found,
> the chunk is printed.  As with grep, this can be piped into other
> programs....
> 
> arguments are a little strange, but run with a -help to figure them out.

Oh, here is a rewrite of the tool using XML tools (well... the only XML
tools I really know well ;--) You need the latest development version
available from http://xmltwig.com/xmltwig/ to run this script:

#!/usr/local/bin/perl -w
use strict;

use Getopt::Long;
use Pod::Usage;
use XML::Twig;


# options (all used globally in the script) my( $help, $man, @roots,
@paths, $files, $nb_results, $encoding,
    $wrap, $group, $pretty_print);


GetOptions( 'help'         => \$help,
            'man'          => \$man,
            'root=s'       => \@roots,
            'cond=s'       => \@paths,
	    'files'        => \$files,
	    'nb_results=i' => \$nb_results,
	    'encoding=s'   => \$encoding,
	    'wrap:s'       => \$wrap,
            'group_by_file:s' => \$group,
	    'pretty_print:s'  => \$pretty_print,
	  ) or pod2usage(2);

pod2usage(1) if $help;
pod2usage(-exitstatus => 0, -verbose => 2) if $man;
	
unless( @roots or @paths or $files) { pod2usage(1); exit; } if( $files and
!@paths)             { pod2usage(1); exit; } if( $files and (@roots or
$encoding or defined( $wrap)
                or defined( $group) or defined( $pretty_print)))
                                    { pod2usage(1); exit; }
if( $files and !@ARGV)              { pod2usage(1); exit; } if( !$files
and @paths and !@roots) { @roots= @paths; @paths=(); }

# defaults for optional arguments to options $group        = 'file'    
if( defined $group        and !$group); $pretty_print = 'indented' if(
defined $pretty_print and !$pretty_print); $wrap         = 'grep'     if(
!defined( $wrap) and (@roots or @paths));

# some globals
my( $result_start_printed, $file_results_start_printed, $current_file);

# will be used to create the twig
my %options;

if( @roots)
  { my $root_handlers={};
    my $root_handler= sub { my( $t, $root)= @_;
                            if( !@paths or $_->att( '#print'))
                              { unless( $result_start_printed)
                                  { print result_start();
                                    $result_start_printed=1;
                                  }
                                unless( !$group or
                                $file_results_start_printed)
                                  { print file_results_start();
                                    $file_results_start_printed= 1;
                                  }
                                $root->print;
                                $nb_results--;
                                unless( $nb_results) { $@= "XMLGREP:
                                NB_RESULT_REACHED"; die; }
                              }
                            $t->purge;
                          };
    foreach my $root (@roots)
      { $root_handlers->{$root}= $root_handler; }

    $options{twig_roots}= $root_handlers;
  }
  }
if( @paths)
  { my $twig_handlers={};
     my $twig_handler;
     if( $files)
       {  $twig_handler= sub { $@="XMLGREP: FOUND"; die; }; }
     else
       {  $twig_handler= sub { my( $t, $hit)= @_;
		               foreach my $elt ( $hit->ancestors_or_self)
                                 { $elt->set_att( '#print' => 1); }
                             };
       }
    foreach my $path (@paths)
      { $twig_handlers->{$path}= $twig_handler; }

    $options{twig_handlers}= $twig_handlers;
  }
  }

$options{pretty_print}    = $pretty_print if( $pretty_print);
$options{output_encoding} = $encoding     if( $encoding);
     
my $t= XML::Twig->new( %options);

if( @ARGV)
  { foreach my $file (@ARGV)
      { $file_results_start_printed=0;
        $current_file= $file;
        my $ok= $t->safe_parsefile( $file);
        if( !$ok)
          { if( $@ =~ m{XMLGREP: FOUND})
              { # in files mode
                print $current_file, "\n";
                $nb_results--;
                exit unless( $nb_results);
              }
            elsif( $@ =~ m{^XMLGREP: NB_RESULT_REACHED})
              { print file_results_end();
                print result_end() if( $group);
                exit;
              }
            else
              { die /$@/; }
          }
        else
         { if( @roots) { print file_results_end(); }
         }
         }
    print result_end();
  }
else
  { $file_results_start_printed=0;
    my $ok= $t->safe_parse( \*STDIN);
    die $@ if( !$ok and ( $@ !~ m{^XMLGREP: NB_RESULT_REACHED})); print
    result_end();
  }
  }
{ my $seen_start=0; # so we only print the end if there was a start

  sub result_start
    { my $enc_decl= $encoding ? qq{encoding="$encoding" } : '';
      $seen_start=1;
      return   qq{<?xml version="1.0" $enc_decl?>\n}
             . qq{<$wrap>\n};
    }
    }
  sub result_end
    { return '' unless $seen_start;
      $seen_start=0;
      return qq{\n</$wrap>\n};
    }
    }
}
{ my $seen_start=0; # so we only print the end if there was a start

  sub file_results_start
    { $seen_start=1;
      return qq{<$group filename="$current_file">};
    }
    }
  sub file_results_end
    { return '' unless $seen_start;
      $seen_start=0;
      return qq{\n</$group>\n};
    }
    }
}


__END__

=head1 NAME

xmlgrep - grep XML files looking for specific elements

=head1 SYNOPSYS

xmlgrep [options] [file ...]

 Options:
   -help            brief help message
   -man             full documentation

=head1 OPTIONS

=over 4

=item B<--help>

brief help message

=item B<--man>

full documentation

=item B<--root> <cond>

look for and return xml chunks matching <cond>

if neither C<--root> nor C<--file> are used then the element(s) that
trigger the C<--cond> option is (are) used. If C<--cond> is not used then
all elements matching the <cond> are returned

several C<--root> can be provided

=item B<--files>

return only file names (do not generate an XML output)

usage of this option precludes using any of the options that define the
XML output: C<--roots>, C<--encoding>, C<--wrap>, C<--group_by_file> or
C<--pretty_print>

=item B<--cond> <cond>

return the chunks (or file names) only if they contain elements matching
<cond>

several C<--cond> can be provided (in which case they are OR'ed)

=item B<--nb_results> <nb>

output only <nb> results

=item B<--encoding> <enc>

encoding of the xml output (utf-8 by default)

=item B<--wrap> <tag>

wrap the xml result in the provided tag (defaults to 'grep')

=item B<--file_wrap> <optional_tag>

wrap results for each files into a separate element. By default that
element is named C<file>. It has an attribute named C<filename> that gives
the name of the file.

the short version of this option is B<-g>

=item B<--pretty_print> <optional_style>

pretty print the output using XML::Twig styles ('C<indented>', 'C<record>'
or 'C<record_c>' are probably what you are looking for)

if the option is used but no style is given then 'C<indented>' is used

short form for this arggument is B<-s>

=back

<cond> is an XPath-like expression as allowed by XML::Twig to trigger
handlers.
	 
exemples:
  'para'
  'para[@compact="compact"]'
  '*[@urgent]'
  '*[@urgent="1"]'
  'para[string()="WARNING"]'

see XML::Twig for a more complete description of the <cond> syntax

options are processedby Getopt::Long so they can start with '-' or '--'
and can be abbreviated (-r instead of --root for example)

=head1 DESCRIPTION

B<xmlgrep> does a grep on XML files. Instead of using regular expressions
it uses XPath expressions (in fact the subset of XPath supported by
XML::Twig)

the results can be the names of the files or XML elements containing
matching elements.

=head1 SEE ALSO

XML::Twig Getopt::Long

=head1 LICENSE

This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=head1 AUTHOR

Michel Rodriguez <mirod@xmltwig.com>




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

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


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