[18521] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 689 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 13 00:20:49 2001

Date: Thu, 12 Apr 2001 21:20:27 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <987135626-v10-i689@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 12 Apr 2001     Volume: 10 Number: 689

Today's topics:
    Re: Q: Active Perl redistributable MINIMUM? <jeremyk.remove-this@privacy.nu>
        Q: Shelling out (Create Process) to run a perl script <jeremyk.remove-this@privacy.nu>
    Re: Q: Shelling out (Create Process) to run a perl scri <Jonathan.L.Ericson@jpl.nasa.gov>
    Re: So what do YOU use Perl for? (Abigail)
    Re: So what do YOU use Perl for? (Mark Jason Dominus)
    Re: So what do YOU use Perl for? (Mark Jason Dominus)
    Re: Stripping non standard control characters from a fi <ronda@panix.com>
        Thankyou All Most Kindly :-) <karlyoung@unconscious.co.uk>
    Re: Thankyou All Most Kindly :-) (Tad McClellan)
    Re: Thankyou All Most Kindly :-) (Si Ballenger)
    Re: Ulimit in Perl <cadet@alum.mit.edu>
        Warning Message <chris62vw@hotmail.com>
    Re: Warning Message <uri@sysarch.com>
    Re: Warning Message <waltman@netaxs.com>
    Re: Win32::ODBC insert datetime data into Access DB <Jonathan.L.Ericson@jpl.nasa.gov>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 12 Apr 2001 20:30:25 -0400
From: Jeremy <jeremyk.remove-this@privacy.nu>
Subject: Re: Q: Active Perl redistributable MINIMUM?
Message-Id: <3AD648A1.8474DA9F@privacy.nu>

Beable van Polasm wrote:
> I don't run ActiveState Perl, but wouldn't the smallest possible
> installation be just perl.exe? 
Nah, it's got a billion DLLs, unfortunately. Although you're right, I
could try just perl.exe, I guess. I doubt it's sufficient though, but
I'll test.

Btw, which Perl are you using? Is there anything other than ActivePerl
for NT? My requirements are very simple, I'm sure any perl would do.

> Jeremy <jeremyk.remove-this@privacy.nu> wrote:
> > Does anyone know what the absolutely minimal Active Perl installation
> > consists of? Assume I use no packages, only the very core perl
> > functionality, what do I need to install on a machine in order to be
> > able to run it? (The old perl was easy in that respect, while the
> > "Active" perl is too Window'ish, takes huge amount of space on disk,
> > installs fifty bazillion files, and probably puts something in the
> > Registry.) I need to move it quickly though, and nonintrusively in terms
> > of machine configuration.
>


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

Date: Thu, 12 Apr 2001 20:27:39 -0400
From: Jeremy <jeremyk.remove-this@privacy.nu>
Subject: Q: Shelling out (Create Process) to run a perl script
Message-Id: <3AD647FB.694D73BF@privacy.nu>

Friends,

I have a little problem. I'm running a perl script from inside a proggie
by using CreateProcess with the following command line:

"perl make_stuff.pl .\b2b4.tmp > .\Test.dat"

make_stuff takes input from stdin, opens one file internally and also
prints a bunch of stuff to stdout (and stderror too.) So, in our case,
input comes from "b2b4.tmp", output SHOULD go to test.dat, and another
file would be created internally, let's call it "internal.txt". 

Now, the problem is that when I run this thing with CreateProcess 
(flags := no console/high priority) it creates the "internal.txt" file
just fine, but  does NOT create the redirected-to file! 

Same thing run manually from a console windows works like a charm.

Why could that be? Is there something about redirection I need to know?


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

Date: 13 Apr 2001 00:59:07 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Q: Shelling out (Create Process) to run a perl script
Message-Id: <86u23t4ntw.fsf@jon_ericson.jpl.nasa.gov>

Jeremy <jeremyk.remove-this@privacy.nu> writes:

> Friends,
> 
> I have a little problem. I'm running a perl script from inside a proggie
> by using CreateProcess with the following command line:

<snip>
 
> Same thing run manually from a console windows works like a charm.

Sounds like a CreateProcess (whatever that is) problem to me.  You do
know you can redirect your own STDERR and STDOUT from within perl,
right?  (See perlfunc/open and perlopentut for ideas.)

Jon


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

Date: Thu, 12 Apr 2001 22:31:20 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: So what do YOU use Perl for?
Message-Id: <slrn9dcb5o.gs9.abigail@tsathoggua.rlyeh.net>

Mark Jason Dominus (mjd@plover.com) wrote on MMDCCLXXXI September
MCMXCIII in <URL:news:3ad60451.2149$21a@news.op.net>:
"" 
"" I wrote a suite of Perl programs to generate all the quilt blocks of a
"" certain type (sixteen-patch half-square triangles with 90-degree
"" rotational symmetry) and printed out the result:
"" 
""         http://www.plover.com/~mjd/misc/quilt/composites/bindexs.jpg
"" 
"" (I made an error; one block appears twice.  Can you find it?)

The fifth row, the fourth and sixth figures look like mirror images to me.



Abigail
-- 
#!/opt/perl/bin/perl -w
$\ = $"; $; = $$; END {$: and print $:} $SIG {TERM} = sub {$ := $_}; kill 15 =>
fork and ($; == getppid and exit or wait) foreach qw /Just another Perl Hacker/


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

Date: Thu, 12 Apr 2001 20:04:18 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: So what do YOU use Perl for?
Message-Id: <3ad60a41.21c8$31e@news.op.net>

In article <ZDqA6.8740$cF.187039@news1.nokia.com>,
Elaine Ashton <elaine@chaos.wustl.edu> wrote:
>There are close to 2100 modules on CPAN 

I counted 6,300 or so, looking at the 02packages.details.txt.  Is this
an error?

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Thu, 12 Apr 2001 19:38:59 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: So what do YOU use Perl for?
Message-Id: <3ad60451.2149$21a@news.op.net>

In article <slrn9d02ft.ff7.tjla@thislove.dyndns.org>,
Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
>
>I use it to impress women.
>

Around 1993 or 1994 I started dating a woman who was a quilter.  After
seeing a lot of quilts and pictures of quilts, it seemed to me that
most quilters stuck to a few traditional quilt blocks and that there
might be a lot of quilt blocks that were rarely used.

I wrote a suite of Perl programs to generate all the quilt blocks of a
certain type (sixteen-patch half-square triangles with 90-degree
rotational symmetry) and printed out the result:

        http://www.plover.com/~mjd/misc/quilt/composites/bindexs.jpg

(I made an error; one block appears twice.  Can you find it?)

I was delighted, because the results confirmed my suspicion:  There
*are* a lot of excellent but rarely-seen quilt blocks.

I was delighted even further when we got married, she made the program
output into a real quilt and gave it to me as a wedding present.

        http://www.plover.com/~mjd/misc/quilt/quilt/

She must have been impressed.


-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: 12 Apr 2001 16:21:02 GMT
From: Ronda Hauben <ronda@panix.com>
Subject: Re: Stripping non standard control characters from a file
Message-Id: <9b4kle$psp$1@news.panix.com>

Uri Guttman <uri@sysarch.com> wrote:
:>>>>> "RH" == Ronda Hauben <ronda@panix.com> writes:


:   RH> #!/usr/bin/perl

:   RH> my $source = shift @ARGV;
:   RH> my $destination = shift @ARGV;

:   RH> open IN, $source or die "Can't read source file $source: $:\n";
:   RH> open OUT, ">$destination" or die "Can't write on file $destination: $!\n";

: learn about the -n and -p options for perl. they are perfect for this
: kind of stuff.

Thanks.  I see what you mean. Some of why I wanted to learn perl
was to use it like Unix tools. I am now beginning to see why
folks suggested I learn perl.


:   RH>                 print;
:   RH>         }

:   RH> print OUT $_;

: you are printing to the file and stdout? other than for debugging, why?
: try this with: strip_wstar input_file > output_file

Good you point this out as well. 
To begin with its good to see that its working, but I agree once
I know that it is I don't have to print the file to stdout.

I wanted to be able to not only use the perl script to do 
a command line ocnversion, but also to try to figure out how to 
work through a directory of old wordstar files and make text files 
from them. 

: #/usr/local/bin/perl -p

: 	tr/\x80-\xff/\x00-\x7f/;        # mask most significant bit
: 	tr/\n\x20-\x7f//dc;             # nuke control characters
:         s/ +$//;                        # nuke spaces at end of line

: uri

Ronda
ronda@panix.com



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

Date: Fri, 13 Apr 2001 01:14:15 +0100
From: "Karl Young" <karlyoung@unconscious.co.uk>
Subject: Thankyou All Most Kindly :-)
Message-Id: <987121014.22958.0.nnrp-08.c2ded7c2@news.demon.co.uk>

Brian, Randall, Alan et al . Thankyou most kindly for your answers & for the
comp.infosystems.www.authoring.cgi newsgroup. I don't know how I missed it,
I'm not a Usenet newbie by any means. I will post my CGI questions there. I
will try to only post Perl questions here, but as Randall said as a newbie
to Perl it is sometimes hard to know if it is a Perl or a CGI problem, but
I'll do my best :-)

Does anyone really read a newsgroup for 3 weeks before posting to it?

Thanks once again people :-)
--

Karl
     ¸  ¸
   \(Ö)/
     Ô
   _/ \_

'Alan has told you already.'   - "Is this the right room for an argument?" -
"I've told you once".................Monty Python's Flying Circus







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

Date: Thu, 12 Apr 2001 20:03:11 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Thankyou All Most Kindly :-)
Message-Id: <slrn9dcghv.eug.tadmc@tadmc26.august.net>

Karl Young <karlyoung@unconscious.co.uk> wrote:

>Does anyone really read a newsgroup for 3 weeks before posting to it?


Folks that are very interested in not embarrassing themselves do.


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


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

Date: Fri, 13 Apr 2001 01:36:06 GMT
From: shb@vnet.net (Si Ballenger)
Subject: Re: Thankyou All Most Kindly :-)
Message-Id: <3ad653c3.541548526@166.82.1.9>

On Thu, 12 Apr 2001 20:03:11 -0400, tadmc@augustmail.com (Tad
McClellan) wrote:

>Karl Young <karlyoung@unconscious.co.uk> wrote:
>
>>Does anyone really read a newsgroup for 3 weeks before posting to it?
>
>
>Folks that are very interested in not embarrassing themselves do.
>
>
>-- 
>    Tad McClellan                          SGML consulting
>    tadmc@augustmail.com                   Perl programming
>    Fort Worth, Texas

Hmmm, Tad, I think *you* are starting to be an embarrasment to
the group (bypassing a more colorful discription!). But, I've
been killfiled, so you just won't have the opportunity to benefit
from this. Maybe you can find a 24 hour pharmacy that can help.
Hang in there, we're all pulling for you!  ;-)

ps. If the smiley fails again, just say these letters to the
pharamist... p  r  o  z  a  c.  He'll understand!


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

Date: Thu, 12 Apr 2001 18:06:11 GMT
From: David Bakhash <cadet@alum.mit.edu>
Subject: Re: Ulimit in Perl
Message-Id: <m33dbexxsu.fsf@alum.mit.edu>

>>>>> "sf" == Stan Francis <scf@ltop.newk.net> writes:

 sf> Is there a way to set system resource limits in a perl
 sf> program/script like ulimit in a shell? TIA

http://search.cpan.org/search?dist=BSD-Resource

dave



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

Date: Thu, 12 Apr 2001 19:18:37 -0700
From: "Chris A." <chris62vw@hotmail.com>
Subject: Warning Message
Message-Id: <tdcofua39jll1b@corp.supernews.com>

I run perl with the -w flag.  I am getting a warning.  Is there a place
where I can find the meaning to various warnings and errors in my script?

I am getting this error in particular:

Deep recursion on subroutine "main::stayalive" at keepalive line 11.

stayalive is a sub.  My 'named' is crashing so I made a cheap little perl
script to keep it alive until I can get the new version.

#!/usr/bin/perl -w


stayalive();

sub stayalive {

$processes = `ps -aux`;
if ($processes =~ /named/) {
        sleep 5;
        stayalive();
}

else {
        print "NAMED HAS SHUT DOWN !!! Restarting...";
        print "\t";
        print `date`;
        system ("named -q") || print "named has restarted successfully.\n";
        $processes = `ps -aux`;
        stayalive();

}

}

It isn't pretty, but it doesn't need to be.  It only took a few minutes to
make.


Thanks in advance everyone!

Chris A.

p.s. Thanks for the earlier tip pertaining to running subs like this() and
not like &this




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

Date: Fri, 13 Apr 2001 03:36:39 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Warning Message
Message-Id: <x7ae5lo4hk.fsf@home.sysarch.com>

>>>>> "CA" == Chris A <chris62vw@hotmail.com> writes:

  CA> stayalive();

  CA> sub stayalive {

  CA> $processes = `ps -aux`;
  CA> if ($processes =~ /named/) {

ever heard about indentation? sub code is usually indented from the sub
start.

  CA>         sleep 5;
  CA>         stayalive();
  CA> }


  CA>         stayalive();

why are you calling stayalive from INSIDE stayalive? that is recursion
and it is never ends which is what triggers your warning.


  CA> It isn't pretty, but it doesn't need to be.  It only took a few
  CA> minutes to make.

then take a few minutes to make it more readable.

and then take a few more to understand what calling a sub from inside
itself means. question for you: when will any call to that sub ever return?

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: 12 Apr 2001 23:57:52 -0400
From: Walt Mankowski <waltman@netaxs.com>
Subject: Re: Warning Message
Message-Id: <874rvtjvsv.fsf@netaxs.com>

"Chris A." <chris62vw@hotmail.com> writes:

> I run perl with the -w flag.  I am getting a warning.  Is there a place
> where I can find the meaning to various warnings and errors in my script?

Perl's error messages are all in the perldiag manpage, accessible by
typing:

perldoc perldiag

> I am getting this error in particular:
> 
> Deep recursion on subroutine "main::stayalive" at keepalive line 11.

Here's what perldiag has to say about your error:

       Deep recursion on subroutine ""%s""
           (W recursion) This subroutine has called itself
           (directly or indirectly) 100 times more than it has
           returned.  This probably indicates an infinite
           recursion, unless you're writing strange benchmark
           programs, in which case it indicates something else.

And in fact, that's exactly what you're doing.  You've written an
infinitely recursive subroutine.  When you write recursive
subroutines, you've got to have some way for the routine to break out
of the recursion and return.  Otherwise you eat up a little more RAM
each time you recurse until eventually you run out of memory.

There's not really any need for you to use recursion at all.
stayalive() can be easily rewritten to use an infinite loop:

sub stayalive {

    while (1) {
	$processes = `ps -aux`;
	if ($processes =~ /named/) {
	    sleep 5;
	}

	else {
	    print "NAMED HAS SHUT DOWN !!! Restarting...";
	    print "\t";
	    print `date`;
	    system ("named -q") || print "named has restarted successfully.\n";
	}
    }
}

While I'm mucking around in there, I should point out that calling
`date` is hardly ever necessary, since localtime returns a formatted
date when called in scalar context.  So you should replace

    print `date`;

with

    print scalar localtime;

Walt


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

Date: 13 Apr 2001 00:35:58 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Win32::ODBC insert datetime data into Access DB
Message-Id: <863dbd63gx.fsf@jon_ericson.jpl.nasa.gov>

"John" <john@imining.com.tw> writes:

> I'd like to insert datetime data into an Access 2000 database.
> I use the Win32::ODBC module with sql insert command.
> When the sql string is
>   INSERT INTO table (time,...) VALUES (#2001/04/05 12:00:00#,....)
> or
>   INSERT INTO table (time,...) VALUES ('2001/04/05 12:00:00',....)
> I always get a -3502 error.
> Other data types are ok.

This is likely to be a SQL, ODBC or Access problem.  Unless you post a
minimal _perl_ script that shows your problem, you will only get
speculative or off-topic answers to this question.

Jon


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

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


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