[15803] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3216 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 31 00:05:42 2000

Date: Tue, 30 May 2000 21:05:10 -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: <959745910-v9-i3216@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 30 May 2000     Volume: 9 Number: 3216

Today's topics:
    Re: capturing password via Basic Auth <kkrieger@erols.com>
    Re: casting? (Gwyn Judd)
    Re: Dynamically assigning $variable name? <bwalton@rochester.rr.com>
    Re: First (implicit) argument passed to a method? <bwalton@rochester.rr.com>
    Re: First (implicit) argument passed to a method? <ilesandrew@hotmail.com>
    Re: Is Perl for me? <elaine@chaos.wustl.edu>
    Re: Newbie asks about where to place custom script conf <y-o-y@home.com>
    Re: oops Re: seeking method to encode email addresses i <nospam@devnull.com>
    Re: oops Re: seeking method to encode email addresses i <godzilla@stomp.stomp.tokyo>
    Re: oops Re: seeking method to encode email addresses i <elaine@chaos.wustl.edu>
    Re: Passing print statements (Craig Berry)
    Re: Passing print statements <tina@streetmail.com>
    Re: Please help me with this ONe? <lauren_smith13@hotmail.com>
    Re: Regex prime numbers (Was Re: seeking method to enco <godzilla@stomp.stomp.tokyo>
    Re: Regex prime numbers (Was Re: seeking method to enco <godzilla@stomp.stomp.tokyo>
    Re: Regex prime numbers (Was Re: seeking method to enco <godzilla@stomp.stomp.tokyo>
    Re: Regex prime numbers (Was Re: seeking method to enco (Sam Holden)
    Re: Regex prime numbers (Was Re: seeking method to enco <erebus@hushmail.com>
    Re: seeking method to encode email addresses in web pag <anmcguire@ce.mediaone.net>
        Using a package identifier inside a package <conrad20342001@hotmail.com>
    Re: Using a package identifier inside a package <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 30 May 2000 23:54:08 -0400
From: Kurt Krieger <kkrieger@erols.com>
Subject: Re: capturing password via Basic Auth
Message-Id: <39348CDF.80457560@erols.com>

Thanks for the information. I know that IIS does provide the password as
AUTH_PASSWORD (or something similar), and up until now I've considered
that to be a security risk. But now that I need it, I miss it!
Kurt

"Alan J. Flavell" wrote:

> On Tue, 30 May 2000, Kurt Krieger wrote:
>
> > Getting the username is trivial ($ENV{'REMOTE_USER'}, or CGI.pm's
> > user_name() sub), but I can't figure out how to get the password.
>
> That's because the web server doesn't make it available to CGI
> scripts, for security reasons.
>
> Making the plain-text password available may be feasible (by modifying
> the server), but has significant security implications for this
> already relatively insecure procedure.  There's some notes about it in
> the Apache distribution, as I recall: look for the build option
> SECURITY_HOLE_PASS_AUTHORIZATION  (I think the name was chosen to
> discourage from using it, which is probably a wise move!).
>
> Ideally you should be looking for some alternative way for the two
> servers to convince each other that the client is authentic. Using a
> central authentication server might be one possibility. The details of
> this would go beyond the scope of this kind of answer.
>
> I've narrowed f'ups, but I strongly recommend redirecting further
> discussion to the web servers group where your OS is on topic
> (comp.infosystems.www.servers.unix or whichever), or conceivably to
> comp.infosystems.www.authoring.cgi
>
> Suggestions on posting style:
>
> It's generally considered inappropriate to cross-post to several
> closely-related groups: an issue is usually considered on-topic to
> xxx.misc when there is no more-appropriate xxx.[specific] group for
> it, and vice versa.
>
> Cross-posting is useful, but it's best kept for situations where a
> topic is genuinely relevant to groups that otherwise have little
> relationship to each other.  On top of that, comp.lang.perl is
> obsolete, and, as it happens, your question turns out to be more
> appropriate elsewhere, though maybe this wouldn't be obvious
> beforehand, I don't know.  (Me, I'd think it only too obvious how
> non-Perl-specific CGI issues are regularly rebuffed on c.l.perl.*,
> but maybe I'm just over sensitive...).
>
> --
>
> Public service announcement: Please ignore the troll.



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

Date: Wed, 31 May 2000 02:40:26 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: casting?
Message-Id: <slrn8j8utf.8fp.tjla@thislove.dyndns.org>

I was shocked! How could Neil Macneale <mac4@operamail.com>
say such a terrible thing:
>Hi all!
>
>I am new to the world of PERL, and I seem to have missed something in the
>Camel book.  How do I cast something?  I want to read in a character from

<snip>

You don't have to in Perl (not PERL by the way :) ). Perl will treat
numbers as strings and strings as numbers more or less depending on what
you want to do with them. Use the ord() function (perldoc -f ord) to get
the ASCII value of a character.

>The problem I am trying to solve is this:  When I read MacOS text files on
>a Linux machine the new line characters are not recognized.  I want to use

<snip>

This should be a lot easier than what you are trying. This seems to work
for me:

perl -i.bak -pe 's/\015/\012/sg' readme

Type that in at the command line (and change the "readme" to the name of
the file you want to convert). It will overwrite the file and make a
backup in $file.bak. Have a look at (perldoc perlport) for an
explanation of line endings (and other stuff).

-- 
Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
The reason why worry kills more people than work is that more people
worry than work.


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

Date: Wed, 31 May 2000 02:54:25 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Dynamically assigning $variable name?
Message-Id: <39347DDE.984680EA@rochester.rr.com>

Bart Lateur wrote:
 ...
> Look, Perl has a very nice alternative to symbolic references: storing
> your data in a hash. It is entirely safe, it is virtually as fast, and
> you can even loop over all user supplied variables (try doing THAT using
> symbolic references!)

   print "$_\n" for sort keys %main::;

 ...
>         Bart.
-- 
Bob Walton


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

Date: Wed, 31 May 2000 01:52:23 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: First (implicit) argument passed to a method?
Message-Id: <39346EFC.AD48CEFD@rochester.rr.com>

Andrew Iles wrote:
> 
> I have a simple question regarding the first argument passed to methods
> when using object oriented perl. It seems to me that the first argument
> passed is implicitly a pointer to the class that the function is blessed
> into, or at least some kind of pointer to the calling package. I'm
> having to look through some perl code that was written by someone else
> and a typical bit is as follows:
> 
> .
> .
> .
> sub activate {
>     my($this) = @_;
>     ...
>     $cgi = $this->get_cgi();
>     ...
> .
> .
> .
> 
> What I don't understand is that the function will be called with no
> parameters. So is this reference always the first element of @_ ?
 ...
> Andrew iles

Andrew, yes, the object instance making the call is passed as the first
argument to a method (so the method knows what object called the
method), with the call looking like:

    $obj->activate;

to use your example above.  In Perl, objects are "references", not
"pointers", since Perl doesn't have "pointers" (since "references" are
better than "pointers" in several important respects).  Also, I don't
think your terminology regarding "class" is correct -- the "class" would
refer to something which is common to all object instances sharing the
same code (like, for example, the methods and class variables shared by
all instances).  It is the object instance which is passed as the first
argument to a method, not the class.  The method can determine the class
of the object instance it receives if necessary by examining the class
into which the object instance was blessed (using the ref function).

To learn more, use the resouces already on your hard drive, like:

    perldoc perltoot
    perldoc perlobj

etc.  Or read a book like "Object-Oriented Perl".
-- 
Bob Walton


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

Date: Wed, 31 May 2000 00:25:27 -0500
From: Andrew Iles <ilesandrew@hotmail.com>
Subject: Re: First (implicit) argument passed to a method?
Message-Id: <3934A247.BEF5A3F2@hotmail.com>

Thanks a million to the both of you.

I have been reading a good deal on perl of late, but sometimes a simple answer
to a specific question can be worth hours of frustration and searching, even
for the simplest things.

As always though, I try to find a non-human source before a give up and post a
question on a newsgroup. :-)

--andrew



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

Date: Wed, 31 May 2000 02:48:51 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: Is Perl for me?
Message-Id: <B559F5CE.51A0%elaine@chaos.wustl.edu>

in article 8h1lh2$7ba$11@news.panix.com, Abigail at abigail@arena-i.com
quoth:
> ++ 1. Is Perl going places?
> Yes, specially Paris.

Paris? Darling, Paris is for lovers...Perl is heading for a nice peaty bog
in the highlands of Scotland so it can brood across the moors and keep up
the Loch Ness Monster tourism. :)

e.



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

Date: Wed, 31 May 2000 02:25:23 GMT
From: Andy <y-o-y@home.com>
Subject: Re: Newbie asks about where to place custom script config files?
Message-Id: <nK_Y4.224805$Tn4.1969070@news1.rdc2.pa.home.com>

In article <8766rv5z8i.fsf@limey.hpcc.uh.edu>, Tony Curtis 
<tony_curtis32@yahoo.com> wrote:

> >> On Wed, 31 May 2000 00:36:58 GMT,
> >> Andy <y-o-y@home.com> said:
> 
> > Hi folks!  My script does a check for 2 files and if
> > they're not found, the script branches to a LABEL to
> > print prompt from STDIN to create the files as:
> 
> > open (IN ,"perlotto.cfg") or goto SETOPTIONS; #for
> > example
> 
> goto.  Bad.  Bad.  BAD!!!
> 
> It sounds like you just want to check the files for open
> and use a conditional to prompt if you can't open them.
> 
Well yeah, kinda/sorta. I just want to run a "first-run" trial test to 
make sure the files exist, so after routing the user through the 
"SETOPTIONS" promts, the correct files are created and forever after it 
skips that.

Andy


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

Date: 31 May 2000 01:09:15 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: oops Re: seeking method to encode email addresses in web pageforms
Message-Id: <8h1onr$qpk$0@216.155.32.186>

In article <393459FC.698E6563@stomp.stomp.tokyo>, "Godzilla!" 
<godzilla@stomp.stomp.tokyo> wrote:

 | The WebDragon wrote:
 | > In article <39343EC3.43CFD43@stomp.stomp.tokyo>, "Godzilla!"
 | > <godzilla@stomp.stomp.tokyo> wrote:
 | >  | The WebDragon wrote:
 | >  | > "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
 | >  | >  | The WebDragon wrote:
 | >  | >  | > "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
 | 
 | 
 | >  and you *still* haven't responded to 95% of the body 
 | > of the post.
 | 
 | Too much word wrapping in your program.
 | You should take this out. Doesn't look
 | as pretty. Don't word wrap your lines.

when I posted the code I set the linewrapping to 150 chars.. after 
finishing the post I set it back to 72 chars where it belongs.

 | It's a nice program. I would be interested to
 | see printed results and results of a harsh
 | reality test, not a home system sissy test.
 | Have you dumped it onto the web yet to see
 | how it does under realistic conditions?

'realistic conditions' would be "run from the user's system to scan this 
week's uploaded reviews (usually between 30-50 reviews per week) for the 
appropriate details". (see www.planetunreal.com/nalicity/ and look for 
the sunday post to see an edited version of the output) 

this script wasn't designed to be run from the web, which is why it 
OUTputs an html file instead of displaying it as inline CGI. If I wanted 
a .cgi I would have written one; this is meant to be a .pl :)

This was, obviously, intentional. 

 | Not touching your code, I would comment there is
 | no need for -w, your code works, right? Strict
 | reduces your flexibility in imagination, as the
 | name stict implies, explicitly. Both -w and strict
 | are junk and insult the beauty of your program.
 | It's an aesthetic thing with me. Why splatter your
 | work of art with garbage like -w and strict? Show
 | some confidence in your obvious well advanced Perl
 | programming skills.

ahhhh but those usages helped me trap some nasty accidental typos. :) 

 | Posix is well known for its bugs, such as returning 
 | incorrect times and often causing a Perl core dump 
 | into your script directory. You could cut your bloat 
 | factor significantly by dumping Posix. For one kilobyte
 | of code you could write a better sub-routine which would
 | do more and do it better than twenty-eight kilobytes of 
 | Posix could ever do. Calling gmt time will introduce a 
 | serious bug with Posix in some European time zones, for 
 | what it isn't worth. Posix is huge bug bloat factor not 
 | worth the trouble it causes on a routine basis. 

Since the script is run once, and the resultant html page is not created 
on the fly, nor created again until more reviews get uploaded so we can 
skim the results and select Map of the Week, this is not a serious 
problem.. 

it merely makes the timestamp part of the html AS TEXT, so that one can 
be certain the file has changed since last viewed. locality is not an 
issue here. 

 | Portability is reduced by use of cgi.pm which introduces 
 | a bloat factor in the thousands of percent and could 
 | introduce a lot of its well known bugs, if you expand 
 | upon this for a user interface. You really don't need
 | cgi.pm for what you are doing. I see no serious security
 | issues, unless you expand into an elaborate user interface
 | which allows input.  You could write your own code in 
 | one-hundredth of cgi.pm's six-thousand plus lines of code
 | at a quarter of a megabyte bloat. Maybe a custome code
 | to replace unreliable cgi.pm with something of class?

Funny, I have found that CGI.pm has thorughly reduced the amount of time 
it takes me to bring a project involving web output to fruition, and I 
simply cannot agree. Lincoln Stein seems to be quite assiduous in 
providing bugfixes, and responds to e-mail promptly. 

I prefer not to re-invent the wheel whenever it is unnecessary, 

 | I would remove use of 'or die' in favor of better error 
 | checking with an html diagnostic print-out. This 'or die'
 | is basically worthless. You can do better than using this
 | piece of junk 'or die'. Seems your program is a work of
 | individual art which would be enhanced by replacing this
 | 'or die' with something of great and multiple use. Think
 | about custom error checking which checks many items all
 | at once, in one piece of short code. Hmm.. I believe one
 | of my techniques for this is in a recent article.

On the contrary, EVERYTHING I've seen points to making sure to test the 
open to make sure it works, or die if it doesn't. I'll keep it in there, 
thanks. I've heard this TOO MANY times to ignore.

 | Nice coding, well organized, neat in appearance. I like 
 | your code. Be nice if I could give it one of my reality 
 | tests. However, well... there is a portability issue.
 | Won't run under 5.003 Perl. =)

From all the bugreports I've seen, 5.003 has some SERIOUS security flaws 
in it, and thus I wouldn't recommend its use anyway. Since all two 
people involved in the use of this script have 5.004 or better, this is 
not an issue.

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: Tue, 30 May 2000 18:29:05 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: oops Re: seeking method to encode email addresses in web pageforms
Message-Id: <39346AE1.5A226285@stomp.stomp.tokyo>

The WebDragon wrote:
> 
> In article <393459FC.698E6563@stomp.stomp.tokyo>, "Godzilla!"
> <godzilla@stomp.stomp.tokyo> wrote:

>  | Too much word wrapping in your program.
>  | You should take this out. Doesn't look
>  | as pretty. Don't word wrap your lines.
 
> when I posted the code I set the linewrapping to 150 chars.. after
> finishing the post I set it back to 72 chars where it belongs.

I was making another joke. You really need to
upgrade your sense of humor. Don't ya get it?
Any word wrapping I see is because of my
newsreader.. get it? A joke.

Ha? Ha?


Baloney, baloney, get rid of a few of those
modules, write some custom error checking
of your own, dump cgi.pm and write your own 
mangler, write your own Mickey Mouse watch.

Why be happy with modules and all that stuff
when you can do it your way, the right way?
You are a purist programmer like myself, right?

I am the Salvadorina Dali of Perl programming.

If all you are going to do is disagree with
me, I won't critique your code again. At least
show some diplomatic, "Well, yeah maybe I could."

First time Posix dumps a multi-mega core into
your script directory, you will be back, 

"Oh my God! What now Salvordorina!!??"

For trivia, many, probably lots of people out
there never realize a fubar "while" and fubar
posix drops a big load of core into their
script directory. What they notice is their
email overhead vanishes and never know why,
until their sysop fixes it or.. a person asks
why they are being charged for excessive
disk storage. Ha!

Wanna dump a core for fun? Use this:

while (FILE_HANDLE)

instead of:

while (<FILE_HANDLE>)

in a current working program and watch
Perl poop in your script directory.



Perl 5.003 is only insecure if you don't
know what you are doing.


Godzilla!


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

Date: Wed, 31 May 2000 03:02:07 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: oops Re: seeking method to encode email addresses in web pageforms
Message-Id: <B559F8ED.51A1%elaine@chaos.wustl.edu>

in article 39346AE1.5A226285@stomp.stomp.tokyo, Godzilla! at
godzilla@stomp.stomp.tokyo quoth:
> I am the Salvadorina Dali of Perl programming.

"I don't do drugs, I am drugs."

Hmmm...it all starts to make sense...

e.



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

Date: Wed, 31 May 2000 01:16:42 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Passing print statements
Message-Id: <sj8pvqcq5pj173@corp.supernews.com>

Ron Auer (rrauer@mitre.org) wrote:
: I have a subroutine, and depending on what I pass it, it will print one
: of two formats.
: 
: E.g.,	$format_one = "%-45s \t%6s \t%-15s\n"
: 	$format_two = "%-50s \t%10s\n"
: 
: This I can pass into the sub with no problem.  What I would like to know
: - is there anyway to pass a print statment into the sub as a variable
: (of sorts).  I need two print statments for the two format statements.
: 
: E.g.	printf $format_one, "Data", "More Data", "And more data"
: 	printf $format_two, "Data", "More Data"
: 
: Here is what I would like to do:
: ___________________________________________________________
: 
: sub test {
: printf $_[0];
: }
: 
: $format = "%-45s \t%6s \t%-15s\n";
: $print_statement= $format, "Data", "More Data", "And more data";
: test ($print_statement);
: 
: $format = "%-50s \t%10s\n";
: $print_statement = $format, "Data", "More Data";
: 
: ___________________________________________________________________
: 
: Of course I know this doesn't work, but is there a way to do something
: like this?

#!/usr/bin/perl -w
# myprintf - demo of passing in print formats and arguments
# Craig Berry (20000530)

use strict;

sub myprintf {
  printf @_;
}

my $format     = "%-45s \t%6s \t%-15s\n";
my @print_args = ($format, "Data", "More Data", "And more data");

myprintf(@print_args);

$format     = "%-50s \t%10s\n";
@print_args = ($format, "Data", "More Data");

myprintf(@print_args);


-- 
   |   Craig Berry - cberry@cinenet.net
 --*--  http://www.cinenet.net/users/cberry/home.html
   |   "The road of Excess leads to the Palace
      of Wisdom" - William Blake


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

Date: 31 May 2000 02:10:01 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Passing print statements
Message-Id: <8h1s9p$27ekg$1@fu-berlin.de>

hi,

Larry Rosler <lr@hpl.hp.com> wrote:
> In article <8h1llm$2716d$4@fu-berlin.de> on 31 May 2000 00:16:54 GMT, 
> Tina Mueller <tina@streetmail.com> says...

>> $format = "%d \t%d \t%s\n";
>> $print_statement= q($format, $a, $b, $c);
>> test ($print_statement);
>> sub test {
>>  eval "printf ".shift;
>> }'

> The use of the 'eval STRING' capability should be a last resort.  This 
> is not such a case.  Use a list of arguments, not a string that has to 
> be eval'ed to create the list.

well, I have to admit that I never thought
of using a list of arguments, in this case
it would be enough; I just thought
"let the others know that you know
the function eval" (just kidding :-)

tina

-- 
http://www.tinita.de \  enter__| |__the___ _ _ ___
tina's moviedatabase  \     / _` / _ \/ _ \ '_(_-< of
search & add comments  \    \ _,_\ __/\ __/_| /__/ perception


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

Date: Tue, 30 May 2000 19:06:00 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Please help me with this ONe?
Message-Id: <8h1s46$boh$1@brokaw.wa.com>


Chung Derek <dchk_78NOdcSPAM@yahoo.com.invalid> wrote in message
news:0f380c77.9a20daea@usw-ex0106-046.remarq.com...
>
> my previous script have some command suck as "unlink" to delete
> a specified file. do i need to change to (eg. del file.txt)?
> basically, my question is can are this command based from unix
> command , or perl? If the latter, can I assume the function can
> be used no matter where I port the script, right.

The 'unlink' function is a built-in Perl command, there is no need to change
unlink to system('del *.*');

Lauren




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

Date: Tue, 30 May 2000 19:51:11 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Regex prime numbers (Was Re: seeking method to encode email       addresses in web page forms)
Message-Id: <39347E1F.662FB054@stomp.stomp.tokyo>

Sam Holden wrote:

> Copying the prime generator you quoted in you post 
> (I snipped) will impress you? 

> no Content-Type crap

> You'll notice there are 14 numbers there, so your answer was wrong.



Well gosh, now don't you just take the fun out
of everything in a schoolyard bully fashion.

Your code is not portable.

*shrugs*

So much for trying to have a little fun..

Godzilla!


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

Date: Tue, 30 May 2000 20:28:52 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Regex prime numbers (Was Re: seeking method to encode email       addresses in web page forms)
Message-Id: <393486F4.4286A6B4@stomp.stomp.tokyo>

Alex Gough wrote:
> 
> "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
> news:393471A9.3DD05F0E@stomp.stomp.tokyo...

> > There are twelve composite numbers in these
> > results you will see.
 
> Er, prime number generator with composite numbers?

Yes, and splitting hairs is an effective
way of nit picking. Learned this right
off as a teacher.
 
> A new programming paradigm is upon us.

Possibly, if you pay close attention.

 
> > Write a cutesy program
> > to find those twelve composite numbers. This
> > will impress me, sorta.

* laughs in her sleeve *


> Well, those of us that can count found 14, this worked for me:

I only have 12 fingers, in total.

 
> @¬ =(41); # the key to the kingdom
> 
> for (1..100) {
>  my $candidate = ($_**2 + $_ + 41);
>  LOOP: foreach (@¬) {
>   if (($candidate/$_)== int($candidate/$_)) {
>    print "$candidate is not a prime, factor $_\n";
>    push @¬, $¬[-1]+2*@¬;
>    last LOOP;
>   }
>  }
> }
> 
> exit(0) or die "Why doesn't the troll check error codes?";



Well, I would ask why don't people pay attention?

hmmm.. yeah, that is a pretty cute program.
However, I do not see any results, just code,
albeit pretty code. Does it work?

Godzilla!


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

Date: Tue, 30 May 2000 18:58:01 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Regex prime numbers (Was Re: seeking method to encode email    addresses in web page forms)
Message-Id: <393471A9.3DD05F0E@stomp.stomp.tokyo>

The WebDragon wrote:
> Brad Baxter wrote:
>  |  Gwyn Judd wrote:
>  | >  Larry Rosler wrote:

>  | > Okay that's got me curious. What is this regex prime number >  | > generator?

>  | perl -wle '$_ = 1; (1 x $_) !~ /^(11+)\1+$/ && print while $_ ++'
 
> owie. neat, but it seems to have some sort of problem on my machine :/
> crashes and hangs somewhere around 5000

For your MAC and you should break down and
buy an IBM... a gentle prime number generator
which runs from 43 to 10141 to be gentle on
your system. However, a challenge Mr. Dragon.

There are twelve composite numbers in these
results you will see. Write a cutesy program
to find those twelve composite numbers. This
will impress me, sorta.


Godzilla!



#!/usr/local/bin/perl

print "Content-Type: text/plain\n\n";

@Prime_Array = (1 .. 100);

foreach $element (@Prime_Array)
 {
  $prime_save = $element;
  $prime = ($element**2);
  $prime = ($prime + $prime_save + 41);
  print "$prime \n";
 }

exit;


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

Date: 31 May 2000 02:41:54 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Regex prime numbers (Was Re: seeking method to encode email    addresses in web page forms)
Message-Id: <slrn8j8uvh.p7f.sholden@pgrad.cs.usyd.edu.au>

On Tue, 30 May 2000 18:58:01 -0700,
	Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
>The WebDragon wrote:
>
>For your MAC and you should break down and
>buy an IBM... a gentle prime number generator
>which runs from 43 to 10141 to be gentle on
>your system. However, a challenge Mr. Dragon.
>
>There are twelve composite numbers in these
>results you will see. Write a cutesy program
>to find those twelve composite numbers. This
>will impress me, sorta.

Copying the prime generator you quoted in you post (I snipped) will impress
you? 

>
>#!/usr/local/bin/perl
>
>print "Content-Type: text/plain\n\n";
>
>@Prime_Array = (1 .. 100);
>
>foreach $element (@Prime_Array)
> {
>  $prime_save = $element;
>  $prime = ($element**2);
>  $prime = ($prime + $prime_save + 41);
>  print "$prime \n";
> }
>
>exit;

Or simply (OK less newlines, no spaces, no Content-Type crap):

perl -e 'print join "\n",map {$_**2+$_+41} (1..100)'

So we combine that with the regex one above:

perl -e 'print join "\n",map {$_**2+$_+41} (1..100)' | \
	perl -lne 'print if (1x$_)=~/^(11+)\1+$/'

and we get:
1681 
1763 
2021 
2491 
3233 
4331 
5893 
6683 
6847 
7181 
7697 
8051 
8413 
9353 


You'll notice there are 14 numbers there, so your answer was wrong.


-- 
Sam

The very fact that it's possible to write messy programs in Perl is also
what makes it possible to write programs that are cleaner in Perl than
they could ever be in a language that attempts to enforce cleanliness.
	--Larry Wall


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

Date: Wed, 31 May 2000 04:14:33 +0100
From: "Alex Gough" <erebus@hushmail.com>
Subject: Re: Regex prime numbers (Was Re: seeking method to encode email    addresses in web page forms)
Message-Id: <8h202s$ib7$1@news.ox.ac.uk>

"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:393471A9.3DD05F0E@stomp.stomp.tokyo...

> For your MAC and you should break down and
> buy an IBM... a gentle prime number generator
> which runs from 43 to 10141 to be gentle on
> your system. However, a challenge Mr. Dragon.
>
> There are twelve composite numbers in these
> results you will see.

Er, prime number generator with composite numbers?

A new programming paradigm is upon us.

> Write a cutesy program
> to find those twelve composite numbers. This
> will impress me, sorta.
>
>
Well, those of us that can count found 14, this worked for me:


@¬ =(41); # the key to the kingdom

for (1..100) {
 my $candidate = ($_**2 + $_ + 41);
 LOOP: foreach (@¬) {
  if (($candidate/$_)== int($candidate/$_)) {
   print "$candidate is not a prime, factor $_\n";
   push @¬, $¬[-1]+2*@¬;
   last LOOP;
  }
 }
}

exit(0) or die "Why doesn't the troll check error codes?";

--
Alex Gough




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

Date: Tue, 30 May 2000 22:36:12 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: seeking method to encode email addresses in web page forms
Message-Id: <Pine.LNX.4.21.0005302223340.11474-100000@hawk.ce.mediaone.net>

On Tue, 30 May 2000, Godzilla! wrote:

+ The WebDragon wrote:
+ 
+ > hmm.. let's see.. I make some helpful suggestions and 
+ > you turn around and insult me...
+ 
+ No, you made tactless unwarranted comments pertaining
+ to notions which are simply none of your business.
+ Your comments are exceptionally insulting. Use social
+ grace with me or I will blast you each time for your
+ intentional poorly veiled rudeness and insulting
+ commentary. 

Oh jeez.

+ Play it straight with me and you won't have problems.
+ Play games and I will match you move-for-move and,
+ in the final end, call a checkmate along with taking
+ both your King and Queen, my old friend.

You can't 'take' the king in chess, obviously you do not
know how to play chess either.

+ Practice social grace with me. I have dignity and
+ pride within an environment lacking these qualities.

I am gone, you are too much.  To all the experts and people
out there who know Perl like the back of their hands, good
luck to you.. You have a real problem to deal with in Godzilla!
I have had enough of you, Godzilla.   You have ruined this
NG IMHO.  My recommedation is that everyone in the NG (experts too),
killfile Godzilla, and then post a once-a-week message, explaining
to newbies that they should killfile her as well.  Perhaps if
many people also put a couple of good lines in their sigfile,
that would help too.  I am fairly certain if a message was
posted frequently warning newbies to ignore or killfile her,
as well as some activism in signatures, that she would give up
and go away.  Perhaps an entry in the FAQ is needed, heck she
has been trolling here for half a year now... Geeez.

Well best wishes to you all, even you Kiralynne.  I don't hate
you, in some respects I even admire you... However, I think
you go about helping and making your points the wrong way.
What I hate is the aggravation you cause the citizens of c.l.p.m.
After yesterday, I realized, there is too much angst here.

Best Regards,

anm
-- 
/*-------------------------------------------------------.
| Andrew N. McGuire                                      |
| anmcguire@ce.mediaone.net                              |
`-------------------------------------------------------*/



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

Date: Wed, 31 May 2000 00:20:04 -0500
From: Drew Connery <conrad20342001@hotmail.com>
Subject: Using a package identifier inside a package
Message-Id: <3934A104.7F1D3DC4@hotmail.com>


Hope someone can help me understand a piece of code that I've been
looking over. I'm a new PERL programmer so I'm sure it's a simple issue.

If I create a package:

    package temp

and create a hash inside of the package:

  $temp::info = {...};

then why do I need to use the package identifier when creating the new
hash? Since it's being defined inside of the temp package shouldn't it
be associated anyway?
This is code that someone else wrote and it works fine.

Thanks,
Drew



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

Date: Wed, 31 May 2000 02:45:05 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Using a package identifier inside a package
Message-Id: <39347BB2.FD493298@rochester.rr.com>

Drew Connery wrote:
> 
> Hope someone can help me understand a piece of code that I've been
> looking over. I'm a new PERL programmer so I'm sure it's a simple issue.
> 
> If I create a package:
> 
>     package temp
;-----------------^
> 
> and create a hash inside of the package:
> 
>   $temp::info = {...};
Actually, that is a hash reference, not a hash.
> 
> then why do I need to use the package identifier when creating the new
> hash? Since it's being defined inside of the temp package shouldn't it
> be associated anyway?
You don't need to use the full name inside a package.  But you always
*can* reference a global variable by its full name, which includes the
package in which it resides as above.  And that can be done inside the
package or anywhere else.  Inside the package, it is not necessary;
elsewhere is it necessary.  For more info, see:

    perldoc perlmod

 ...
> Drew
-- 
Bob Walton


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 3216
**************************************


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