[18703] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 871 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 10 18:06:36 2001

Date: Thu, 10 May 2001 15:05:23 -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: <989532322-v10-i871@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 10 May 2001     Volume: 10 Number: 871

Today's topics:
    Re: 1 billion seconds bug <mischief@velma.motion.net>
    Re: 1 billion seconds bug (Craig Berry)
    Re: 1 billion seconds bug <flavell@mail.cern.ch>
    Re: 1 billion seconds bug (Gwyn Judd)
    Re: 1 billion seconds bug <bart.lateur@skynet.be>
        About ASP PerlScript generating dynamic pictures with G <ellaella@hongkong.com>
    Re: Announcement -- TESTING COMPUTER SOFTWARE (TCS2001) (Eric Bohlman)
    Re: Announcement -- TESTING COMPUTER SOFTWARE (TCS2001) (Garry Williams)
    Re: Announcement -- TESTING COMPUTER SOFTWARE (TCS2001) <mischief@velma.motion.net>
    Re: Announcement -- TESTING COMPUTER SOFTWARE (TCS2001) <uri@sysarch.com>
    Re: Base 6 sieve. (Anno Siegel)
    Re: Base 6 sieve. (Abigail)
    Re: Can't get sleep to work. (Mark Jason Dominus)
        CGI and printing vars <todd@designsouth.net>
    Re: CGI and printing vars <todd@designsouth.net>
    Re: CGI and printing vars <joe+usenet@sunstarsys.com>
    Re: CGI and printing vars <godzilla@stomp.stomp.tokyo>
    Re: Converting a tab-delimited file? <ren@tivoli.com>
        DES-CBC without Crypt::CBC <simon@super-simon.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 10 May 2001 18:57:01 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: 1 billion seconds bug
Message-Id: <tflp3tkdo6uue3@corp.supernews.com>

Alan J. Flavell <flavell@mail.cern.ch> wrote:
> On Thu, 10 May 2001, Chris Stith wrote:

>> You forget how arroga^Wshort-sigh^Wum, provincial some people are
>> in the way they think. I know of at least two Linux versions which
>> ask upon installation if you wish to set your clock to 'GMT' and
>> use a proper timezone.

> I'm not sure what you're using that to illustrate (aside from the fact
> that a more politically correct designation would be UTC, and nowadays
> Greenwich isn't really involved ;-)

What I'm trying to illustrate deals directly with what I quoted:

    AFAIK time() will return the same value at the same time
    everywhere in the world, if your clock is correctly set.
    It's localtime() which applies a timezone offset to the
    return value to give you hours, minutes, and seconds. But
    if time() return 123456 in Auckland, it'll be 123456 in
    London, New York, and Beijing as well.

My point is that just because you consider something to be
correct does not mean you should assume it to be implemented
by everyone everywhere. The 'if your clock is correctly set'
assumes too much. Mainly, it assumes that people are concerned
with the difference. I've seen many machines installed with
no thought of time zone at all, because the careless admin
knew there is a way to set the time later. I'm sure this is
the exception and not the rule, but exceptional cases are
always the ones to guard against since the normal ones are
expected to work from the gate.

Chris

-- 
The purpose of a language is not to help you learn the
language, but to help you learn other things by using the
language. --Larry Wall, The Culture of Perl, August 1997



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

Date: Thu, 10 May 2001 19:41:42 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: 1 billion seconds bug
Message-Id: <tflrnmqsfmh2c@corp.supernews.com>

Gwyn Judd (tjla@guvfybir.qlaqaf.bet) wrote:
: I just want to point out that as the resident .nz 'er that (assuming
: there's noone from Fiji or the Cook Islands here) my Perl scripts will
: break before all of y'all since I'm closest (numerically and lexically)
: to the IDL.

Actually, since epoch seconds count from an absolute time point (1970 Jan
1 00:00:00 GMT) and are thus not timezone-dependent, we'll all hit it
simultaneously.  Gives one a nice warm feeling of worldwide togetherness,
it does. 

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "God becomes as we are that we may be as he is."
   |               - William Blake


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

Date: Thu, 10 May 2001 22:11:20 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: 1 billion seconds bug
Message-Id: <Pine.LNX.4.30.0105102210520.27671-100000@lxplus003.cern.ch>

On Thu, 10 May 2001, Chris Stith wrote:

> My point is that just because you consider something to be
> correct does not mean you should assume it to be implemented
> by everyone everywhere. The 'if your clock is correctly set'
> assumes too much.

Understood - thanks




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

Date: Thu, 10 May 2001 20:35:32 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: 1 billion seconds bug
Message-Id: <slrn9flusi.hvs.tjla@thislove.dyndns.org>

"Mein Lufkissenfahrzeug ist voller Aale"
said Craig Berry (cberry@cinenet.net) in 
<tflrnmqsfmh2c@corp.supernews.com>:
>Gwyn Judd (tjla@guvfybir.qlaqaf.bet) wrote:
>: I just want to point out that as the resident .nz 'er that (assuming
>: there's noone from Fiji or the Cook Islands here) my Perl scripts will
>: break before all of y'all since I'm closest (numerically and lexically)
>: to the IDL.
>
>Actually, since epoch seconds count from an absolute time point (1970 Jan
>1 00:00:00 GMT) and are thus not timezone-dependent, we'll all hit it
>simultaneously.  Gives one a nice warm feeling of worldwide togetherness,
>it does. 

Awwww....but I wanted to be *first*

*pout*

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
"Let's leave heaven to the angels and the sparrows."
              [Heinrich Heine]
  Atheism/Freethought fortune cookie file


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

Date: Thu, 10 May 2001 21:42:20 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: 1 billion seconds bug
Message-Id: <l62mft49r35cseuhhuang7pilbffqbi0hf@4ax.com>

Craig Berry wrote:

>Actually, since epoch seconds count from an absolute time point (1970 Jan
>1 00:00:00 GMT) and are thus not timezone-dependent, we'll all hit it
>simultaneously.  Gives one a nice warm feeling of worldwide togetherness,
>it does. 

Except for people using a Mac.

Two differences:

 - The Mac epoch is the beginning of 1904. 1 billion is long past. The 3
billion mark was reached on January 24, 1999.

 - Seconds since epoch are in local time. Local time?!?! Yes, local
time.

-- 
	Bart.


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

Date: Fri, 11 May 2001 03:42:54 +0800
From: "Ella" <ellaella@hongkong.com>
Subject: About ASP PerlScript generating dynamic pictures with GD
Message-Id: <9deqak$7r31@imsp212.netvigator.com>


Hi all,

Sorry I don't know whether it is a right place for me asking ASP PerlScript.
I could plot some graph by GD by ASP codes with Microsoft IIS server.
I just want to know how to generate a picture like CGI output, just dump the
data out to the web browser, but not generate a png file first, and then
redirect to it, if anybody know, please tell me, thanks very much!


Lucas



<html>
I am better
<% @LANGUAGE = PerlScript %>
<%
use GD;

 # create a new image
      #print "Content-type: image/gif\n\n";

 $im = new GD::Image(100,100);

 # allocate some colors
 $white = $im->colorAllocate(255,255,255);
 $black = $im->colorAllocate(0,0,0);
 $red = $im->colorAllocate(255,0,0);
 $blue = $im->colorAllocate(0,0,255);

 # make the background transparent and interlaced
 $im->transparent($white);
 $im->interlaced('true');

 # Put a black frame around the picture
 $im->rectangle(0,0,99,99,$black);

 # Draw a blue oval
 $im->arc(50,50,95,75,0,360,$blue);

 # And fill it with red
 $im->fill(50,50,$red);

 # Convert the image to GIF and print it on standard output
 open(IMG, '>test.png') || die;
   binmode IMG;
   print IMG $im->png;
 #print STDOUT $im->png;

%>

</html>




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

Date: 10 May 2001 19:05:27 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Announcement -- TESTING COMPUTER SOFTWARE (TCS2001) Conference -- Keynote Speakers
Message-Id: <9deopn$3dq$3@bob.news.rcn.net>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> [Newsgroups reduced to clpm]

> According to Peter Zuckerman <pazpax@clark.net>:
>> 
>>              18th International Conference and Exposition on 
>> 
>>                         TESTING COMPUTER SOFTWARE
>>               Theme: Meeting the New Challenges of Testing
>                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

> [major snip]

> Where do people learn to think of a conference theme like that?  The
> maxim seems to be, pack buzzwords in the phrase until all traces
> of meaning are crowded out.  Must be the same school that teaches
> newbies to choose a topic.

One way is to use what Laurence Peter of Peter Principle fame called a 
"jargon phrase indicator" which is simply a multi-column list of words, 
arranged by parts of speech.  You randomly pick one word from each column 
and then add the appropriate function words ("the," "of," etc.).  Peter 
suggested its use in the context of someone doing actual work and trying 
to spend as little time as possible satisfying management demands.



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

Date: Thu, 10 May 2001 20:51:58 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Announcement -- TESTING COMPUTER SOFTWARE (TCS2001) Conference -- Keynote Speakers
Message-Id: <slrn9flvre.ig.garry@zfw.zvolve.net>

On 10 May 2001 19:05:27 GMT, Eric Bohlman <ebohlman@omsdev.com> wrote:
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>> [Newsgroups reduced to clpm]
> 
>> According to Peter Zuckerman <pazpax@clark.net>:
>>> 
>>>              18th International Conference and Exposition on 
>>> 
>>>                         TESTING COMPUTER SOFTWARE
>>>               Theme: Meeting the New Challenges of Testing
>>                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
>> [major snip]
> 
>> Where do people learn to think of a conference theme like that?  The
>> maxim seems to be, pack buzzwords in the phrase until all traces
>> of meaning are crowded out.  Must be the same school that teaches
>> newbies to choose a topic.
> 
> One way is to use what Laurence Peter of Peter Principle fame called a 
> "jargon phrase indicator" which is simply a multi-column list of words, 
> arranged by parts of speech.  You randomly pick one word from each column 
> and then add the appropriate function words ("the," "of," etc.).  Peter 
> suggested its use in the context of someone doing actual work and trying 
> to spend as little time as possible satisfying management demands.

Let's automate that: 

#!/usr/bin/perl -wl
use strict;

my @verbs = qw(
        aggregate architect benchmark brand cultivate deliver deploy
        disintermediate drive e-enable embrace empower enable engage
        engineer enhance envisioneer evolve expedite exploit extend
        facilitate generate grow harness implement incentivize
        incubate innovate integrate iterate leverage maximize mesh
        monetize morph optimize orchestrate recontextualize
        reintermediate reinvent repurpose revolutionize scale seize
        strategize streamline syndicate synergize synthesize target
        transform transition unleash utilize visualize whiteboard
        );

my @adjectives = qw(
        24/365 24/7 B2B B2C back-end best-of-breed bleeding-edge
        bricks-and-clicks clicks-and-mortar collaborative compelling
        cross-platform cross-media customized cutting-edge distributed
        dot-com dynamic e-business efficient end-to-end enterprise
        extensible frictionless front-end global granular holistic
        impactful innovative integrated interactive intuitive killer
        leading-edge magnetic mission-critical next-generation
        one-to-one open-source out-of-the-box plug-and-play proactive
        real-time revolutionary robust scalable seamless sexy sticky
        strategic synergistic transparent turn-key ubiquitous
        user-centric value-added vertical viral virtual visionary
        web-enabled wireless world-class 
        );

my @nouns = qw(
        action-items applications architectures bandwidth channels
        communities content convergence deliverables e-business
        e-commerce e-markets e-services e-tailers experiences eyeballs
        functionalities infomediaries infrastructures initiatives
        interfaces markets methodologies metrics mindshare models
        networks niches paradigms partnerships platforms portals
        relationships ROI synergies web-readiness schemas solutions
        supply-chains systems technologies users vortals
        );

srand;
$, =  " ";
print $verbs[ rand @verbs ], $adjectives[ rand @adjectives ],
    $nouns[ rand @nouns ];
exit 0;

-- 
Garry Williams


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

Date: Thu, 10 May 2001 21:23:35 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Announcement -- TESTING COMPUTER SOFTWARE (TCS2001) Conference -- Keynote Speakers
Message-Id: <tfm1mnjfdonff4@corp.supernews.com>

Garry Williams <garry@ifr.zvolve.net> wrote:
> On 10 May 2001 19:05:27 GMT, Eric Bohlman <ebohlman@omsdev.com> wrote:
>> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>>> [Newsgroups reduced to clpm]
>> 
>>> According to Peter Zuckerman <pazpax@clark.net>:

[snip]

>>>               Theme: Meeting the New Challenges of Testing
>>>                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> 
>>> [major snip]
>> 

[snip]

>>> maxim seems to be, pack buzzwords in the phrase until all traces
>>> of meaning are crowded out.  Must be the same school that teaches
>>> newbies to choose a topic.
>> 
>> One way is to use what Laurence Peter of Peter Principle fame called a 
>> "jargon phrase indicator" which is simply a multi-column list of words, 
>> arranged by parts of speech.  You randomly pick one word from each column 
>> and then add the appropriate function words ("the," "of," etc.).  Peter 
>> suggested its use in the context of someone doing actual work and trying 
>> to spend as little time as possible satisfying management demands.

> Let's automate that: 

Your approach is stunningly simple, yet some of the phrases sound
extremely real. A few actually sound good, like 'generate 24/365
networks' and 'optimize wireless e-services' (although I hate that
'e-everything' buzz). I particularly liked 'deploy sexy communities'
and was all ready to buy stock in a company that could do that. ;-)

However, 'brand customized users' sounds pretty scary in many
directions, depending upon the possible connotations of 'brand'
and 'customized' and how far those can go.

This foes to show that programming is a tool which can be used
for good or evil.

Chris

-- 
For the pleasure of others, please adhere to the following
rules when visiting your park:
    No swimming.  No fishing.  No flying kites.  No frisbees.
    No audio equipment. Stay off grass.  No pets. No running.



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

Date: Thu, 10 May 2001 21:49:49 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Announcement -- TESTING COMPUTER SOFTWARE (TCS2001) Conference -- Keynote Speakers
Message-Id: <x7itj8c1r7.fsf@home.sysarch.com>

>>>>> "GW" == Garry Williams <garry@ifr.zvolve.net> writes:

  GW> srand;

unneeded by recent perls

  GW> $, =  " ";
  GW> print $verbs[ rand @verbs ], $adjectives[ rand @adjectives ],
  GW>     $nouns[ rand @nouns ];


i cribbed the list of words from a web site and wrote my own
shakespearean insult generator. this is part of a simple demo of and
inetd server in Stem.

and yes, i didn't use strict as the code is too simple to bother with
that. but i may strictify it someday.

uri


sub insult {

	$word1 = $insult_list1[rand @insult_list1] ;
	$word2 = $insult_list2[rand @insult_list2] ;
	$word3 = $insult_list3[rand @insult_list3] ;
	$word4 = $insult_list4[rand @insult_list4] ;

	return "$word1 thou $word2 $word3 $word4!" ;
}

BEGIN {
 
@insult_list1 = ( 

	q(Away I say),
	q(Bathe thyself),
	q(Be not deaf),
	q(Behold thy mirror),
	q(Beware my sting),
	q(Clean thine ears),
	q(Drink up eisel),
	q(Eat a crododile),
	q(Eat my knickers),
	q(Fie upon thee),
	q(Forsooth say I),
	q(Get thee gone),
	q(Get thee hence),
	q(Grow unsightly warts),
	q(Hear me now),
	q(Hear this pox alert),
	q(I'll see thee hang'd),
	q(Kiss my codpiece),
	q(Lead apes in hell),
	q(Methinks you stinks),
	q(My finger in thine eye),
	q("Phui" I say),
	q(Quit not thy day gig),
	q(Remove thy ass hence),
	q(Sit thee on a spit),
	q(Sorrow on thee),
	q(Swim with leeches),
	q(Thou dost intrude),
	q(Thy mother wears armor),
	q(Trip on thy sword),
	q(Tune thy lute),
	q(Why, how now putz),
	q(Wipe thy ugly face),
) ;

@insult_list2 = qw( 
 
	artless
	bawdy
	beslubbering
	bootless
	cankerous
	churlish
	cockered
	clouted
	craven
	currish
	dankish
	dissembling
	droning
	errant
	fawning
	fobbing
	fool-born
	froward
	frothy
	gleeking
	goatish
	gorbellied
	ill-nurtured
	incestuous
	incurable
	infectious
	jarring
	loggerheaded
	lumpish
	loutish
	mammering
	mangled
	mewling
	paunchy
	puking
	puny
	qualling
	rank
	reeky
	roguish
	rump-fed
	ruttish
	saucy
	spleeny
	spongy
	tardy-gaited
	tottering
	unmuzzled
	vain
	venomed
	warped
	wayward
	weedy
	whoreson
	wretched
	yeasty
) ;

@insult_list3 = qw( 

	addlepated
	base-court
	bat-fowling
	beef-witted
	beetle-headed
	boil-brained
	clapper-clawed
	clay-brained
	codpiece-sniffing
	common-kissing
	crook-pated
	dismal-dreaming
	dizzy-eyed
	doghearted
	dread-bolted
	earth-vexing
	elf-skinned
	fat-kidneyed
	fen-sucked
	flap-mouthed
	fly-bitten
	folly-fallen
	foul-practicing
	full-gorged
	guts-griping
	half-faced
	hasty-witted
	hedge-born
	hell-hated
	idle-headed
	ill-breeding
	knotty-pated
	mad-brained
	milk-livered
	motley-minded
	onion-eyed
	plume-plucked
	pottle-deep
	pox-marked
	reeling-ripe
	rough-hewn
	rude-growing
	shard-borne
	sheep-biting
	spur-galled
	swag-bellied
	tickle-brained
	toad-spotted
	unchin-snouted
	weather-bitten
) ;

@insult_list4 = qw( 
	apple-john
	baggage
	barnacle
	bladder
	boar-pig
	bugbear
	bum-bailey
	canker-blossom
	clack-dish
	clotpole
	coxcomb
	codpiece
	death-token
	dewberry
	dotard
	flap-dragon
	flax-wench
	flea
	flirt-gill
	foot-licker
	fustilarian
	giglet
	gudgeon
	haggard
	harpy
	hedge-pig
	horn-beast
	hugger-mugger
	jolthead
	knave
	lewdster
	lout
	maggot-pie
	malt-worm
	mammet
	measle
	minnow
	miscreant
	moldwarp
	mumble-news
	nit
	nut-hook
	pigeon-egg
	pignut
	pumpion
	puttock
	ratsbane
	rudesby
	scut
	skainsmate
	strumpet
	varlot
	vassal
	wagtail
	water-fly
	whey-face
	winter-cricket
) ;




  GW> -- 
  GW> Garry Williams


-- 
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: 10 May 2001 18:20:27 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Base 6 sieve.
Message-Id: <9dem5b$jsr$1@mamenchi.zrz.TU-Berlin.DE>

According to Abigail <abigail@foad.org>:
> Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMDCCCVII
> September MCMXCIII in <URL:news:9d9b9t$jbu$1@mamenchi.zrz.TU-Berlin.DE>:

> $$  Your scrub routine is highly optimized.  I had expected having to
> $$  do something complicated before the loop to get in sync.  The idea
> $$  of establishing a preliminary limit to get some complications out of
> $$  the middle rounds is new to me and noteworthy.  Also noteworthy is
> $$  the tasteful use of a bare block to align the final lines with the
> $$  corresponding ones inside the loop.
> 
> Well, there are only two things that need to be optimized: the memory
> usuage, and the scrub routine, as most work will be performed in this
> routine. The "extra" pieces before and after the core loop seem very
> natural - if you don't do that, you will have to put conditions in your
> loop, and it's easy to see those conditions only deal with boundary
> conditions. From there it's just one step to take the boundary conditions
> out of your loop ;-)

Put another way, when you lie down on a ladder, both your head and your
feet dangle.

Loop conditionals that catch only one case are pretty common, and
usually the right attitude is to shrug and go on; if anything
substantial happens elsewhere in the loop it doesn't matter.  It's
nice to learn that something can be done when it does matter.
 
> $$  You are one of the few programmers who don't only have a distinctive
> $$  personal style, but a whole range of such, one for each occasion.
> $$  This is clearly one not of the more jocular programs.  I is also, if
> $$  I'm not very wrong, written with the idea in mind that it could be
> $$  the prototype for a seriously fast prime generator written in C or
> $$  assembler.
> 
> There's little about a sieve you can do to make it language specific.
> All significant optimizations (one byte of usage per 24 possible numbers,
> and the core loop) are language independent - so it translates easily
> to C or assembler. As long as your language gives you access to bits.

Well, in your first sieve program in one place you wrote "$n << 1" for
"2*$n", clearly inspired by a parallel stream of low-level thinking.

> There is, however, a major inefficiency in the program that's screaming
> to be optimized away. Can you guess what it is?

If you are clearing bits more often than necessary I don't see it.  If
there were an easy way to predict which bits will be cleared, we wouldn't
need this nifty algorithm

There's only one place where I see potential room for improvement:
could the calculation of the actual index into the sieve be simplified
if the previous value was saved?  Some previous partial result?  Off
the top of my head I don't see how, but we do know that $n is a prime
larger than the factors of $BASE, maybe that helps... .

Well, I guess that amounts to a declaration of defeat.  I don't hear
the screaming.

Anno


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

Date: Thu, 10 May 2001 20:06:56 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Base 6 sieve.
Message-Id: <slrn9flt70.cp9.abigail@tsathoggua.rlyeh.net>

Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMDCCCIX
September MCMXCIII in <URL:news:9dem5b$jsr$1@mamenchi.zrz.TU-Berlin.DE>:
~~  According to Abigail <abigail@foad.org>:
~~ > Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMDCCCVII
~~ > September MCMXCIII in <URL:news:9d9b9t$jbu$1@mamenchi.zrz.TU-Berlin.DE>:
~~ > 
~~ > There's little about a sieve you can do to make it language specific.
~~ > All significant optimizations (one byte of usage per 24 possible numbers,
~~ > and the core loop) are language independent - so it translates easily
~~ > to C or assembler. As long as your language gives you access to bits.
~~  
~~  Well, in your first sieve program in one place you wrote "$n << 1" for
~~  "2*$n", clearly inspired by a parallel stream of low-level thinking.

I also said that I think it shouldn't matter whether you write $n << 1, 
2 * $n or $n + $n, a good compiler should generate identical, optimal,
code. In the absense of overloaded or tie()d stuff of course.

~~ > There is, however, a major inefficiency in the program that's screaming
~~ > to be optimized away. Can you guess what it is?
~~  
~~  If you are clearing bits more often than necessary I don't see it.  If
~~  there were an easy way to predict which bits will be cleared, we wouldn't
~~  need this nifty algorithm
~~  
~~  There's only one place where I see potential room for improvement:
~~  could the calculation of the actual index into the sieve be simplified
~~  if the previous value was saved?  Some previous partial result?  Off
~~  the top of my head I don't see how, but we do know that $n is a prime
~~  larger than the factors of $BASE, maybe that helps... .
~~  
~~  Well, I guess that amounts to a declaration of defeat.  I don't hear
~~  the screaming.


Well, currently the loop calculates the next number to be scrubbed,
and from that, the bitindex is calculated. Calculating the next number
is done reasonably efficient, but completely unnessary. In stead of
calculating the next number, all that's needed is calculating the
next bit index. We know by how much the next number is incremented
(2 * $n and 4 * $n (results that could have been cached)), but there's
a linear relationship between the skips in numbers and the skips in
bitindices. So, it should be much faster to keep track of the bit
indices, as that's the only thing we are interested in.


Abigail
-- 
perl -le 's[$,][join$,,(split$,,($!=85))[(q[0006143730380126152532042307].
          q[41342211132019313505])=~m[..]g]]e and y[yIbp][HJkP] and print'


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

Date: Thu, 10 May 2001 19:20:37 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Can't get sleep to work.
Message-Id: <3afaea05.4e2d$3b7@news.op.net>

In article <3AFAB500.202B54C2@wiedman.com>,
Jim Wiedman  <jim@wiedman.com> wrote:
>I'm sure this is going to be a really stupid question, but I can't
>figure it out.

It's subtle.

        http://perl.plover.com/FAQs/Buffering.html

discusses this *exact* problem in detail, under the heading "My log
file has nothing in it!"

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: Thu, 10 May 2001 20:00:33 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: CGI and printing vars
Message-Id: <BrCK6.3591$I5.1301635@news1.rdc1.tn.home.com>

when I use CGI, sometimes I need to print some of the variables back out on
the page. Or if I'm sending email to a few people based on input, like a
feedback form, I like to make the body of the email all at once and store it
in a variable for later. So, I wish I could do this:

------------
use CGI;
$cgi = new CGI;

$send = <<SEND;
Name: $cgi->param{Name}<br>
Email: $cgi->param{Email}<br>
SEND

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

But of course that prints

Name: CGI=HASH(0x80c6fdc)->param{Name}
Email: CGI=HASH(0x80c6fdc)->param{Email}

And I hate typing $a = "stuff", $cgi->param(Name), "eqfefge",
$cgi->param(Email}, "aefeafeag"- because that's ugly.

So I've been resorting to making a quick hash from $cgi ---

for ($cgi->param) {
    $c{$_} = $cgi->param($_);
}

But writing a whole 'for' loop just for convenience? There's got to be a
better way. How do you guys deal with printing out vars passed in to CGI?




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

Date: Thu, 10 May 2001 20:03:17 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: Re: CGI and printing vars
Message-Id: <9uCK6.3593$I5.1302656@news1.rdc1.tn.home.com>

> Name: $cgi->param{Name}<br>

oops, these lines should be ...param(\w+)...




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

Date: 10 May 2001 16:43:34 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: CGI and printing vars
Message-Id: <m3vgn9exzd.fsf@mumonkan.sunstarsys.com>

"Todd Smith" <todd@designsouth.net> writes:

> And I hate typing $a = "stuff", $cgi->param(Name), "eqfefge",
> $cgi->param(Email}, "aefeafeag"- because that's ugly.

  % man CGI

Look for 'Vars' and/or 'import_names'.

-- 
Joe Schaefer               "Buy land.  They've stopped making it."
                                               --Mark Twain



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

Date: Thu, 10 May 2001 14:27:09 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: CGI and printing vars
Message-Id: <3AFB07AD.525638C8@stomp.stomp.tokyo>

Todd Smith wrote:
 
> when I use CGI, sometimes I need to print some of the variables back out on
> the page. Or if I'm sending email to a few people based on input, like a
> feedback form, I like to make the body of the email all at once and store it
> in a variable for later. So, I wish I could do this:
 
> use CGI;
> $cgi = new CGI;
 
> $send = <<SEND;
> Name: $cgi->param{Name}<br>
> Email: $cgi->param{Email}<br>
> SEND
 
> print "Content-type: text/html\n\n";
> print $send;

> But of course that prints
 
> Name: CGI=HASH(0x80c6fdc)->param{Name}
> Email: CGI=HASH(0x80c6fdc)->param{Email}
 
(snipped)


$send = join ("", "Name: ", $cgi->param('Name'), "<BR>Email: ",
$cgi->param('Email'));


Carefully note my use of parentheses in my syntax, not "curly brackets."


Godzilla!
--
Name this test1.pl and try it.
If you need a cgi extension for
your server, change my form action
as needed.


#!perl

use CGI;
my ($cgi) = new CGI;

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

print "
 <form action=\"test1.pl\" method=\"post\">
 <input type=\"submit\" name=\"button\"><P>
 <input type=\"text\" name=\"Name\"><P>
 <input type=\"text\" name=\"Email\"><P>
 </form><P>";

$send = join ("", "Name: ", $cgi->param('Name'), "<BR>Email: ",
$cgi->param('Email'));

print "<P>$send";


exit;


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

Date: 10 May 2001 12:50:59 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Converting a tab-delimited file?
Message-Id: <m34rutnldo.fsf@dhcp9-172.support.tivoli.com>

On Thu, 10 May 2001, amnuts@talker.com wrote:

> In article <d4alft80s81kitf52gpat9l7h6oott7m0j@4ax.com>, 
> bart.lateur@skynet.be says...
> 
>> So, my advice is to look up the Text::CSV, or better yet, the
>> Text::CSV_XS module. That'll help in getting the records read in
>> properly.
> 
> Great!  I'll have a look into that right now.

Be forewarned, those modules do *not* handle multi-line records.  This
is because CSV is not supposed to have embedded newlines.  Microsoft
ignores this restriction.  I've worked around the problem in the past
by assuming that any parsing error is a result of needing to include
an additional line.  This is a pretty brain-dead approach.

A simple improvement would probably be to read as many lines as it
takes to get another quote.  Yup -- I saw a significant improvement.
Still have trouble if parse fails for some other reason, which I
appear to be experiencing at this point.

Anyway, here's what I'm using now:

#!/usr/bin/perl
use warnings;
use strict;
use Text::CSV;

my $csv = Text::CSV->new();
my $file = shift;

open(FILE, $file) or die "Could not open $file, $!";
$csv->parse(scalar<FILE>) or die $csv->error_input();
my @headers = $csv->fields();
print "Headers: @headers\n";

while (<FILE>) {
  until ($csv->parse($_)) {  # assume an error means unbalanced quotes
    die "Premature end of file:\n$_" if eof FILE;
    while (my $line = <FILE>) {
      $_ .= $line;
      last if $line =~ tr/"//;  # so find another quote
    }
  }
  my @fields = $csv->fields();
  print "$headers[$_]: $fields[$_]\n" for 0..$#headers;
  print "\n";
}
close FILE;
__END__

-- 
Ren Maddox
ren@tivoli.com


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

Date: Fri, 11 May 2001 00:00:42 +0200
From: "Super-Simon" <simon@super-simon.com>
Subject: DES-CBC without Crypt::CBC
Message-Id: <9df2sq$93a$1@news1.xs4all.nl>

Hi all,

I have to encrypt / decrypt strings using DES-CBC. On my hostingserver is
Crypt::DES installed, but not Crypt::CBC (the only Crypt modules installed
are DES and Blowfish).

Where can I get a .pl file doing this (without using another Crypt-module
than Crypt::DES)??????


With kind regards,

Simon




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

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


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