[19503] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1698 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 5 14:07:27 2001

Date: Wed, 5 Sep 2001 11:05:11 -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: <999713111-v10-i1698@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 5 Sep 2001     Volume: 10 Number: 1698

Today's topics:
    Re: ActivePerl says Out of Memory, but I'm not out of m <mjcarman@home.com>
    Re: can this be done with regex? (stupid question proba (Helgi Briem)
        cgi.pm cookie function - am I missing something? (Jennifer)
    Re: cgi.pm cookie function - am I missing something? <godzilla@stomp.stomp.tokyo>
        data for perl hash table <Mark.Pennington@sdrc.com>
    Re: data for perl hash table (Mark Jason Dominus)
        Disappearing Compiler messages <david.f.dafoe@boeing.com>
        DumbQuestion::CGI_parser <martin@people-com.com>
    Re: DumbQuestion::CGI_parser (Malcolm Dew-Jones)
        fore! (Steven M. O'Neill)
    Re: fore! (Rafael Garcia-Suarez)
    Re: Godzilla DOS Internal Script Timer <godzilla@stomp.stomp.tokyo>
    Re: Godzilla DOS Internal Script Timer <godzilla@stomp.stomp.tokyo>
    Re: Header error with Activeperl on Win2K Sp2 (Ross)
    Re: Header error with Activeperl on Win2K Sp2 (Alex SC)
    Re: How can I find the PID's of my children? (Ilja Tabachniks)
        How can I wait in perl? <jonni@ifm.liu.nospam.se>
    Re: How can I wait in perl? <jasper@guideguide.com>
    Re: HTML syntax (second pair of eyes) <bart.lateur@skynet.be>
    Re: ignoring lines in file using array of phrases to sk <krahnj@acm.org>
    Re: Match starting from the nth occurrence of a charact (Marc Schaefer)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 05 Sep 2001 08:09:22 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: ActivePerl says Out of Memory, but I'm not out of memory?  Is this  a  limitation in the Perl build I have?
Message-Id: <3B962402.3FDD41ED@home.com>

Jonadab the Unsightly One wrote:
> 
> Joe Schaefer <joe+usenet@sunstarsys.com> wrote:
> 
> > Well, it's hard to follow what you are doing,
> 
> I know; the longer version was more legible, but it
> was also more general and... lengthy.

Well, okay, but "post a short piece of code" doesn't mean "shorten by
squeezing out all the whitespace." :)
 
> What it's doing is working out a solution to a FreeCell
> position, by brute force of trying every possible move,
> recursively.

Ah. Are you trying to prove the belief that every game can be won? (via
brute force, no less).

Anyway, there are a helluva lot of permutations for playing out a game
of Freecell. What do you do when you follow a path to a dead end? As
near as I can tell, $moves only grows. I would expect it to be cleared
when you reach an impass so that you can start fresh down another path.

> > but I would have expected to see a lot more usage of
> > the "my" keyword in your script.
> 
> I come from a lisp background, so I was using local instead.
> (I associate lexical scoping with C++ and other forms of evil.)
> However, now that you mention it...

Scoping is your friend. It may not save memory, but it makes programming
much easier.
 
> > My best guess is that one of your ".=" expressions
> > in the workfrom -> trytoplay -> workfrom ... recursion sequence
> > is making a *very* long string, and by the time your script
> > consumes 112MB, it's looking to malloc over 50 MB of additional
> > RAM before crapping out.
> 
> This made sense, so I added a couple of lines to write out
> the contents of $moves to sequentially-numbered files each
> iteration.  At the longest, right before the bailout, file
> 3446 is 149027 bytes.  Still, that's bit longer than I
> would have expected it to be at that level of iteration,
> and I think...
> 
> No, I changed the beginning of workfrom to this:
> sub workfrom { local $card;
>     ( $stack{0}, $stack{1}, $stack{2}, $stack{3},
>       $stack{4}, $stack{5}, $stack{6}, $stack{7},
>       $cell{1},  $cell{2},  $cell{3},  $cell{4},
>       $build{0}, $build{14}, $build{28}, $build{42},
>       local $moves) = @_;

You're using all globals, and the param list you pass to workform() is
matches what you unpack it into. All you're doing is copying stuff onto
itself...

-mjc


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

Date: Wed, 05 Sep 2001 13:53:37 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: can this be done with regex? (stupid question probably)
Message-Id: <3b962d9c.595485923@news.isholf.is>

On Tue, 04 Sep 2001 22:39:37 GMT, kick.me@love.me (crow)
wrote:

>if this is an easy one then just tell me to go read some manual but for now 
>i couldn't solve it. just got some basic knowledge.
>
>suppose you have a string like this "6542{"
>now the last character (always the last one) needs to be substituted.
>{ to 0, A to 1, B to 2 and so on.
>
>i was thinking of
>s/[{ABCDEFGH]$/[0123456789]/
>but of course that doesn't work.  the last char will be mapped but replaced 
>by [0123456789].

It's not a stupid question and  could be solved
with a substitution although to my mind the tr 
transliteration operator seems more natural 
for this task, translating one character for another.

Your regex is correct and the only change needed is
to change s/[{ABCDEFGH]$/[0123456789]/ to
tr[{ABCDEFGH]$/[0123456789]/
and your home.

Regards, 
Helgi Briem


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

Date: 5 Sep 2001 09:54:17 -0700
From: jennlee.2@eudoramail.com (Jennifer)
Subject: cgi.pm cookie function - am I missing something?
Message-Id: <e836199f.0109050854.360e8b8f@posting.google.com>

Hi,

I'm running into some issues while using cgi.pm and I'm hoping someone
here can point me in the right direction.

My script is like a mini-shopping cart where users can add items and
they are stored via cookie. It doesn't actually process payments, just
keeps track of stuff in a cookie called CoStore.

At the beginning of the script, I check to see if a cookie already
exists like:

%userorders	=	cookie('CoStore');

If a user is adding (or deleting) a transaction from their order, I
change the value of the %userorders hash appropriately (or setup a new
%userorders hash if there wasn't any returned from the cookie
function), and save the cookie like:

$cookie=cookie(-name=>'CoStore',
		-value=>\%userorders,
		-path=>'/',
		-expires=>'+7D');
		print header(-cookie=>[$cookie]);

It appears that the cookie successfully sets.  In fact, I can go and
see it in the cookies files used for IE and Netscape.

However, even with the cookie there and visible to me in text, the
first use of the cookie function to set %userorders never ever returns
the cookie.

What's also wierd, is that another script on my site sets a different
cookie with a different name, and if in my script I check for that
cookie like:
%userorders = cookie('U_Forms');
it finds that cookie OK.

So I'm stumped as to why it finds that one and not the other one.

My IE cookie file actually shows the following:

U_Forms
req_name&Jennifer[snipped values]
[snipped domain]/
0
471652480
29472745
1131420640
29436535
*
CoStore
1&1%7C1%7CS
[snipped domain]/
0
2310258304
29439526
1820898304
29439526
*

So both cookies are there but not sure why cgi.pm cookies function
cannot find the 'CoStore' one.  I don't think its expired because it
was set for +7D which I think is corect for 7 days in the future.

Any suggestions?

Thanks,

Jennifer


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

Date: Wed, 05 Sep 2001 10:15:28 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: cgi.pm cookie function - am I missing something?
Message-Id: <3B965DB0.BDD4E2C7@stomp.stomp.tokyo>

Jennifer wrote:

(snipped)

> It appears that the cookie successfully sets.  In fact, I can go and
> see it in the cookies files used for IE and Netscape.


What is the name of the file for storing Netscape cookies?


Godzilla!


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

Date: Wed, 05 Sep 2001 10:31:56 -0400
From: Mark Pennington <Mark.Pennington@sdrc.com>
Subject: data for perl hash table
Message-Id: <3B96375B.B3F11103@sdrc.com>

I need to create a hash table in order to run 82 test cases for the CAD
software my company creates and maintains.
The data can be called by the person who runs the test case.  It would
be good if the data could be broken up so that it
could be called by individual testing.  It also needs to have the
capability of being broken into several different
categories.  The table needs to have the ability to be updated and
maintained with any changes in the script_files and
data_files that will be tested for the software.  The table below shows
what I need to do for the problem.

Category 1 through 6 is a combination of 82 separate Programs.  Each
CATEGORY has its own script_file.  The model file is the same for each
individual test needed to be ran.

CATEGORY 1
Program 1            data_file 1    script_file 1
Program 2            data_file 1    script_file 2
Program 3            data_file 1    script_file 3
 ....                          .......                ........
 ....                          .......                ........
Program 13          data_file 1   script_file 13

CATEGORY 2
Program 14          data_file 2    script_file 1
Program 15          data_file 2    script_file 2
Program 16          data_file 2    script_file 3
 .....                        ......                   .....
 .....                        ......                   ......
Program 26          data_file 2    script_file 13

CATEGORY 3
Program 27          data_file 3    script_file 1
Program 28          data_file 3    script_file 2
Program 29          data_file 3    script_file 3
 .....                        ......                   .....
 .....                        ......                   ......
Program 39          data_file 3     script_file 13

CATEGORY 4
Program 40          data_file 4   script_file 1
Program 41          data_file 4   script_file 2
Program 42          data_file 4   script_file 3
 .....                         ......                   .....
 .....                         ......                   ......
Program 52          data_file 4    script_file 13

CATEGORY 5
 ......................
 ........................
 .........................

CATEGORY 6
Program 77          data_file 6  script_file 1
Program 78          data_file 6   script_file 2
Program 79          data_file 6   script_file 3
 .....                         ......                   .....
 .....                         ......                   ......
Program 82          data_file 6    script_file 13


Category 7 - 19 is a combination of basically the same script_file that
brings in a separate data_file with different data
into each Program.

CATEGORY 7
Program 1             data_file 1     script_file 1
Program 2             data_file 2     script_file 1
Program 3             data_file 3     script_file 1
Program 4             data_file 4     script_file 1
Program 5             data_file 5     script_file 1
Program 6             data_file 6     script_file 1

CATEGORY 8
Program 7              data_file 1     script_file 2
Program 8              data_file 2     script_file 2
Program 9              data_file 3     script_file 2
Program 10             data_file 4     script_file 2
Program 11             data_file 5     script_file 2
Program 12            data_file 6     script_file 2

CATEGORY 9
Program 13              data_file 1     script_file 3
Program 14              data_file 2     script_file 3
Program 15              data_file 3     script_file 3
Program 16              data_file 4     script_file 3
Program 17              data_file 5     script_file 3
Program 18              data_file 6     script_file 3

CATEGORY 10
Program 19              data_file 1     script_file 4
Program 20              data_file 2     script_file 4
Program 21              data_file 3     script_file 4
Program 22              data_file 4     script_file 4
Program 23              data_file 5     script_file 4
Program 24              data_file 6     script_file 4

CATEGORY 11
 ............................
 .............................
 ...............................

CATEGORY 19
Program 77             data_file 1     script_file 13
Program 78             data_file 2     script_file 13
Program 79             data_file 3     script_file 13
Program 80             data_file 4     script_file 13
Program 81             data_file 5     script_file 13
Program 82             data_file 6     script_file 13


The following line displays how I run the individual Programs:
'copy data_file #';
'copy script_file #';

Then start the software with the following line:
'Program 77 -d data_file1 -s script_file13';


Does anyone have any ideas on how to put all this data into a hash
table??  Or if there is a better solution in PERL
programming language that I can use to solve the problem faster and more
effectively??

Thanks;
Mark



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

Date: Wed, 05 Sep 2001 17:20:28 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: data for perl hash table
Message-Id: <3b965edb.53ef$227@news.op.net>

In article <3B96375B.B3F11103@sdrc.com>,
Mark Pennington  <Mark.Pennington@sdrc.com> wrote:
>I need to create a hash table in order to run 82 test cases for the CAD
>software my company creates and maintains.
>The data can be called by the person who runs the test case.  It would
>be good if the data could be broken up so that it
>could be called by individual testing.  It also needs to have the
>capability of being broken into several different
>categories.  The table needs to have the ability to be updated and
>maintained with any changes in the script_files and
>data_files that will be tested for the software.  The table below shows
>what I need to do for the problem.
>
>Category 1 through 6 is a combination of 82 separate Programs.  Each
>CATEGORY has its own script_file.  The model file is the same for each
>individual test needed to be ran.
>
>CATEGORY 1
>Program 1            data_file 1    script_file 1
>Program 2            data_file 1    script_file 2
>Program 3            data_file 1    script_file 3
>....                          .......                ........
>....                          .......                ........
>Program 13          data_file 1   script_file 13
>
>CATEGORY 2
>Program 14          data_file 2    script_file 1
>Program 15          data_file 2    script_file 2
>Program 16          data_file 2    script_file 3
>.....                        ......                   .....
>.....                        ......                   ......
>Program 26          data_file 2    script_file 13
>
>CATEGORY 3
>Program 27          data_file 3    script_file 1
>Program 28          data_file 3    script_file 2
>Program 29          data_file 3    script_file 3
>.....                        ......                   .....
>.....                        ......                   ......
>Program 39          data_file 3     script_file 13
>
>CATEGORY 4
>Program 40          data_file 4   script_file 1
>Program 41          data_file 4   script_file 2
>Program 42          data_file 4   script_file 3
>.....                         ......                   .....
>.....                         ......                   ......
>Program 52          data_file 4    script_file 13
>
>CATEGORY 5
>......................
>........................
>.........................
>
>CATEGORY 6
>Program 77          data_file 6  script_file 1
>Program 78          data_file 6   script_file 2
>Program 79          data_file 6   script_file 3
>.....                         ......                   .....
>.....                         ......                   ......
>Program 82          data_file 6    script_file 13
>
>
>Category 7 - 19 is a combination of basically the same script_file that
>brings in a separate data_file with different data
>into each Program.
>
>CATEGORY 7
>Program 1             data_file 1     script_file 1
>Program 2             data_file 2     script_file 1
>Program 3             data_file 3     script_file 1
>Program 4             data_file 4     script_file 1
>Program 5             data_file 5     script_file 1
>Program 6             data_file 6     script_file 1
>
>CATEGORY 8
>Program 7              data_file 1     script_file 2
>Program 8              data_file 2     script_file 2
>Program 9              data_file 3     script_file 2
>Program 10             data_file 4     script_file 2
>Program 11             data_file 5     script_file 2
>Program 12            data_file 6     script_file 2
>
>CATEGORY 9
>Program 13              data_file 1     script_file 3
>Program 14              data_file 2     script_file 3
>Program 15              data_file 3     script_file 3
>Program 16              data_file 4     script_file 3
>Program 17              data_file 5     script_file 3
>Program 18              data_file 6     script_file 3
>
>CATEGORY 10
>Program 19              data_file 1     script_file 4
>Program 20              data_file 2     script_file 4
>Program 21              data_file 3     script_file 4
>Program 22              data_file 4     script_file 4
>Program 23              data_file 5     script_file 4
>Program 24              data_file 6     script_file 4
>
>CATEGORY 11
>............................
>.............................
>...............................
>
>CATEGORY 19
>Program 77             data_file 1     script_file 13
>Program 78             data_file 2     script_file 13
>Program 79             data_file 3     script_file 13
>Program 80             data_file 4     script_file 13
>Program 81             data_file 5     script_file 13
>Program 82             data_file 6     script_file 13
>
>
>The following line displays how I run the individual Programs:
>'copy data_file #';
>'copy script_file #';
>
>Then start the software with the following line:
>'Program 77 -d data_file1 -s script_file13';
>
>
>Does anyone have any ideas on how to put all this data into a hash
>table??  Or if there is a better solution in PERL
>programming language that I can use to solve the problem faster and more
>effectively??
>
>Thanks;
>Mark
>


Perhaps something like this:

        # read in the data file
        while (<DATA>) {
          next unless /\S/;             # skip blank lines

          chomp;        
          if (/CATEGORY (\d+)/) {
            $CATEGORY = $1;
          } else {
            my ($program, $data, $script) = split;
            push @{$CATEGORY_PROGRAMS{$CATEGORY}}, $program;
            $how_to_run{$program} = 
                { data => $data,
                  script => $script,
                };
          }
        }

Now, to run the program named 'program77':

        sub run_program {
          my $program_name = shift;
          my $data_file = $how_to_run{$program_name}{data};
          my $script    = $how_to_run{$program_name}{script};
          my $result  = system("$program_name -d $data_file -s $script");
          unless ($result == 0) {
            warn "Warning: program $program_name did not run successfully";
          }
        }

To run all the programs in a certain category:

        sub run_entire_category {
          my $category = shift;
          foreach my $program (@{$CATEGORY_PROGRAMS{$category}}) {
            run_program($program);
          }
        }

I hope this helps.

-- 
@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: Wed, 5 Sep 2001 15:10:27 GMT
From: "David F Dafoe" <david.f.dafoe@boeing.com>
Subject: Disappearing Compiler messages
Message-Id: <GJ73HG.3Kt@news.boeing.com>

A few things changed recently in my .PL files hosted on an NT server at a
large corporation.

You're supposed to put this line:

print "Content-type:text/html\n\n";

at the beginning of each file.  This used to work and still works on other
servers.  Recently, this line started to cause my scripts to stop running,
so I had to comment them out.

Also, I no longer get compiler error messages.  If there is any syntax error
I get a message saying "script produced no output."  I have to laboriously
remove all new code, and put it back in line by line until I find the
offending code.

The server admin. says that none of the PERL software or settings have
changed.

Note that I don't have the luxury of sitting directly on NT and running the
scripts from the command line.  I have to pump them over to a server from my
lowly PC and hope for the best.

Any insights would be welcome





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

Date: Wed, 5 Sep 2001 16:14:14 +0200
From: "Martin Mielke" <martin@people-com.com>
Subject: DumbQuestion::CGI_parser
Message-Id: <9n5bp5$h6e$1@titan.bt.es>

Dear all,

one of my first approaches to Perl aims to be a CGI which should parse an
HTML page, compose a filename from the parsed value and download the file.

The HTML side loks like this:

---] START

[...]
<FORM ACTION=http://172.a.b.c/Scripts/checkTice.pl NAME="Form"
METHOD="POST">
[...]

---] END


And the Perl side like this:

---] START

#!/usr/bin/perl

use CGI qw(:cgi);

$ticeURL="http://www.remote-machine.com/whatever.asp\?idA=28\&idB=";
$ticeFileInput=$ARGV[0] ;
$ticeFileToCheck=join ("",$ticeURL,$ticeFileInput);
$ticeUsage="\nUsage: checkTice.pl <file code>\n";

if (@ARGV < 1 ) {
   print $ticeUsage ;
   exit ;
}

print "\n INFO - Getting => $ticeFileToCheck\n";
system
("wget -cq --execute=http_proxy=proxy:8080 --output-document=TICE_checkpoint
_$ticeFileInput.xml $ticeFileToCheck");
print "\n INFO - The downloaded file can be found as:
TICE_checkpoint_$ticeFileInput.xml\n\n";

---] END

The script used alone works pretty fine but problems arise when I use it as
CGI...

What obvious part am I overseeing?

Please, email and/or CC me your replies as I cannot check the newsgroups
very often.


Thanks in advance,

Martin





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

Date: 5 Sep 2001 09:47:07 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: DumbQuestion::CGI_parser
Message-Id: <3b96570b@news.victoria.tc.ca>

Martin Mielke (martin@people-com.com) wrote:
: Dear all,

If you're going to do some CGI programming then I suggest you read the CGI
docs

	perldoc CGI

in particular look for the function 'param()' and read up on that.



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

Date: 5 Sep 2001 14:11:59 GMT
From: steveo@panix.com (Steven M. O'Neill)
Subject: fore!
Message-Id: <9n5brf$hnh$1@news.panix.com>
Keywords: one-liners

I would like assistance in learning to translate the following to a
one-liner.  Any code and/or references will be appreciated.

Steve

-~-~-
[dis.pl:]

open IN, "dis" or die "nope";
while (<IN>) {
    chomp;
    $grepwithme = substr($_, 3);
    @output = `grep ^${grepwithme}\$ /usr/share/dict/words`;
    print "$grepwithme " unless (@output);
}


[head dis:]
disability
disable
disabled
disablement
disabusal
disabuse
disacceptance
disaccharide
disaccharose
disaccommodate

[output:]
abled ablement abusal accharide accharose
-- 
Steven O'Neill                                          steveo@panix.com


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

Date: 5 Sep 2001 15:05:00 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: fore!
Message-Id: <slrn9pcfp3.9jc.rgarciasuarez@rafael.kazibao.net>

Steven M. O'Neill wrote in comp.lang.perl.misc:
} I would like assistance in learning to translate the following to a
} one-liner.  Any code and/or references will be appreciated.
} 
} Steve
} 
} -~-~-
} [dis.pl:]
} 
} open IN, "dis" or die "nope";
} while (<IN>) {
}     chomp;
}     $grepwithme = substr($_, 3);
}     @output = `grep ^${grepwithme}\$ /usr/share/dict/words`;
}     print "$grepwithme " unless (@output);
} }
} 
} 
} [head dis:]
} disability
} disable
} disabled
} disablement
} disabusal
} disabuse
} disacceptance
} disaccharide
} disaccharose
} disaccommodate
} 
} [output:]
} abled ablement abusal accharide accharose

That's the shortest I found :

perl -lne \
    'END{$,=" ";print keys%x}$f++if eof;$f?delete$x{$_}:++$x{substr$_,3}' \
    dis /usr/share/dict/words

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Wed, 05 Sep 2001 09:21:17 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Godzilla DOS Internal Script Timer
Message-Id: <3B9650FD.4BF5234E@stomp.stomp.tokyo>

Thomas Bätzler wrote:
 
> Godzilla! wrote:

(snipped)

> >My rather ingenious method is pretty darn accurate
> >and can be used to compare any number of Perl code
> >segments, anywhere in a Perl script.
 
> Anywhere where you may use backticks and obviously only where you have
> access to a time command. And also obviously only up to the precision
> of said command's internal clock.

I cannot think of many code circumstances where you could not
use system back ticks; this is quite adaptable. However, there
are no code circumstances where system () syntax can be used
with my echo.|time methodology; it must be backticks.

Average systems will display a plus or minus one millisecond
accuracy. This is quite acceptable for a millisecond timer.

All systems should display this accuracy, or extremely close.
This DOS clock, actually a device which accesses a Real Time
Clock chip, is very standardized. I believe Motorola provides
the chip set for this feature in all systems, including MAC
from what little I have read about MAC computers. The actual
DOS device for accessing a Real Time Clock, is unchanged since
early DOS versions, at least back to DOS 3.x to my knowledge.

I do not know the historical time line for use of Motorola
Real Time Clock chipsets. I think their chipset dates way
back, at least in computer years.

Currently I am working on a project to access a RTC, real time
clock, via a Perl script. However, this requires writing a
binary executable file, such as a .com or .exe file. I am not
sure individual accuracy would be improved. Average accuracy
for multiple runs, would improve slightly. Actually, accuracy
would not truly improve, but rather, stability would improve
somewhat, but still be influenzed by Windows background noise.

Next project will be a timer based on system ticks which might
allow microsecond timing. There is a significant obstacle with
this method; CPU speed is a major variable factor. A program
to access system ticks, would be very complex and consume a
high degree of time itself. Microsecond timing inherently 
would be useless for average common day usage.

My opinion is my simple DOS timer is well adapted for almost
all usage with a one millisecond resolution. Programmers will
be looking for time differences well exceeding one millisecond
to determine which code syntax is more efficient, enough so to
discount one method in favor of another. My DOS millisecond
timer makes an excellent replacement for the benchmark module
and, reports timed events benchmark cannot.

 
> >echo.|time
 
> Any particular reason why you don't use "time <nul"?

There is a very good reason. I suggest you test this syntax
at a DOS prompt and within a Perl script. For a Perl script,
test both backtick usage and system () usage.

 
> If you're timing code town to milliseconds, you should at least factor
> in the time needed to fire up your second time command.

This will vary from system-to-system. This system variation disallows
accurate compensation for time consumed by DOS system initiation. This
could be calculated for an individual system, if needed. Nonetheless,
relative event times are both quite accurate and quite stable.

For a 600 MHz Pentium 3, this DOS consumed time is an average 5 milliseconds.
If I could poll a wide variety of system types under carefully controlled 
conditions, I suspect, with one millisecond resolution, this system
dependent variation might turn out to be in a range of four to six
milliseconds for all systems above a 66 MHz 486 system. For larger
complex Perl code tests, this DOS initiation consumed time, becomes
literally irrelevant.


Godzilla!


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

Date: Wed, 05 Sep 2001 10:05:47 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Godzilla DOS Internal Script Timer
Message-Id: <3B965B6B.D3F09F25@stomp.stomp.tokyo>

Godzilla! wrote:
 
> Thomas Bätzler wrote:
> > Godzilla! wrote:
 
 (snipped)


> For a 600 MHz Pentium 3, this DOS consumed time is an average 5 milliseconds.

This statement needs to be better qualified. Inherently this average
DOS 5 milliseconds, will also include some time consumed by perl core
processing this system request. This time consumed by perl core would
be exceptionally difficult to calculate, if at all possible.

Certainly, various versions of perl core, will influenze this time.
Different Windows versions will also influenze this time along with
Windows background noise externalities. Hardware, is another variable
externality. Should you want to thrust this into obsessive geek anal
retentive nitpicking, even current voltage level would be a factor
effecting various internal clock speeds. Did I mention temperature?

Calculating a correction factor, is clearly very complex and, most
likely, would introduce more variation than corrected or, at least
would not correct any variation but rather reduce reported time by
a standardized amount, regardless of accuracy.

My statement of an "average 5 milliseconds" should be considered
to be an all inclusive generic statement.

With a tested average plus or minus one millisecond accuracy,
I say leave well enough alone.


Godzilla!


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

Date: 5 Sep 2001 08:38:14 -0700
From: stimpy_j_cat@hotmail.com (Ross)
Subject: Re: Header error with Activeperl on Win2K Sp2
Message-Id: <e2d756e7.0109050738.2dffb454@posting.google.com>

Nevermind I fixed it.

Changed .pl mapping from Perl.exe to PerlIS.dll


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

Date: 5 Sep 2001 08:59:28 -0700
From: hkmp5@spray.se (Alex SC)
Subject: Re: Header error with Activeperl on Win2K Sp2
Message-Id: <18d79944.0109050759.39323c33@posting.google.com>

stimpy_j_cat@hotmail.com (Ross) wrote in message news:<e2d756e7.0109050245.1a5b8b46@posting.google.com>...

> I installed Active Perl on my workstation solely for this demo so this
> is the first and only time I have found out about this problem. Can
> anyone suggest why I should be getting this error?

Try having

$|++;
print "Content-type: text/html\n\n";

as the FIRST thing in your cgi script - before any other 
output. 

Also, this is not a perl thing as much as a web server thing;
you'd be well advised to look over your web server documentation.


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

Date: 5 Sep 2001 07:02:36 -0700
From: billy@arnis-bsl.com (Ilja Tabachniks)
Subject: Re: How can I find the PID's of my children?
Message-Id: <5d4a715a.0109050602.3531bdf@posting.google.com>

"John W. Krahn" <krahnj@acm.org> wrote in message news:<3B95F5D0.47AF2099@acm.org>...

 ...skipped...

> my $command = 'ps -eo ppid,pid,command';
> my @children = grep {
>             chomp( my @x = split " ", $_, 3 );
>             $x[0] == $$ and $x[2] ne $command and $_ = $x[1]
>             } `$command`;
> 
> 

OK, I understand your intentions. Just some warnings:

1. The 'command' format for ps(1) is not so portable (say AFAIK on Solaris
   you'd use 'args' instead).
 
2. The implementation of ps(1) may truncate the resulting 'command' string, 
   and therefore $x[2] ne $command will be true when unexpected.

IMHO the more robust solution would include a manual fork()/exec().
This way we will know the exact pid of ps(1) process and will be able to
filter it out from listing.
 
Ilja.


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

Date: Wed, 5 Sep 2001 19:40:18 +0200
From: "Jonas Nilsson" <jonni@ifm.liu.nospam.se>
Subject: How can I wait in perl?
Message-Id: <9n5o0v$k40$1@newsy.ifm.liu.se>

I wan't to execute a subroutine every 5 seconds or so. How can I make perl
wait some time without using something processor killer-stupid like:
sub my_wait {
    my $secs=shift;
    my $tmptime=localtime;
    while ($secs) {
        my $newtime=localtime;
        $secs-- if ($tmptime ne $newtime);
        $tmptime=$newtime;
    }
}

--
/jN




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

Date: Wed, 05 Sep 2001 19:01:19 +0100
From: Jasper McCrea <jasper@guideguide.com>
Subject: Re: How can I wait in perl?
Message-Id: <3B96686F.35F79910@guideguide.com>

Jonas Nilsson wrote:
> 
> I wan't to execute a subroutine every 5 seconds or so. How can I make perl
> wait some time without using something processor killer-stupid like:
> sub my_wait {
>     my $secs=shift;
>     my $tmptime=localtime;
>     while ($secs) {
>         my $newtime=localtime;
>         $secs-- if ($tmptime ne $newtime);
>         $tmptime=$newtime;
>     }
> }


sleep?

jasper
-- 
      split//,'019617511192'.
      '17011111610114101114'.
      '21011141011840799901'.
            '17101174';
            foreach(0..         # my
            $#_){$_[$_          # signature is too
            ++]^=$_[$_          # bignature
            --]^=$_[$_
]^=$_[++    $_]if!($_%
2)}$g.=$_  ,chr($g)=~
 /(\w)/&&($o.=$1and
   $g='')foreach@_;
      print"$o\n"


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

Date: Wed, 05 Sep 2001 14:08:11 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: HTML syntax (second pair of eyes)
Message-Id: <58ccpt440vl2t6ha3rrg8jnh41kaaqvav6@4ax.com>

JD Lampard wrote:

><BEGIN PASTE>
>my %row;
>$sth->bind_columns( \( @row{ @{$sth->{NAME_lc} } } ));
>while ($sth->fetch) {
>    print "<tr><td><a
>href=$row(url)>$row{site}</a></td><td><ahref=$row(url)>$row{url}</a></td></t
>r>\n";
>}
><END PASTE>

That "$row(url)" looks extremely fishy... surely you mean "$row{url}"?

You should put your (href) attributes between quotes. One never knows
what characters are in an URL, usually it's not just [a-zA-Z0-9.\-] as
HTML would require from unquoted attributes...

And do html-escape your data. '&' should be '&amp;' and '<' should be
'&lt;'. The rest isn't that important (except that for quoted
attributes, the quote character should be escaped as well).

-- 
	Bart.


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

Date: Wed, 05 Sep 2001 13:04:24 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: ignoring lines in file using array of phrases to skip
Message-Id: <3B96234E.C98211E6@acm.org>

Mike Solomon wrote:
> 
> If I use the format
> 
>        while ($line = <FILE)
> 
> and I am using strict I will have to declare $line first, in other words
> 
>        my ($line);
>        while ($line = <FILE)
> 
> Why is this better than using
> 
>        while (<FILE>) {
>          my $line = $_;

If you want to limit the scope of $line to the while loop then:

       while ( my $line = <FILE> ) {



John
-- 
use Perl;
program
fulfillment


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

Date: 5 Sep 2001 06:38:50 -0700
From: schaefer@pdtec.de (Marc Schaefer)
Subject: Re: Match starting from the nth occurrence of a character to the nth+1 occurrence
Message-Id: <388a211a.0109050538.124b8e12@posting.google.com>

Thank you all for your quick help.

I love you all and my problem is done.


Marc


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

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


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