[8833] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2450 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 29 00:04:36 1998

Date: Tue, 28 Apr 98 21:00:27 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 28 Apr 1998     Volume: 8 Number: 2450

Today's topics:
    Re: 'each' and recursion, do they mix? (Mark-Jason Dominus)
        1701 days hath September (was: Re: rename funciton) <rootbeer@teleport.com>
    Re: 1701 days hath September (was: Re: rename funciton) <ljz@asfast.com>
    Re: 1701 days hath September (was: Re: rename funciton) <sowmaster@juicepigs.com>
    Re: ANNOUNCE: Perl Builder IDE Now Available <metcher@spider.herston.uq.edu.au>
        basic email parser? <james.davis@corp.home.net>
    Re: basic email parser? (brian d foy)
    Re: CGI help for a newbie (Martien Verbruggen)
    Re: Getting the filehandle from a typeglob <fecund@fatnet.net>
        help: HTTP GET method with Perl for NT/95 (Alex Dong Li)
    Re: How to read command line literally? (Ilya Zakharevich)
    Re: How to read command line literally? (Ilya Zakharevich)
    Re: How to read command line literally? <tchrist@mox.perl.com>
    Re: How to read command line literally? (Martien Verbruggen)
    Re: image size for jpg and/or gif (Martien Verbruggen)
    Re: Initializing hash with null array: which is best? <rootbeer@teleport.com>
    Re: Initializing hash with null array: which is best? <zenin@archive.rhps.org>
    Re: Initializing hash with null array: which is best? <zenin@archive.rhps.org>
    Re: Matts Script Archive-WWWBoard-FrontPage-Suddenly No (brian d foy)
        New module for ordered hashes (Ken Williams)
        Pack and Unpack problem!! <tmaster@tea.com>
    Re: Permutations in hashes make Perl hurt (Mark-Jason Dominus)
    Re: rename funciton (was: Re: Dummie question) <ljz@asfast.com>
    Re: Using '::' in variable names. (was Question on sort <rjk@coos.dartmouth.edu>
    Re: writing a format to a scalar. (Martien Verbruggen)
        You people want Perl to be popular? <archive@cglis.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 28 Apr 1998 23:30:21 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: 'each' and recursion, do they mix?
Message-Id: <6i66sd$34p$1@monet.op.net>
Keywords: Maxine Runnymede sumptuous umbra


>Mark-Jason Dominus <mjd@op.net> wrote:
>> The `closures' returned by `make-matcher'
>> are broken---they point to the *same* regex.  

In article <1d87anz.t7xy93phdznkN@slip166-72-108-227.ny.us.ibm.net>,
Kevin Reid <kpreid@ibm.net> wrote:
>OK, here's a workaround:

Thanks, but that is irrelevant to this discussion.  Sarathy suggested
putting the hash iterator into the OP, and I said that was always a
bad idea because putting state into the OPs declosurizes the closures,
and I gave an example of this.

My point was not that you can't dynamically generate pattern-matching
functions in Perl; it was that putting program state into the OP tree
breaks closures.  Your workaround has nothing to do with this.

>Recursive subroutines also have multiple copies of $s.

Thanks for pointing this out.  //o is broken in recursive subroutines
in the same way and for the same reasons, but I didn't say anything
about it because it is less clear that the behavior is wrong and I
didn't want to have a big argument about it.



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

Date: Wed, 29 Apr 1998 03:03:32 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Lloyd Zusman <ljz@asfast.com>
Subject: 1701 days hath September (was: Re: rename funciton)
Message-Id: <Pine.GSO.3.96.980428195407.3378L-100000@user2.teleport.com>

On 28 Apr 1998, Lloyd Zusman wrote:

> 1701 Sept. 1993 is the same as 28 April, 1998, 

Is it really? When is the end of September, by your reckoning? :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 28 Apr 1998 23:24:24 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: 1701 days hath September (was: Re: rename funciton)
Message-Id: <ltn2d5timv.fsf@asfast.com>

Tom Phoenix <rootbeer@teleport.com> writes:

> On 28 Apr 1998, Lloyd Zusman wrote:
> 
> > 1701 Sept. 1993 is the same as 28 April, 1998, 
> 
> Is it really? When is the end of September, by your reckoning? :-)

September never ends ...

-- 
 Lloyd Zusman   ljz@asfast.com
 perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'


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

Date: Tue, 28 Apr 1998 23:36:18 -0400
From: Bob Trieger <sowmaster@juicepigs.com>
Subject: Re: 1701 days hath September (was: Re: rename funciton)
Message-Id: <3546A032.7AFD@juicepigs.com>

Lloyd Zusman wrote:
> 
> Tom Phoenix <rootbeer@teleport.com> writes:
> 
> > On 28 Apr 1998, Lloyd Zusman wrote:
> >
> > > 1701 Sept. 1993 is the same as 28 April, 1998,
> >
> > Is it really? When is the end of September, by your reckoning? :-)
> 
> September never ends ...

Don't say that! None of my software is d2k September 1993 compliant.

-- 
Bob Trieger               |  Titanic: big boat, bigger
sowmaster@juicepigs.com   |           iceberg, big deal


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

Date: Wed, 29 Apr 1998 12:31:37 +1000
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: ANNOUNCE: Perl Builder IDE Now Available
Message-Id: <35469108.18EA194D@spider.herston.uq.edu.au>

Grinch wrote:
> 
snip
> That's also, btw, where the mouse was invented. If I recall correctly, the
> original model had two buttons, and Apple, as usual, insisted on being
> different. ;-)

It had three buttons and the worst marketing team on the planet.  Steve
Jobs was being his usual inspired but minimalist self (one box, no fan,
no colour, hardly any RAM, one mouse button) and Microsoft was doing
it's usual subversive/conservative act, sitting on the fence while
slowly replacing all the pickets with ones of different size.

--
Jaime Metcher


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

Date: Tue, 28 Apr 1998 19:22:35 -0700
From: James Davis <james.davis@corp.home.net>
Subject: basic email parser?
Message-Id: <35468EEB.9ADC08CE@corp.home.net>

Can anyone recommend a PERL module/process for parsing through emails?

Best,

Jim
-- 
James Davis
james.davis@corp.home.net


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

Date: Tue, 28 Apr 1998 22:39:12 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: basic email parser?
Message-Id: <comdog-ya02408000R2804982239120001@news.panix.com>
Keywords: from just another new york perl hacker

In article <35468EEB.9ADC08CE@corp.home.net>, James Davis <james.davis@corp.home.net> posted:

>Can anyone recommend a PERL module/process for parsing through emails?

Mail::* has a lot of goodies.  perhaps you could be more explicit in
your description of what you are trying to do?

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>


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

Date: 29 Apr 1998 03:19:21 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: CGI help for a newbie
Message-Id: <6i667p$md7$2@comdyn.comdyn.com.au>

In article <6i50gb$lgf$1@nnrp1.dejanews.com>,
	mcad999@geb.meteo.fr writes:
> I am new to cgi scripting with perl.
> I want my script to create a new file. But this generates
> an "Internal Server Error: The server encountered an internal error
> or misconfiguration and was unable to complete your request."
> 
> Anyone see anything that could help me ???

Nope. Because you haven't given us a clue.

You definitely want to read the following documents:

Perl CGI FAQ and (no offense) Idiot's guide:

http://www.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html
http://www.perl.com/CPAN/doc/FAQs/cgi/perl-cgi-faq.html

Section 9 of the perl FAQ:

# perldoc perlfaq9

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Tue, 28 Apr 1998 18:58:29 -0700
From: "yary h." <fecund@fatnet.net>
Subject: Re: Getting the filehandle from a typeglob
Message-Id: <35468945.29A7@fatnet.net>

Jason Gloudon wrote:
> 
> yary h. <fecund@fatnet.net> wrote:
> .
> >sub socket_to_me {
> >    my $sock = ++$sockname;
> >    socket(*sock, PF_INET, SOCK_STREAM, getprotobyname('tcp'))
> .
> .
 ...
> 
> *sock returns the entry for 'sock' in the symbol table for the current package.
 ...

The example used strict vars.  If I'm referencing a global in the current package
(though the glob), why doesn't the perl tell me to use an explicit package name
and die?


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

Date: Wed, 29 Apr 1998 03:56:43 GMT
From: lidong@globalserve.net (Alex Dong Li)
Subject: help: HTTP GET method with Perl for NT/95
Message-Id: <6i6brv$pm6$1@titan.globalserve.net>

Dear Perl experts, especially experts on perl for win NT/95,

Is there a simple GET method subroutine in perl, which works on WinNT/95?

The following subroutine GetIt works fine in unix system for
retrieving both binary and text files
However, when I use it to retrieve binary files on windows NT/95,
there is a problem: file size will increase several bytes, and
files will be also corrupt!
I thought the problem might be the carrige return difference
between unix and PC and tried to change \013\010 to \010 
but it did not work.

Could anyone tell me how to solve the problem?

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

$AF_INET = 2;   ## can be found in /usr/include/sys/socket.h
## unix user: check the following value in /usr/include/sys/socket.h
## try 2 if 1 does not work
$SOCK_STREAM = 1;

## a sample:
&GetIt("http://www.uic.edu/~lidong/gif/h1big.gif", "test.gif");

sub GetIt {
    local($url, $outputFilename) = @_;
    local($name,$aliases,$proto,$len,$type);
    local($this, $that, $thisaddr, $thataddr);
    local($server,$port,$serverRelativeURL,$getCommand);

    ## if URL looks like: http://www.univ.edu/blabla
    if($url =~ /^([a-z]+)\:\/\/([^:\/]+)(:\d+)?(.+)$/) {
        $server = $2;
        $port = $3;
        $serverRelativeURL = $4;
    }
    if(!defined($port)) { $port = 80; }
    else { $port =~ s/://; }

    chop($hostname = `hostname`);
    open(OUTPUT_FOR_GET, ">$outputFilename");

    ## build the HTTP GET command
    $getCommand = "GET $serverRelativeURL HTTP/1.0\015\012\015\012";

    $name = $aliases = $proto = '';

    ($name,$aliases,$proto) = getprotobyname('tcp');
    ($name,$aliases,$port) = getservbyname($port,'tcp') unless $port =~ 
/^\d+$/;;
    ($name,$aliases,$type,$len,$thisaddr) = gethostbyname($hostname);

    ($name,$aliases,$type,$len,$thataddr) = gethostbyname($server);
    if($name eq '') { die $!; } # handle gethostbyname failure

    ## change this to clieent, that to server, print out error msg too!
    $this = pack("Sna4x8",$AF_INET,0,$thisaddr);
    $that = pack("Sna4x8",$AF_INET,$port,$thataddr);

    # make the socket filehandle
    if (!socket(SOCKET_FOR_GET,$AF_INET,$SOCK_STREAM,$proto)) { die $!; };

    # give the socket an address
    if (!bind(SOCKET_FOR_GET,$this)) { die $!; }

    #call up the server
    if (!connect(SOCKET_FOR_GET,$that)) { die $!; }

    # set socket to be command buffered
    select(SOCKET_FOR_GET);
    $| = 1;
    select(STDOUT);

    print SOCKET_FOR_GET $getCommand;

    $_ = <SOCKET_FOR_GET>;
    if(/^HTTP/) {
        while(<SOCKET_FOR_GET>) {
            # look for first blank line
            if(/^\w/) { next; }
            else {
                while(<SOCKET_FOR_GET>) {
                   print OUTPUT_FOR_GET $_;
                }
            }
        }
    }
    close(OUTPUT_FOR_GET);
    close(SOCKET_FOR_GET);
}                      


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

Date: 29 Apr 1998 02:07:57 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: How to read command line literally?
Message-Id: <6i621t$dck$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Tom Christiansen 
<tchrist@mox.perl.com>],
who wrote in article <6i5vq6$puv$3@csnews.cs.colorado.edu>:
> :But if it wants, it may examine the command line and find what user
> :wanted, so there is no braindead backslashitis and quotitis for
> :something like
> :	  find . -name *.blah
> 
> Oh, good, so now I have to keep track of which command do or do
> not quote or glob.

Exactly the opposite.  You never need any quoting - unless you want
spaces in arguments, like in

       perl -e "die if shift"

> No fricking thank you.  I didn't like CP/M then, and I don't like it
> now.

Hmm, did I discuss what you like or what you do not?  We all already
know your preferences, and know that you have no way to think about
these topic in any other term.


Btw, nobody answered my question

     Is it possible to write a function which

	tries to start a program (+argc+argv) in background, and  
	returns 1 on success, 0 on failure

     using braindead fork()+exec() interface?

It looks like it is possible!  (I did not try my convoluted solution,
so do not know for sure.)

Ilya


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

Date: 29 Apr 1998 02:10:32 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: How to read command line literally?
Message-Id: <6i626o$dmd$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Jason Gloudon
<jgloudon@bbn.com>],
who wrote in article <slrn6kd0pb.lhf.jgloudon@hyssop.bbn.com>:
> Everything has its plusses and minuses. Consistent behaviour is the plus of
> having one's shell do globbing. Having to remember which program did or didn't
> do globbing becomes very tedious. How often did I wished dir *.txt worked the
> same way as more *.txt ? That aside, if file globbing is a nuisance, you can

Use less.

Ilya


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

Date: 29 Apr 1998 02:19:09 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How to read command line literally?
Message-Id: <6i62mt$4ji$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
:Exactly the opposite.  You never need any quoting - unless you want
:spaces in arguments, like in

Oh good.  Now we can have applications doing their own command line
redirection, too.  Won't that be fun?  And let's add enviroment variable
expansion in the arguments to the application?

You really have no clue about this at all, do you?

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

  "Contempt, rather than celebration, is the proper response to 
   advertising and the system that makes it possible." --Neil Postman


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

Date: 29 Apr 1998 02:06:33 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How to read command line literally?
Message-Id: <6i61v9$m51$1@comdyn.comdyn.com.au>

In article <6i5vi3$njv@srvr1.engin.umich.edu>,
	gsar@engin.umich.edu (Gurusamy Sarathy) writes:
>   [ mailed and posted ]
> 
> In article <6i5o31$l6s$3@comdyn.comdyn.com.au>,
> Martien Verbruggen <mgjv@comdyn.com.au> wrote:
>>(Also: note that the GS port of perl is not the 'standard
>>distribution'. It behaves very much like it, but it's patched here and
>>there.
> 
> Hunh?  Can I ask how you arrived at that conclusion?  The perl in
> bindist04 was built from pristine 5.004_02 sources (no less, no more)
> and the README says so.  There are some "third-party" modules that
> needed patching, for which you'll find the patches in there also.

Whoops. I was talking from memory here, which I shouldn't have done.
I must have sort of stored the patches to the third party modules in
my fallible memory, and forgot that they weren't patches to the core
distribution...

Apologies.

> No information is better than misinformation, y'know. :-)

Indeed.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: 29 Apr 1998 02:58:26 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: image size for jpg and/or gif
Message-Id: <6i650i$md7$1@comdyn.comdyn.com.au>

In article <354605c3.0@news.greatbasin.net>,
	"Henry Wolff" <admin@hatsoft.com> writes:
>>perl5 Makefile.PL PREFIX=/libs
> Worked Ok
>>make && make test
> Worked Ok
>>make install
> You do not have permissions to install into
> /usr/libdata/perl5/site_perl/i386-bs
> dos at -e line 1
> *** Error code 2
> 
> Could it be something in the perl setup? The /user/bin/perl is a 4 version
> so you have to type perl5 to get it to compile right. Is there a different
> make for perl5 maybe?

Make is not part of perl. It's a standard utility on most unices.

It just looks like you don't have permissions to write to that
directory (in what way is the message not clear?). Either install as
root, or keep the modules in your own directory. How to do that, is
described in perlfaq8, as Jonathan Feinberg already told you.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Wed, 29 Apr 1998 02:25:21 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Zenin <zenin@archive.rhps.org>
Subject: Re: Initializing hash with null array: which is best?
Message-Id: <Pine.GSO.3.96.980428191820.3378K-100000@user2.teleport.com>

On 29 Apr 1998, Zenin wrote:

> 	If you had said:
> 
> 	$fred->{thing} = ('foo', 'bar', 'cat', 'dog');
> 
> 	$fred->{thing} would have equaled 'dog'.  I'm not sure where this
> 	is documented, 

It's the scalar comma operator, documented in perlop.

> and I for one don't think it makes any sense
> 	considering that "('foo', 'bar', 'cat', 'dog')" is a list (albeit
> 	a list constant) that is being evaluated in scalar context 

Not really. It just _looks_ like a list. There's no such thing as a list
in a scalar context in Perl.

> so it
> 	really should return 4, not 'dog'.  

Not really. Only a few list operations return the length of the list when
used in a scalar context; it's the exception, not the rule.

> It gets even odder when:
> 
> 	($fred->{thing}) = ('foo', 'bar', 'cat', 'dog');
> 
> 	sets $fred->{thing} to equal 'foo'...

No, that's an ordinary list assignment; no problem there.

> even if you call scalar() on
> 	the thing to try and force it:
> 
> 	$fred->{thing} = scalar (('foo', 'bar', 'cat', 'dog'));

That gives dog; the scalar() is superfluous. Did you mean to write
something else?

> 	Hmm, maybe I should call it a bug and submit it already...

I haven't seen a bug here yet. :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 29 Apr 1998 02:53:39 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: Initializing hash with null array: which is best?
Message-Id: <893818850.409413@thrush.omix.com>

> It's the scalar comma operator, documented in perlop.

	Ah, ok.  I still think it's lame though, but that's MHO. :-)

> Not really. It just _looks_ like a list. There's no such thing as a list
> in a scalar context in Perl.

	Err...huh?

	@foo = qw(foo bar cat dog);
	$bar = @foo;        # list evaluated in scalar context
	print $bar;         # prints 4
	$bar = scalar @foo; # explicitly asking for list in scalar context
	print $bar;         # still prints 4

	Or, if one would like to force perl to not optimize the list away
	and treat it like most other list contexts are and should be treated
	(IMHO), you can trick it:

	$bar = @{[('foo', 'bar', 'cat', 'dog')]};
	print $bar;  # prints 4

	Albeit a lame kluge to get scalar context.  There is no list()
	function to force list context, but @{[ statement ]} gives that
	effect anyway, even when the statement normally wouldn't.

	Perl is special casing list constants when it really shouldn't
	be, IMO.

> > so it
> > 	really should return 4, not 'dog'.  
> 
> Not really. Only a few list operations return the length of the list when
> used in a scalar context; it's the exception, not the rule.

	...?  Are you speaking of the list given, or returned?  I'd have to
	go count, but I think operators that return a list will return the
	count if called in scalar context if they have not been overloaded
	to return something else in scalar context (ala localtime()).  I
	might check this out later, if you don't beat me to it. :-)

> > It gets even odder when:
> > 	($fred->{thing}) = ('foo', 'bar', 'cat', 'dog');
> > 	sets $fred->{thing} to equal 'foo'...
> No, that's an ordinary list assignment; no problem there.

	It's fine by itself, but when compared with the non list assignment
	form I think it's a little odd.

> > even if you call scalar() on
> > 	the thing to try and force it:
> > 	$fred->{thing} = scalar (('foo', 'bar', 'cat', 'dog'));
> That gives dog; the scalar() is superfluous. Did you mean to write
> something else?

	Nope, that's what I meant to write.  That's my point.  I should
	be able to force "normal" list in scalar context with the scalar()
	function.  That's what it's there for after all.  I still can get
	my way despite perl (ala @{[()]} above), but I still think it's
	silly.

> > 	Hmm, maybe I should call it a bug and submit it already...
> I haven't seen a bug here yet. :-)

	I haven't called it a bug, yet.  It's just silly enough that I
	pretty much should though.  Not that it would get fixed, because
	I'm sure someone out there is relying on this silly quark and
	worse yet, there are people I'm sure that actually like it.

-- 
-Zenin (zenin@archive.rhps.org)
 The Bawdy Caste (San Jose, CA)       http://www.netmagic.net/~dmcgrath/bawdy/
 Barely Legal   (Berzerkly, CA)                    http://www.barelylegal.org/
 Zenin's Rocky Horror Archive (I MOVED!)          http://www.archive.rhps.org/
 RHFC1.02 V800@!M!P1S2RY1980 P*B-R+20@H-D+100@W+200@T+5@P@L15@Y1990&&1@(7@)!1
 C8@W3@P@& IF&-W&&-N+M1C! MA2{RO,PQ}M{PQ}C3B15@R15@V1O@+++ D?-K1S@C0!O{IS}T5@


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

Date: 29 Apr 1998 02:55:30 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: Initializing hash with null array: which is best?
Message-Id: <893818960.740076@thrush.omix.com>

[posted & mailed]

Tom Phoenix <rootbeer@teleport.com> wrote:
	>snip<

	BTW, when you CC people your followups, it's nice to mention
	it at least in the email so one doesn't waste time replying
	twice (see above).  Thanks.

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: Tue, 28 Apr 1998 22:27:51 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Matts Script Archive-WWWBoard-FrontPage-Suddenly Not Working
Message-Id: <comdog-ya02408000R2804982227510001@news.panix.com>
Keywords: from just another new york perl hacker

In article <6i5vig$7cs@fridge.shore.net>, "Grinch" <grinch@whoville.com> posted:

>Bob Confer wrote in message <6i5mvc$drs$1@news1.i1.net>...
>
>>I have been running the wwwboard script from Matt's Script Archive for
>>sometime now through my ISP on a Unix server.

>It's much more likely to be a problem with FrontPage than with the scripts.
>When any working system breaks down, you look to see what changed to cause
>the problem. The biggest change to your site, and therefore most likely
>cause of the problem, was the addition of FP to the picture.

this is one of those situations when i can't decide which is worse.  is it
Matt Wright or FrontPage?

in this case, it was exactly as i had guessed after we debugged it in email.
Matt tends not to check the return value of his open()s, so things that
were supposed to write to a file often end up writing to an unopened
FILEHANDLE without complaining.  this happens when the data files aren't
world writeable (which, as we know, is already a security concern).

if anyone ever wondered why so many real programmers don't like Matt's
work, this is a really good example.  this is also probably one of the
reasons that he refuses to support his own code - there are just too
many bugs.

sorry for the rant, but give discredit where it is due.  it wasn't
Microsoft's fault this time.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>
but then, i'm biased.


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

Date: Tue, 28 Apr 1998 23:20:24 -0400
From: ken@forum.swarthmore.edu (Ken Williams)
Subject: New module for ordered hashes
Message-Id: <ken-2804982320240001@news.swarthmore.edu>

Hi,

I've written a new module that does ordered hashes.  I'm calling it
Tie::LLHash currently.  Here's its short description:


 This class implements an ordered hash-like object.  It's a cross between a
 Perl hash and a linked list.  Use it whenever you want the speed and
 structure of a Perl hash, but the orderedness of a list.  

 Don't use it if you want to be able to address your hash entries by number, 
 like you can in a real list ($list[5]).

 See also Tie::IxHash by Gurusamy Sarathy.  It's similar (it does
 ordered hashes), but it has a different internal data structure and a
different 
 flavor of usage.  It makes your hash behave more like a list than this does.




(see source at http://forum.swarthmore.edu/tools/perlmods/Tie-LLHash.txt)

Anyone interested in seeing it on CPAN?  Or does anyone have any
suggestions for improvement?


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

Date: Tue, 28 Apr 1998 21:19:13 -0500
From: T-Master <tmaster@tea.com>
Subject: Pack and Unpack problem!!
Message-Id: <35468E21.92F5D85D@tea.com>

I am trying to setup the Netscape Client Customization Kit for my ISP. 
Here is the stuff i am doing:

I have a program to write some binary data, and another program to read
the binary data:

write to a file :---------------------------------------------------
print F pack("v",6),pack("a*","STATUS"),pack("v",2),pack("a*","OK");


read :-----------------------------------------------------------------
sysread(F,$buff,2,8);
print unpack("v",$buff),"\n";

As you can see, the print statement from read supposed to print 2, but
it is not.  What am i doing wrong here?  the sysread or read can only
correctly read the first 2 bytes.  can someone enlighten me, pleaseeee??


here is what I actually wanted to do:

When Navigator sees this MIME type, it expects data in the format
described below. The binary file format used by this MIME
type is simple, yet extensible. It consists of consecutive name/value
pairs separated by 2 bytes of size information: 

| 2 bytes | ------ x bytes ------ | 2 bytes | ------ y bytes ------ | 
(x)              (name)            (y)             (value)

The parser iterates as follows until it reaches the end of the stream:

     Read 2 bytes of binary data and cast to int for size of Name in 
bytes (x) 
     Read (x) bytes of ASCII data for the name 
     Read 2 bytes of binary data and cast to int for size of Value in
bytes (y) 
     Read (y) bytes of ASCII data for the value 
---------------------------------------------------------------------
Because my netscape doesn't seem to work when my server return this MIME
stream, so i thought i should try to simulate to read the binary data. 
Have anyone setup the Netscape Client Customization Kit before??  win95.

Any HELPS is much appreciated..... 

shaolin_@_granax.com


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

Date: 28 Apr 1998 23:19:34 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Permutations in hashes make Perl hurt
Message-Id: <6i6686$330$1@monet.op.net>
Keywords: marrow mien procreate shaw


> Dominus wrote in article <6i5tu4$1nu$1@monet.op.net>:
>
>> 37 would still show poor behavior for permutations, but the behavior
>> would be better than 33.  Every 4th bucket would get populated instead
>> of every 8th bucket.  For good behavior on permutations, the number
>> you want to pick has the form 4N+3.  

In article <6i61c1$c1m$1@mathserv.mps.ohio-state.edu>,
Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
>Wrong.  Multiplicative group mod 8 is not cyclic, it has 4 elements
>but any element squared is 1.  Thus any odd residue mod 8 which *is
>notn 1* gives the same performance.

I think you have done the wrong analysis.  I put the short explanation
at the end.  Long explanation follows.

Suppose we have a string S, and we would like to make a hash with
every permutation of the characters of S.  Let us suppose that S[i]=A
and S[j]=B and consider how hash(S) changes when we exchange
characters at positions i and j.  I will take S[0] to be the rightmost
character in the string, for convenience.

position:      i   ...   j  ...  0
S:    ...      A   ...   B  ...  S[0]
S':   ...      B   ...   A  ...  S[0]

Suppose M is the multiplier in the hash function, and M is odd.  (Even
M is obviously very, very bad.)  Perl uses M=33.  I say that only
M=8N+3 or M=8N+7 gives the best behavior here; you say that 8N+5 is
just as good as these.

In string S, character A contributes A*M^i to the hash value, and B
contributes B*M^j.  In S', where A and B are exchanged, contributions
are A*M^j and B*M^i instead.

The difference between these two contributions is the total difference
in hash value between S and S'.  It is M^i * (B-A) * (M^(i-j)-1). 

The big problem here is M^(i-j)-1.  This number must be even, because
M is odd.  That means the entire difference is even.  This shows that
for any two strings S1 and S2 that are permutations of one another,
hash(S1)-hash(S2) is a even number.  That means that if we make all
the permutations of S and put them in a hash, at most half the buckets
will be full.  Between any two full buckets is an empty one.

Sometimes the situatin is worse than that.  If M=33, for example,
M^(i-j)-1 is always a multiple of 32.  Hash values for S1 and S2 in
this case will always differ by a multiple of 32.  If we make all
permutations of S and put them in a hash, all but 1/32 of the buckets
will be empty.  (Unless there are fewer than 32 buckets.)

We want to compute
	Q = GCD(M-1, M^2-1, M^3-1, ...)

If we do this, then we know that if the multiplier is M, and if we put
all ther permutations of S into a hash, then all but 1/Q buckets will
be empty.

When M=8N+3, we get

	Q = GCD(8N+2, 64N^2+48N+8, 512N^3+576N^2+216N+26, ...)
          = 2

This is the best we can do---half the buckets will be empty.

When M=8N+5, which you say is just as good, we get

	Q = GCD(8N+4, 64N^2+80N+24, 512N^3+960N^2+600N+124, ...)
	  = 4

which means that if M=8N+5, at least 3/4 of the buckets will be empty.

Short version of explanation: We agree that 8N+1 is a problem.  But
4N+1 is a problem in the same way, only not quite as bad as 8N+1.
8N+5, which you say is good, is an example of 4N+1, so it is bad, not
good.

>I would thing that contemporary processor multiply in one instruction,
>do not they?

This is really outside my area of expertise.  But not all instructions
take the same time, and I think that the multiplication instruction is
usually much slower than add and shift instructions.  

Only stupid people would optimize multiplication to shift-and-add if
there was not something to be gained from that.  gcc was not designed
by stupid people.  Even in *un*optimized mode it generates
shift-and-add instead of multiplication on sparc sun4, for example.


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

Date: 28 Apr 1998 22:22:51 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: rename funciton (was: Re: Dummie question)
Message-Id: <ltvhrttlhg.fsf@asfast.com>

Tom Phoenix <rootbeer@teleport.com> writes:

> On 28 Apr 1998, Abigail wrote:
> 
> > Tom Phoenix (rootbeer@teleport.com) wrote on MDCCI September MCMXCIII in
> > <URL: news:Pine.GSO.3.96.980428130928.15049m-100000@user2.teleport.com>:
> > ++ On 28 Apr 1998, Abigail wrote:
> > ++ 
> > ++ > Tom Phoenix (rootbeer@teleport.com) wrote on MDCCI September MCMXCIII in
> > ++ > <URL: news:Pine.GSO.3.96.980428101400.15049J-100000@user2.teleport.com>:
> > ++ 
> > ++ Was that a Tuesday? :-)
> > 
> > Did you post that on a Tuesday?
> 
> It happens that I did. But I didn't post it on 1701 September 1993, by any
> stretch of the imagination.

1701 Sept. 1993 is the same as 28 April, 1998, which does indeed
happen to have fallen on a Tuesday, and possibly even the same Tuesday
you posted.  I believe that the algorithm is in one of Abigail's
 .sig's.

> [ ... ]

-- 
 Lloyd Zusman   ljz@asfast.com
 perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'


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

Date: Tue, 28 Apr 1998 23:42:09 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: Using '::' in variable names. (was Question on sorting)
Message-Id: <3546A194.B4A6BF5B@coos.dartmouth.edu>

Brad Baxter wrote:
> 
> $str:: = "hey\n";
> print $str::;
> [...]
> New question: Assuming I name variables this way (unlikely), am I asking
> for trouble doing so?

  DB<1> $str:: = 'Foo!'

  DB<2> x $str::
0  'Foo!'
  DB<3> x $main::str::
0  'Foo!'
  DB<4> X ~str
$str:: = 'Foo!'
  DB<5> x $str
0  undef
  DB<6> x $main::{'str::'}
0  '*main::str'
  DB<7> x \%main::
0  HASH(0x1002845c)
[...]
   'str::' => '*main::str'
[...]
  DB<8> $str = 'Bar!'

  DB<9> x $str
0  'Bar!'
  DB<10> x $str::
0  'Foo!'
  DB<11> X ~str
$str:: = 'Foo!'
$str = 'Bar!'
  DB<12> x \%main::
0  HASH(0x1002845c)
[...]
   'dumpvar' => '*main::dumpvar'
   'dumpvar::' => '*main::dumpvar'
      *DUMPED_GLOB*
[...]
   'str' => '*main::str'
   'str::' => '*main::str'
      *DUMPED_GLOB*
[...]
  DB<13> 

It looks kinda weird, but I think you'll be okay.

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 29 Apr 1998 03:23:45 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: writing a format to a scalar.
Message-Id: <6i66g1$md7$3@comdyn.comdyn.com.au>

In article <01bd72bc$b69b6fa0$3f8a63a1@amervw29436.clv.am.bp.com>,
	"Joe Foose" <foosejm@bp.com> writes:
> How does one go about writing a format to a scalar variable rather than to
> a filehandle without having to use an intermediate file?  Is there a way to
> associate a filehandle with a scalar variable?  Any help appreciated. 

I'm not entirely sure what you are asking, but maybe you should read
the documentation on this, which ships with perl

# perldoc perlform

It has a section 'Accessing Format Internals'. That might mention what
you're looking for.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Tue, 28 Apr 1998 22:45:41 -0400
From: Chris Lambrou <archive@cglis.com>
Subject: You people want Perl to be popular?
Message-Id: <35469455.4B144377@cglis.com>

Well?



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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

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

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

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 2450
**************************************

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