[8856] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2473 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 1 15:17:29 1998

Date: Fri, 1 May 98 12:00:30 -0700
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, 1 May 1998     Volume: 8 Number: 2473

Today's topics:
    Re: "use strict" complains about GetOptions variables <bw@pindar.com>
    Re: 1701 days hath September (was: Re: rename funciton) (John Porter)
    Re: 1701 days hath September (was: Re: rename funciton) (John Stanley)
    Re: 1701 days hath September (was: Re: rename funciton) (Stuart McDow)
    Re: 1701 days hath September (was: Re: rename funciton) (John Porter)
        \D fails when [^0-9] doesn't <brannon@lnc.usc.edu>
        ActiveWare PerlIS.dll <bschoen@interlog.com>
    Re: Adding 600 users to a Linux password file <lr@hpl.hp.com>
    Re: alarm <lr@hpl.hp.com>
    Re: alarm (Charles DeRykus)
    Re: Bidirectional pipe filehandles? tigger@io.com.nospaam
    Re: email attachments <brianm@kodak.com>
    Re: email attachments <eryq@zeegee.com>
    Re: fork problem <davidl@inkttomi.com>
        How do I print a string that is in a certain format? <bth@acsu.buffalo.edu>
    Re: How do I print a string that is in a certain format <alpaca@iname.com>
    Re: How do I print a string that is in a certain format (John Porter)
        How to Schedule Program Execution (Rick Alber)
    Re: How to Schedule Program Execution <brianm@kodak.com>
        how to write error log msg when using multiple modules <akushner@cup.hp.com>
    Re: how to write error log msg when using multiple modu (Earl Hood)
    Re: how to write error log msg when using multiple modu <David.Boyce@fmr.com>
    Re: http Reg Exp (Earl Hood)
    Re: Looking for an idiom (cf. Schwartzian Transform) <danboo@negia.net>
    Re: Perl web server.... otis@POPULUS.net
    Re: QRe: == vs. eq <upsetter@shore.net>
        strictly speaking.. (Matt Dunn)
    Re: strictly speaking.. <jhi@alpha.hut.fi>
    Re: visual basic replacement <boys@aspentech.com>
        web_store.cgi error in the browser tiles@pyramidtile.com
    Re: Why doesn't this work? <jamesr@aethos.co.uk.nospam>
        Yet another plead for help <nadassy@ebi.ac.uk>
    Re: Yet another plead for help <akushner@cup.hp.com>
    Re: Yet another plead for help (John Porter)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 1 May 1998 14:16:15 +0100
From: "Bob Wilkinson" <bw@pindar.com>
Subject: Re: "use strict" complains about GetOptions variables
Message-Id: <3549ca3d.0@nnrp1.news.uk.psi.net>

John Bossert wrote in message <354978A4.D9829380@ibm.net>...
>If I (per the Perl Bibles) specify "use strict;", perl complains about
>the "$opt_foo" variables I'm
>referencing within a GetOptions() call.
>
>How should I declare these variables so as to get past the "strict"
>enforcement?  TIA.
>

Like this:

use Getopt::Long;
use vars qw($opt_debug);
GetOptions qw (-debug) or die "Can't get command line options, $!";

i.e. use vars qw($opt_flag1 $opt_flag2 .... )

Bob




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

Date: Fri, 01 May 1998 18:05:08 GMT
From: jdporter@min.net (John Porter)
Subject: Re: 1701 days hath September (was: Re: rename funciton)
Message-Id: <MPG.fb3da66f802138a989694@news.min.net>

On 1 May 1998 15:47:33 GMT,
in article <6icqql$ddr$1@news.NERO.NET>,
stanley@skyking.OCE.ORST.EDU (John Stanley) wrote:
> In article <MPG.fb38fbd4135e4698968c@news.min.net>,
> John Porter <jdporter@min.net> wrote:
> >Yep, that's what a moderated group is all about.  No governments,
> >large or otherwise, get involved.  The perl community will
> >moderate itself.
> 
> Really? I don't think so. I remember seeing a list of specific people
> who would be the moderators for the moderated group. Or are you saying
> that those people on the list are the "perl community"?

Not that they "are" the community, but that they deeply understand
the needs and the idiosyncracies of the community.  These guys
are anything but "large government".  They have the interests of
the community at heart.

JP


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

Date: 1 May 1998 18:40:42 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: 1701 days hath September (was: Re: rename funciton)
Message-Id: <6id4va$jmi$1@news.NERO.NET>

In article <MPG.fb3da66f802138a989694@news.min.net>,
John Porter <jdporter@min.net> wrote:
>in article <6icqql$ddr$1@news.NERO.NET>,
>stanley@skyking.OCE.ORST.EDU (John Stanley) wrote:
>> In article <MPG.fb38fbd4135e4698968c@news.min.net>,
>> John Porter <jdporter@min.net> wrote:
>> >Yep, that's what a moderated group is all about.  No governments,
>> >large or otherwise, get involved.  The perl community will
>> >moderate itself.
>> 
>> Really? I don't think so. I remember seeing a list of specific people
>> who would be the moderators for the moderated group. Or are you saying
>> that those people on the list are the "perl community"?
>
>Not that they "are" the community, but that they deeply understand
>the needs and the idiosyncracies of the community.  These guys
>are anything but "large government".  They have the interests of
>the community at heart.

While this may be true, and as a member and observer of this community
I don't believe it, there is still a big difference between your first
statement "the perl community will moderate itself" and "moderation by
a few members of the community".



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

Date: 1 May 1998 18:41:21 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: 1701 days hath September (was: Re: rename funciton)
Message-Id: <6id50h$jbi$1@ns1.arlut.utexas.edu>

stanley@skyking.OCE.ORST.EDU (John Stanley) writes:
> 
> A "group moderating itself" is the definition of "unmoderated
> newsgroup". "A select few moderating the rest" is how a moderated
> group works.

I think it's a matter of accepting certian logistics and a paradigm
with a certian goal in mind. If a moderated newsgroup borders on
censorship (highly doubtful, IMO), then it would be worth it to me to
have a hight S/N ration.

Consider, by way of analogy, people who choose to live in the "gated
communities" that have sprung up all over the USA. These communities
often have governing boards, elected by the residents (but with no
official ties to government entities). These governing boards impose
rules and conditions (via deed restrictions) for living in the
community ("A select few moderating the rest"). These rules, which I
find abhorrent, govern such things as the color one can paint their
house, the types of shrubberies one can plant in one's own yard, and
whether or not one can work on their own car in one's own driveway,
and all sorts of icky rules and restrictions.

If such rules were imposed by an official government entity, they
would be met with disgust; there would be a revolt, and heads would
roll. I find it ironic that the same people who often complain about
there being "too much government" in this country are the same ones
flocking in droves to such self-governing communities and happily
giving up their individual liberities in the name of high property
values.

I, personally, could never live in such a place. And I don't have to,
thank goodness. Property values and other material posessions aren't
very important to me. But they obviously are to people who live there,
and more power to 'em. OTOH, a high S/N ration in a perl newsgroup is
very important to me. If this means that people who choose to
participate in clp.moderated have to give up some liberty, then so be
it. It's worth it in the long run. (Note: I don't think that
participating will require or cause loss of liberty).

clp.misc isn't going away. If the idea of moderated newsgroups makes
you bristly, then you can participate there. I'm not intending to be
incendiary here; I'm just trying to point out that it's a matter of
individual priorities. People have a choice as to where they live
(most do, anyway), and people will have a choice of venues to discuss
perl issues.

--
Stuart McDow                                     Applied Research Laboratories
smcdow@arlut.utexas.edu                      The University of Texas at Austin
  "It is obvious that about 750,000 people ago, Austin was a wonderful City."


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

Date: Fri, 01 May 1998 18:55:01 GMT
From: jdporter@min.net (John Porter)
Subject: Re: 1701 days hath September (was: Re: rename funciton)
Message-Id: <MPG.fb3e61bff409c41989697@news.min.net>

On 1 May 1998 18:40:42 GMT,
in article <6id4va$jmi$1@news.NERO.NET>,
stanley@skyking.OCE.ORST.EDU (John Stanley) wrote:
> 
> While this may be true, and as a member and observer of this community
> I don't believe it, there is still a big difference between your first
> statement "the perl community will moderate itself" and "moderation by
> a few members of the community".

Not nearly as big as the difference between the moderating board of
clp.mod and "large governments".

JP


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

Date: 01 May 1998 11:29:55 -0700
From: Terrence Brannon <brannon@lnc.usc.edu>
Subject: \D fails when [^0-9] doesn't
Message-Id: <lbogxh6dzw.fsf@seal.usc.edu>



#!/usr/bin/perl 

$file_style="(.+)(,PID=[0-9]+)";

opendir(DOT, './');
GetOptions ( 'ignore-headers!'    => \$opt_ignore_headers );

#$ignore_header_re="^[^0-9]+";  #           THIS DOES NOT!!!!!!
$ignore_header_re="^\D+";       # <-------- THIS FAILS!!!!!!!!!

while ($file=readdir(DOT)) {
    if ($file =~ $file_style) {
	$outfile = $cobble_dir . $1;
	if (!$opt_ignore_headers) {
	    print "not ignoring headers \n";
	    $syscmd = "cat $raw_dir$file >> $outfile ; mv $raw_dir$file $raw_cobbled_dir";
	    print $syscmd, $/;
	    system($syscmd);
	} else {
	    print "ignoring headers \n";
	    open FILE, "<$raw_dir$file";
	    while (<FILE>) {
		print $_, $/;
		if (/$ignore_header_re/) {
		    print "IGNORING: $_\n";
		}
	    }
	}
    }
}


============================================================


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

Date: Fri, 1 May 1998 14:03:46 -0400
From: "Brian Schoenhofer" <bschoen@interlog.com>
Subject: ActiveWare PerlIS.dll
Message-Id: <6id2gc$3d0$1@news.interlog.com>

I am trying to get PerlIS.dll to work with NTW 4.0 service pack 3 and
personal web server.  I believe it is setup correctly but I have 1 problem.
I have a file "test.cgi" in a scripts directory.  It looks like this:

select(STDOUT);
print("<H1>Hello</H!>");

When I hit it with the browser I get a blank page. When there is a syntax
mistake (like forgetting a semi-colon) I get a message saying "the script
did not produce any output.".  This indicates that the PerlIS dll is running
and checking syntax but not sending any output.

Any ideas?

Thanks.
Brian




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

Date: Fri, 1 May 1998 10:49:34 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: Adding 600 users to a Linux password file
Message-Id: <6id1vl$ig3@hplntx.hpl.hp.com>

Brian Mathis wrote in message <3549E279.7D8BA4A0@kodak.com>...
 ...
>    $str =
>'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890./';
 ...
>ps: if anyone can come up with a better way to define $str, let me
>know..

$str = join '', 'a' .. 'z', 'A' .. 'Z', '0' .. '9', '.', '/';

--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com





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

Date: Fri, 1 May 1998 10:42:24 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: alarm
Message-Id: <6id1ic$ifk@hplntx.hpl.hp.com>

Stephen Hill wrote in message <3549DEA1.4CF231B8@huron.net>...
>I want to call a subroutine, but have a time limit on the routine. If
>the limit is hit, it exits the routine and continues with the rest of
>the script. Below is my attempt to do it, but when the alarm reaches 5
>seconds it exits the whole script, I want it to go back to the script
>and keep working away.
>
>& SubThingy;
>print "It didn't kill the whole script, just the subroutine";
>exit;
>
>sub SubThingy{
>alarm(5);
>sleep 40;
>print "hello world";
>}
>
>
>Any suggestions?
>
>buck@huron.net


You have to trap the SIGALRM interrupt raised when the alarm rings.
See the Blue Camel, p. 341, or 'perldoc perlipc'.

--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com





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

Date: Fri, 1 May 1998 17:39:50 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: alarm
Message-Id: <EsAH2E.qC@news.boeing.com>

In article <3549DEA1.4CF231B8@huron.net>, Stephen Hill  <buck@huron.net> wrote:
>I want to call a subroutine, but have a time limit on the routine. If
>the limit is hit, it exits the routine and continues with the rest of
>the script. Below is my attempt to do it, but when the alarm reaches 5
>seconds it exits the whole script, I want it to go back to the script
>and keep working away.
>
>& SubThingy;
>print "It didn't kill the whole script, just the subroutine";
>exit;
>
>sub SubThingy{
>alarm(5);
>sleep 40;
>print "hello world";
>}
>
>
>Any suggestions?

perldoc -f alarm.  There's a really good example that'll
get you going.


HTH,
--
Charles DeRykus
>
>buck@huron.net
>




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

Date: 1 May 1998 16:52:20 GMT
From: tigger@io.com.nospaam
Subject: Re: Bidirectional pipe filehandles?
Message-Id: <6icuk4$ps1$1@nntp-2.io.com>

Check out the open2() command, and the Comm.pl module.


Lou Poppler <lwp@flenser.ibm.net> wrote:
> : Now, on page 163 of the 1st Edition camel book (the "open" reference),
> : Larry and Randal tell me that an open command which pipes both in and out
> : should be easy to build. How, though? I've been poring over the pipe() and
> : fork() man pages and function references for a couple hours now, and I'm
> : not seeing it.

> : Alik

-- 
---------------------------------------------------------------------
On the side of the software box, in the "System Requirements" section,
it said "Requires Windows 95 or better".  So I installed Linux.
---------------------------------------------------------------------


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

Date: Fri, 01 May 1998 11:57:40 -0400
From: Brian Mathis <brianm@kodak.com>
To: "Frank L. Quednau" <quednauf@nortel.co.uk>
Subject: Re: email attachments
Message-Id: <3549F0F4.9DADB56D@kodak.com>

Frank L. Quednau wrote:
>  Again, visit my webpage under
> http://www.surrey.ac.uk/~me51fq/perl/perl.htm
> The first (and right now only) section is on how to produce an
> attachment.


It's great that you have set up a page to help people with this, but you
should really use the Net::SMTP module, especially if you figure
millions of people are going to use your page for help.

Also, I was just browsing through CPAN and the MIME::Lite module looks
like it does things very nicely.

Brian Mathis
orev


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

Date: Fri, 01 May 1998 12:26:22 -0400
From: Eryq <eryq@zeegee.com>
To: Rob Lowe <rob@imedianet.com>
Subject: Re: email attachments
Message-Id: <3549F7AE.48F69FC5@zeegee.com>

Rob Lowe wrote:
> 
> how do I include an attachment to an email using the standard
> open(MAIL, "| /usr/sbin/sendmail -t");
> print MAIL "..";  etc.,
> format

Get a copy of the new MIME::Lite module, from the CPAN 
authors/Eryq directory.

You can do attachments, the files can be really long, you can output
the MIME to a string, or a filehandle, and you can even send the message
(on Unix).  A sample program for MIME-encoding from the command line
is included.

Example:

        # Create a new multipart message:
        $msg = new MIME::Lite 
                    From    =>'me@myhost.com',
                    To      =>'you@yourhost.com',
                    Cc      =>'some@other.com, some@more.com',
                    Subject =>'A message with 2 parts...',
                    Type    =>'multipart/mixed';
        
        # Add parts (each "attach" has same arguments as "new"):
        attach $msg 
                    Type     =>'TEXT',   
                    Data     =>"Here's the GIF file you wanted";  
        attach $msg 
                    Type     =>'image/gif',
                    Path     =>'aaa000123.gif',
                    Filename =>'logo.gif';

    Output a message:

        # As a string...
        $str = $msg->as_string;
        
        # To a filehandle (say, a "sendmail" stream)...
        $msg->print(\*SENDMAIL);

Hope that helps!

-- 
  ___  _ _ _   _  ___ _   Eryq (eryq@zeegee.com)
 / _ \| '_| | | |/ _ ' /  President, Zero G Inc: http://www.zeegee.com/
|  __/| | | |_| | |_| |   
 \___||_|  \__, |\__, |___/\  Visit STREETWISE, Chicago's newspaper by/
           |___/    |______/ of the homeless: http://www.streetwise.org


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

Date: Fri, 01 May 1998 10:55:51 -0700
From: David Leavenworth <davidl@inkttomi.com>
Subject: Re: fork problem
Message-Id: <354A0CA6.5A4046F4@inkttomi.com>

Hey Dave,

The code you have should execute one child at a time, exactly the
way you have seen it run.  The reason is that the next fork takes
place only after the current child exits and closes the filehandle
that the parent is listening to.  I.E., "while (<$fh>)" will only
complete after $fh closes.

I can think of two different ways you can do this and both start with
taking the "listen" part of the script ("while (<$fh>)") outside
the loop that creates the children
  "for ($count=1;$count<=3;$count++)"

This first way would be to create all the children and save the
filehandles in an array (you already do this with the snippet you
posted).  After all the children are created, do something like the
following that listens to each child in turn:
    for $fh (@handles) {
        while(<$fh>) {
            push @results, $_;
        }
    }

One drawback of this method is that there is some potentially wasted
time if the last child actually finishes before the first.

The second way uses a "select" statement.  This neat statement
take a list of file descriptors and returns only when one of the
file descriptors are ready to do IO.  Explaining this is a little
beyond my descriptive power though!  Check out page 211-212 in the
2nd Edition "Programming Perl" book.  You might want to check out
some IPC or network programming books also, if you want to go this
route.

Here is that snippet back with my first solution.

Hope this helps!
Dave (L)
--------------------------------
#! /usr/local/bin/perl -w

use 5.004;
use strict;
use diagnostics;
use FileHandle;

my ($fh,$count, $pid, $read_a_line, @child_list, @handles, @results);

for ($count=1;$count<=3;$count++) {
        print "Doing $count.   ";
        $handles[$count-1]=FileHandle->new();
        $pid=open($handles[$count-1],'-|');
        if (not defined $pid) {
                die "Couldn't fork: $?\n";
        }
                if ($pid) {
                        #Parent
                        push @child_list,$pid;
                        my $fh=$handles[$count-1];
                        #while (<$fh>) {
                        #        push @results, $_;
                        #}
                } else {
                        #Child
                        my $timestamp;
                        # This next is just a little something
                        # to keep the children from all finishing
                        # at the same time.
                        sleep (10 - (2 * $count));
                        $timestamp=time();
                        print "timestamp: $timestamp\n";
                        exit(0);
                }
}
print "\n";

foreach $fh (@handles) {
  while(<$fh>) {
    push @results, $_;
  }
}

$count=0;
foreach (@results) {
        print ("$_\n");
}


Dave Parkin wrote:

> I'm trying to write a program to do multiple simultaneous operations
> in order to reduce the total time the program takes to run. I've got
> the fork process working (thanks Tom), but am having real problems
> retrieving the output of the children.

[SNIP]

> The problem I'm having seems to be in the parent area where I try to
> read the data from the filehandle. If I comment out the while loop, it
> runs fine and the children are produced. If I have in the while loop,
> the children are executed one after the other.
>
> I've tried different approaches, but am stuck. Can anyone help,
> please?
>
> Dave





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

Date: Fri, 1 May 1998 11:57:29 -0400
From: Bryan T Hoch <bth@acsu.buffalo.edu>
Subject: How do I print a string that is in a certain format?
Message-Id: <Pine.GSO.3.96.980501115107.6917B-100000@xena.acsu.buffalo.edu>

OK, I'm going to rephrase my question from earlier so to avoid
confusion...

If I have a string involving commas, parentheses, and colons and I want to
print it in a certain format how do I do it?

For example, if I had the following string $string that contained

231, Hello, 43, (big: medium: small), (right: wrong)

What code could I write so that it would print out in the format of:

231 Hello 43 big    right
	     medium wrong
	     small


What I thought I should do is break it up into seperate elements in an
array using the split command and using , as a delimiter. Thus the array
would contain:
231
Hello
43
(big: medium: small)
(right: wrong)

But I am unsure where to go from here.
Any help would be appreciated.
Thanks in advance.
						Bryan H



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

Date: 1 May 1998 17:36:38 GMT
From: "Allan M. Due" <alpaca@iname.com>
Subject: Re: How do I print a string that is in a certain format?
Message-Id: <6id176$kkv$0@206.165.146.151>

Bryan,

    Well here is one way.  I messed about with your problem and here is one
solution.  Very new to Perl so I am sure there are will better ways to do
this forthcoming.  I am very interested in seeing the more elegent
solutions.
    I am split, then split again, appending to the temp array as I go.
There must be simpler ways to do this, but at least this one works.

$in_string = "231, Hello, 43, (big: medium: small), (right: wrong)";

foreach  (split(/,/,$in_string)) {
    split(/:/);
    $temp[0] = $temp[0].$_[0];
    $temp[1] = $temp[1].$_[1];
    $temp[2] = $temp[2].$_[2];
    }

foreach (@temp) {
      print "$_\n";
      }

and my output is:
231 Hello 43 (big (right
 medium wrong)
 small)

I will leave it to you to work on the formating etc.  Hope this helps.

Allan M. Due
Allan M. Due
Due@discovernet.net
Due@WhiteCrow.net

"There are two major products that come out of Berkeley: LSD and UNIX. We
don't believe this to be a coincidence."
-Jeremy S. Anderson






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

Date: Fri, 01 May 1998 18:43:12 GMT
From: jdporter@min.net (John Porter)
Subject: Re: How do I print a string that is in a certain format?
Message-Id: <MPG.fb3e356a8428003989695@news.min.net>

On Fri, 1 May 1998 11:57:29 -0400,
in article <Pine.GSO.3.96.980501115107.6917B-
100000@xena.acsu.buffalo.edu>,
bth@acsu.buffalo.edu (Bryan T Hoch) wrote:
> 231, Hello, 43, (big: medium: small), (right: wrong)

I'm inclined to do it like this:

$a = '231, Hello, 43, (big: medium: small), (right: wrong)';

# parse it up into a table (2-d array):
@dd = map { /^\((.*)\)$/ ? [split(/:\s*/,$1)] : [$_] } split(/,\s*/,$a);

# invert the array:
for $r ( 0..$#dd ) {
  for $c ( 0..$#{$dd[$r]} ) {
    $d[$c][$r] = $dd[$r][$c];
  }
}

# print out each row and column:
for $r ( 0..$#d ) {
  for $c ( 0..$#{$d[$r]} ) {
    defined $d[$r][$c] or $d[$r][$c] = '';
    printf( "%-8s", $d[$r][$c] );
  }
  print "\n";
}

hth,
John Porter


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

Date: Fri, 01 May 1998 18:00:10 GMT
From: ralber@ix.netcom.com (Rick Alber)
Subject: How to Schedule Program Execution
Message-Id: <6id2dc$p03@sjx-ixn1.ix.netcom.com>

I run a site, www.drscience.com, which is automatically updated each
night  via a PERL script. The script is triggered by a crontab program
running on my ISP's Apache server. Unfortunately, I soon won't be able
to use a crontab program and would like to figure out a way to trigger
the program each night using PERL or javascript. If anyone out there
has any ideas I'm all ears.

The program needs to run sometime between midnight and 3am each night.
I get plenty of traffic on the Dr. Science site, so I can count on
many visitors hitting the home page during that time. My thought was
to run a small program each time a visitor hit  the home page that
checked to see whether it was between midnight and 3am and, if the
program had not already been run that evening, to call the updating
program.

Does this make sense? Or is there another approach that would be more
efficient? Any ideas are welcome.

Thanks.

---- Rick Alber



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

Date: Fri, 01 May 1998 14:11:15 -0400
From: Brian Mathis <brianm@kodak.com>
To: Rick Alber <ralber@ix.netcom.com>
Subject: Re: How to Schedule Program Execution
Message-Id: <354A1043.54918B44@kodak.com>

Rick Alber wrote:
> 
> I run a site, www.drscience.com, which is automatically updated each
> night  via a PERL script. The script is triggered by a crontab program
> running on my ISP's Apache server. Unfortunately, I soon won't be able
> to use a crontab program and would like to figure out a way to trigger
> the program each night using PERL or javascript. If anyone out there
> has any ideas I'm all ears.
> 
> The program needs to run sometime between midnight and 3am each night.
> I get plenty of traffic on the Dr. Science site, so I can count on
> many visitors hitting the home page during that time. My thought was
> to run a small program each time a visitor hit  the home page that
> checked to see whether it was between midnight and 3am and, if the
> program had not already been run that evening, to call the updating
> program.
> 
> Does this make sense? Or is there another approach that would be more
> efficient? Any ideas are welcome.
> 
> Thanks.
> 
> ---- Rick Alber

I suggest you fight with the sysadmin until you are red in the face to
maintain access to crontab.

Other than that, running a cgi that will check the time, and run the
program, as you suggested, might not work, depending on your web
server.  Most web servers kill a cgi process when STDOUT is closed.  So,
if you fork something off, then exit, it might kill the child.  You
might be able to get around this by executing the command via nohup.

Brian Mathis
orev


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

Date: 1 May 1998 16:48:48 GMT
From: Aaron Kushner <akushner@cup.hp.com>
Subject: how to write error log msg when using multiple modules
Message-Id: <6icudg$7sq$1@ocean.cup.hp.com>

I am working on a project that has several modules and would like to
have error messages written to a common log file. I had been using the
'die' command, but the program will be running as a daemon now, and I
would rather log error messages that occur within the different modules
instead of halting the program.

I intend to open the log file in one of the subroutines in the main
program and would like to avoid passing the file handle to every
procedure. Is there a better way to have a global file handle that can
be accessed by all of the modules?

I suppose having each module open/close the logfile would be one method,
but then I would have the same problem of passing the name of the logfile
to each module.

Thanks for the help,

Aaron Kushner
akushner@ cup.hp.com


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

Date: 1 May 1998 17:54:23 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: how to write error log msg when using multiple modules
Message-Id: <6id28f$2g7@news.service.uci.edu>

	[mail & posted]
In article <6icudg$7sq$1@ocean.cup.hp.com>,
Aaron Kushner  <akushner@cup.hp.com> wrote:

>I am working on a project that has several modules and would like to
>have error messages written to a common log file. I had been using the
>'die' command, but the program will be running as a daemon now, and I
>would rather log error messages that occur within the different modules
>instead of halting the program.

Look at the special __DIE__ and __WARN__ signal handlers.  Ie.  You
can registers functions for these in %SIG to intercept all die
and warn calls.

You may want to look at the CGI::Carp module as an example.

	--ewh
-- 
             Earl Hood              | University of California: Irvine
      ehood@medusa.acs.uci.edu      |      Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME


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

Date: Fri, 01 May 1998 14:27:37 -0400
From: David Boyce <David.Boyce@fmr.com>
Subject: Re: how to write error log msg when using multiple modules
Message-Id: <354A1419.FDD81BD8@fmr.com>

Earl Hood wrote:
> In article <6icudg$7sq$1@ocean.cup.hp.com>,
> Aaron Kushner  <akushner@cup.hp.com> wrote:
>
> You may want to look at the CGI::Carp module as an example.
> 
>         --ewh

Or "perldoc Sys::Syslog".

-David


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

Date: 1 May 1998 17:48:40 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: http Reg Exp
Message-Id: <6id1tp$29h@news.service.uci.edu>

In article <35492974.BE9D678@coos.dartmouth.edu>,
Ronald J Kimball  <rjk@coos.dartmouth.edu> wrote:

>> If proper <URL:...> were to be done (ie. urls broken over multiple
>> lines) along with general detection, it would complicate the filtering
>> code.  If using Perl, you would have to slurp the entire file into
>> memory instead of doing the more memory efficient line-by-line filtering.

>Why?

>Read in a line.  If it contains an unterminated '<URL:' then read in and
>concatenate the next line until you find the matching '>'.

Yes that is one way to do it.  But then you have to buffer output until
the terminating '>' is encountered.  I.e.  You cannot just start the <A
HREF...> markup since you do not know what the full URL is.  If you
have the memory (and normally messages are not very large), the code I
did will appear to be cleaner than a line-by-line approach (IMHO).

It looks like I just reversed my original statement.  However, the
statment was within the context of the slurp method version the common
(DejaNews) method (multiline urls not dealt with, but free form URLs
are checked for).  The slurp method looks cleaner than a line-by-line
method (with multiline url detection) since the line-by-line sort-of
degenerates to the the slurp method for multiline urls; plus with
multiple regexes needed to do proper parsing.

Remember, I am also dealing with urls not deliminted by <URL:...>.
Code just for dealing with <URL:...> is trivial.  My initial impression
is that if you wanted to do a line-by-line conversion and achieve the
same results of my posted code, the resulting code will be more
complicated, maybe even slower.

	--ewh
-- 
             Earl Hood              | University of California: Irvine
      ehood@medusa.acs.uci.edu      |      Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME


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

Date: Fri, 01 May 1998 11:04:10 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: Looking for an idiom (cf. Schwartzian Transform)
Message-Id: <3549E46A.F5547561@negia.net>

Randal Schwartz wrote:
> 
> >>>>> "Mitchell" == Mitchell Morris <mgm@unpkhswm04.bscc.bls.com> writes:
> 
> Mitchell> In short, I wanted to sort a list where the key words were
> Mitchell> an optional number followed by an alpha word, e.g. Foo,
> Mitchell> 0Foo, 1Foo, Bar, 0Bar, 1Bar, etc.  I of course wanted all
> Mitchell> the "Foo" words to sort together, and all in numeric
> Mitchell> sequence amongst themselves. My first try, which doesn't
> Mitchell> work, was:
> 
[SNIP]
> 
> @result = map { $_ -> [0] } sort {
>                 $a->[2] cmp $b->[2] or # words first
>                 $a->[1] <=> $b->[1] or # numbers second
>                 $a->[0] cmp $b->[0] # fall back to entire item
>         } map { [
>                 $_, # item 0
>                 /(\d+)(.*)/s # item 1, item 2
>         ] } @data;

hmm, when i run the sample data from the original post through
this i get:

Bar
Foo
0Bar
1Bar
0Foo
1Foo

looks like the (\d+) causing problems again.

-- 
Dan Boorstein   home: danboo@negia.net  work: danboo@y-dna.com

 "THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
                         - Cosmic AC


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

Date: Fri, 01 May 1998 11:05:42 -0600
From: otis@POPULUS.net
Subject: Re: Perl web server....
Message-Id: <6icrsm$nev$1@nnrp1.dejanews.com>

Search for Plexus, I believe that was one of the first web servers written in
Perl.
You could write one fairly easily using HTTPD::* modules.
See the CPAN site near you.

Otis

In article <3548B653.755C6DB8@webchamps.com>#1/1,
  Chris Wertman <chrisw@webchamps.com> wrote:
>
> Some time ago I saw a webserver written in perl.. I have searched .
> engines.DejaNews etc and stilll cannot find it ,... any pointers as to
> where on the web it may live are appreciated...
>
> Chris Wertman
>
>


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 1 May 1998 16:29:50 GMT
From: Art Cohen <upsetter@shore.net>
Subject: Re: QRe: == vs. eq
Message-Id: <6ict9u$duj@fridge.shore.net>

N i c l a s O l o f s s o n <gurun@acc.umu.se> wrote:

: How about, Unix is more intuitive and Windows is less difficult!
: I would say that when you are used to Unix as opposit to "used to
: windows") you'll find the Unix extremely intuitive (though more
: difficult).

I'm defining intuitive as "easy to figure with no prior experience", so
"once you are used to Unix" is irrelevant. 

--Art

National Ska/Reggae Calendar: www.ziplink.net/~upsetter/ska/calendar.html
        Boston Ska Home Page: www.ziplink.net/~upsetter/ska/index.html



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

Date: Fri, 1 May 1998 12:28:15 -0400
From: mattd\@stumpworld.com (Matt Dunn)
Subject: strictly speaking..
Message-Id: <MPG.fb3c228762172db989680@news.shore.net>

Does anyone know off the top of their heads whether having 'use strict' 
slows down the interpreter or speeds it up? This is assuming, of course, 
that the script itself works equally well in strict and in 'casual'.

Basically, my question is whether strict actually changes the way the 
compiler interprets a script, or if it just gives the compiler more 
things to do as it's parsing.

Thanx in advance...

-Matt

PS. anyone know the origins of the variable name $sememe in strict?


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

Date: 01 May 1998 20:59:56 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: strictly speaking..
Message-Id: <oeehg3950tf.fsf@alpha.hut.fi>


Why not

	time perl -Mstrict yourscript.pl

and

	time perl yourscript.pl

instead of guessing?

(You did not say which OS you are using.  I assumed UNIX,
 hence the "time" shell command)

-- 
$jhi++; # http://www.iki.fi/~jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen


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

Date: Fri, 01 May 1998 17:46:34 +0100
From: Ian Boys <boys@aspentech.com>
Subject: Re: visual basic replacement
Message-Id: <3549FC6A.3359@aspentech.com>

Jan Dubois wrote:
> 
> Francesc Guasch <frankie@etsetb.upc.es> wrote:
> 
> >I know I can use DBI for access a db, what
> >I want to know if perl is suitable for building
> >typical windows stuff and if there are modules
> >for displaying forms and dialogs ...
> 
> The module is called Tk (and it is included in the binary distribution of
> standard Perl too!). It doesn't work with AS Perl though.
> 

However pTk is still at Tk 4.0, which gives a Motif-like look and 
feel under Windows rather than an MS look and feel.  Tk 8.0 gives
Windows-style widgets under Windows, but I don't think this is 
available with pTk yet.

You could have a look at TCL/TK 8.0, but you will find this is very 
different from VB (as indeed is Perl).  You might combine TCL/TK for 
the GUI bits and Perl for the programming, using sockets or files for
intercommunication.  But this will get you quite deep into systems
design and programming challenges and may not be where you wish to go.

Ian


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

Date: Fri, 01 May 1998 12:54:57 -0600
From: tiles@pyramidtile.com
Subject: web_store.cgi error in the browser
Message-Id: <6id29g$95$1@nnrp1.dejanews.com>

I have Web_store shopping cart software that I downloaded at Selena Sols
website as well as buying the book on Web_store.
I've read quite extensively on all the possible problems on why the
web_store.cgi script does not work. Even though I'm just a beginner:)

I set the perl interpeter right, I took out the javascript segment in
web_store.cgi as well as the setup file and set the html one.
I set the permissions correctly I think. I uploaded in ascii to redue the
perl interpeter and changes that I needed to make. I edited in the Dos
command prompt of the Windows computer that I am using.

But when I type:
http://www.pyramidtile.com/web_store/Web_store/web_store.cgi

it comes up error, any suggestions would greatly be apprectiated
Bill

tiles@pyramidtile.com
or judya@sirius.com

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 1 May 98 15:46:25 GMT
From: "James Richardson" <jamesr@aethos.co.uk.nospam>
Subject: Re: Why doesn't this work?
Message-Id: <01bd7519$c25aba80$26c0a4c1@kitkat.aethos.co.uk>



Dave Neuer <daven@ldr.com> wrote in article <daven-3004980931290001@daven.ldr.com>...
> In article <3541D406.78814D7C@spiritone.com>, smoothie@spiritone.com wrote:
> > $lines =~ s/.*(<meta\s.*>).*/$1/mg;
> > 
> > Though this didn't remove anything after the meta tag (which I realized
> > was because the .*> matches everything from the first attribute's first
> > character through the closing angle bracket of the entire HTML file),
> > but at least it cut out the prematch stuff.

You could use 

$lines =~ s/<meta.*?>//isg;

 .*? is a minimal match - See man perlre
i cos you could have meta or META
s cos the tag may be split across lines.

I didnt look really at the rest of the program....hope this is of some use...

James




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

Date: Fri, 01 May 1998 17:07:55 +0100
From: Katalin Nadassy <nadassy@ebi.ac.uk>
Subject: Yet another plead for help
Message-Id: <3549F35A.AA105740@ebi.ac.uk>


--------------B6B0C760382750C898210942
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hello,

First of all I really want to thank all the people who helped me with my
previous problem a few days ago.  However, now I would like to ask your
help again with the following:
My programme produces the following output:

    6)    AC     7       --     --      15.56
 12)   TC     13      --     --      24.97
 13)   AE     58      --     --      36.13
 14)   CE     57      --     --      34.08
 6)    AC     7       --     --      --      -19.62

what I would like is if the first number is the same in two or more
lines (6 in this case) than I
would like to combine the two line but in a way that I get the following
:
  6)  AC  7  -- -- 15.56  -19.62

So far all I was able to achieve is:
   6) AC 7 -- -- 15.56 -- -- -- -19.62

Could anyone help me?  Thank you very much for any help that you can
give me!!!!


Katalin
A very grateful beginner

--

*******************************************************************************
Katalin Nadassy                 E-mail address: nadassy@ebi.ac.uk
EMBL-Outstation                 Phone number:   01223-494655
EBI Wellcome Trust              International:  44 1223-494655
Genome Campus                   Fax number:     01223-494468
Hinxton                         International:  44 1223-494468
Cambridge CB10 1SD
United Kingdom
*******************************************************************************



--------------B6B0C760382750C898210942
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
Hello,

<P>First of all I really want to thank all the people who helped me with
my previous problem a few days ago.&nbsp; However, now I would like to
ask your help again with the following:
<BR>My programme produces the following output:

<P>&nbsp;&nbsp;&nbsp; 6)&nbsp;&nbsp;&nbsp; AC&nbsp;&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
--&nbsp;&nbsp;&nbsp;&nbsp; --&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 15.56
<BR>&nbsp;12)&nbsp;&nbsp; TC&nbsp;&nbsp;&nbsp;&nbsp; 13&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
--&nbsp;&nbsp;&nbsp;&nbsp; --&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 24.97
<BR>&nbsp;13)&nbsp;&nbsp; AE&nbsp;&nbsp;&nbsp;&nbsp; 58&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
--&nbsp;&nbsp;&nbsp;&nbsp; --&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 36.13
<BR>&nbsp;14)&nbsp;&nbsp; CE&nbsp;&nbsp;&nbsp;&nbsp; 57&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
--&nbsp;&nbsp;&nbsp;&nbsp; --&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 34.08
<BR>&nbsp;6)&nbsp;&nbsp;&nbsp; AC&nbsp;&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
--&nbsp;&nbsp;&nbsp;&nbsp; --&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-19.62

<P>what I would like is if the first number is the same in two or more
lines (6 in this case) than I
<BR>would like to combine the two line but in a way that I get the following
:
<BR>&nbsp; 6)&nbsp; AC&nbsp; 7&nbsp; -- -- 15.56&nbsp; -19.62

<P>So far all I was able to achieve is:
<BR>&nbsp;&nbsp; 6) AC 7 -- -- 15.56 -- -- -- -19.62

<P>Could anyone help me?&nbsp; Thank you very much for any help that you
can give me!!!!
<BR>&nbsp;

<P>Katalin
<BR>A very grateful beginner
<PRE>--&nbsp;



*******************************************************************************
Katalin Nadassy&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; E-mail address: nadassy@ebi.ac.uk
EMBL-Outstation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Phone number:&nbsp;&nbsp; 01223-494655&nbsp;
EBI Wellcome Trust&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; International:&nbsp; 44 1223-494655&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Genome Campus&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fax number:&nbsp;&nbsp;&nbsp;&nbsp; 01223-494468
Hinxton&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; International:&nbsp; 44 1223-494468
Cambridge CB10 1SD
United Kingdom
*******************************************************************************</PRE>
&nbsp;</HTML>

--------------B6B0C760382750C898210942--



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

Date: 1 May 1998 17:24:27 GMT
From: Aaron Kushner <akushner@cup.hp.com>
Subject: Re: Yet another plead for help
Message-Id: <6id0gb$7sq$2@ocean.cup.hp.com>

Does this do what you need?

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

while (defined($line = <DATA>)) {
 chomp $line;
 print $line,"\n";

 @data = split ' ', $line;

 $lastitem = $data[$#data];

 if (not exists $new{$data[0]}) {
    $new{$data[0]} = $line;
 } else {
    $new{$data[0]} .= " $lastitem";
 }
}

print "\n --- New format \n";

foreach $key (keys %new) {
   print "$new{$key}\n";
}

__DATA__
6)    AC     7       --     --      15.56
12)   TC     13      --     --      24.97
13)   AE     58      --     --      36.13
14)   CE     57      --     --      34.08
6)    AC     7       --     --      --      -19.62
------------ cut here -----------

sample output:

6)    AC     7       --     --      15.56
12)   TC     13      --     --      24.97
13)   AE     58      --     --      36.13
14)   CE     57      --     --      34.08
6)    AC     7       --     --      --      -19.62

 --- New format 
12)   TC     13      --     --      24.97
13)   AE     58      --     --      36.13
14)   CE     57      --     --      34.08
6)    AC     7       --     --      15.56 -19.62



Katalin Nadassy <nadassy@ebi.ac.uk> wrote:
> Hello,

> First of all I really want to thank all the people who helped me with my
> previous problem a few days ago.  However, now I would like to ask your
> help again with the following:
> My programme produces the following output:

>     6)    AC     7       --     --      15.56
>  12)   TC     13      --     --      24.97
>  13)   AE     58      --     --      36.13
>  14)   CE     57      --     --      34.08
>  6)    AC     7       --     --      --      -19.62

> what I would like is if the first number is the same in two or more
> lines (6 in this case) than I
> would like to combine the two line but in a way that I get the following
> :
>   6)  AC  7  -- -- 15.56  -19.62

> So far all I was able to achieve is:
>    6) AC 7 -- -- 15.56 -- -- -- -19.62

> Could anyone help me?  Thank you very much for any help that you can
> give me!!!!



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

Date: Fri, 01 May 1998 18:48:13 GMT
From: jdporter@min.net (John Porter)
Subject: Re: Yet another plead for help
Message-Id: <MPG.fb3e4833e105b7f989696@news.min.net>

On Fri, 01 May 1998 17:07:55 +0100,
in article <3549F35A.AA105740@ebi.ac.uk>,
nadassy@ebi.ac.uk (Katalin Nadassy) wrote:
> 
> My programme produces the following output:
> 
>  6)    AC     7       --     --      15.56
>  12)   TC     13      --     --      24.97
>  13)   AE     58      --     --      36.13
>  14)   CE     57      --     --      34.08
>  6)    AC     7       --     --      --      -19.62
> 
> what I would like is if the first number is the same in two or more
> lines (6 in this case) than I
> would like to combine the two line but in a way that I get the following
> :
>   6)  AC  7  -- -- 15.56  -19.62
> 
> So far all I was able to achieve is:
>    6) AC 7 -- -- 15.56 -- -- -- -19.62

If you expect us to help you with your homework, you could at
least post the code that you've written so far.

It would be one thing to read the input such as you give,
and transform it into the form that you want.
But it seems like the correct solution would be to modify
your program which is giving that output in the first place.

John Porter


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 2473
**************************************

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