[10221] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3814 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 24 13:07:54 1998

Date: Thu, 24 Sep 98 10:00:18 -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           Thu, 24 Sep 1998     Volume: 8 Number: 3814

Today's topics:
    Re: cat reese > /dev/null (was Re: Perl & Java - differ <work@nospam.idea.co.uk>
    Re: cat reese > /dev/null (was Re: Perl & Java - differ <work@nospam.idea.co.uk>
    Re: Concatenating 3 strings <upsetter@ziplink.net>
    Re: exec cgi in apache 1.3.1 ssantini@my-dejanews.com
    Re: File Reading (Tad McClellan)
    Re: Help: What's wrong with sysread? (Jeffrey R. Drumm)
    Re: Help: What's wrong with sysread? (Larry Rosler)
    Re: How to combine hash %b to hash %a? (union) <ckuskie@cadence.com>
    Re: how to reduce ugly multiple if statements (Matt Knecht)
    Re: How to tinker with @_ in threaded Perl? (Ilya Zakharevich)
        Installing Win32::API?? <sumanm@abctech.com.nospam>
    Re: Perl & Java - differences and uses droby@copyright.com
    Re: Perl & Java - differences and uses <zenin@bawdycaste.org>
    Re: Perl & Java - differences and uses <cousin@ensam.inra.fr>
    Re: Perl & Java - differences and uses (Larry Rosler)
    Re: problem retreiving cookie droby@copyright.com
        Problems with Socket.pm on AIX <s.wiemann@ais-gmbh.de>
    Re: Problems with Socket.pm on AIX (Brian Jepson)
    Re: Q: Picking an element from a hash (not knowing whic (Abigail)
    Re: Rotating an array. (Larry Rosler)
        string as file handle <xah@best.com>
    Re: Where to put cgi-lib.pl dave@mag-sol.com
    Re: Where to put cgi-lib.pl (Bart Lateur)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Thu, 24 Sep 1998 16:49:16 +0100
From: Kiril <work@nospam.idea.co.uk>
Subject: Re: cat reese > /dev/null (was Re: Perl & Java - differences and uses)
Message-Id: <360A69FC.D030FE2D@nospam.idea.co.uk>

Ugh-Ogh

Dear All

I have had the pleasure of reading Mr. George Reese's rants for more
than
two years now, most notably on rec.games.mud.*... The pattern of his
"arguments", 
"logic", etc, etc, has always been identical to what has been recently
unleashed on c.l.p.m.

Mr. Reese's apparent life goal is to convince everybody that he is THE
expert
on whatever catche his fancy for the day. LPC, OO, you name it, he's the
one
to ask.

His signature is not a joke - he really means it.

For the record, Abigail posted a short message after his entry into
c.l.p.m,
drawing attention to certain functionality available on most
newsreaders. Use it.

I will repost this message in a couple of months. Rest assured that
'that thread' 
will still be alive and kicking.

And, yes, Borgie boy, this IS personal, so save your fingers.

Abigail, do you mind sharing with us what is it that you have had to
support?
Not something called 'Nightmare', per chance :-) ?

Abigail wrote:
> 
> Uri Guttman (uri@sysarch.com) wrote on MDCCCXLVIII September MCMXCIII in
> <URL: news:x790jcx4wx.fsf_-_@sysarch.com>:
> ++
> ++
> ++ to sumarize, reese has no sense of humor, no sense of programming
> ++ history, no knowledge of turing machines and turing computability, a
> ++ narrow view of allowable syntax and semantics, a zealotic view on the
> ++ right way to do anything, in short, not a good candidate for perl.
> 
> Well, he does have a programming history. I've had the pleasure of
> maintaining some of his code.
> 
> Perfect examples of how not to code, and how to break any OO principle
> you can imagine.
> 
> Abigail
> --
> perl -wleprint -eqq-@{[ -eqw\\- -eJust -eanother -ePerl -eHacker -e\\-]}-


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

Date: Thu, 24 Sep 1998 16:50:28 +0100
From: Kiril <work@nospam.idea.co.uk>
Subject: Re: cat reese > /dev/null (was Re: Perl & Java - differences and uses)
Message-Id: <360A6A44.E0AD6022@nospam.idea.co.uk>

(possibly) True.

Neither has anyone on c.l.p.m - so far .

George Reese wrote:
> 
> In comp.lang.java.programmer Uri Guttman <uri@camel.fastserv.com> wrote:
> : tho it is nice to hear that someone has seen his OO code and it is as
> : logical as he is.
> 
> Abigail is blowing smoke.  At no time has Abigail seen anything
> representative of my work.
> 
> --
> George Reese (borg@imaginary.com)       http://www.imaginary.com/~borg
> PGP Key: http://www.imaginary.com/servlet/Finger?user=borg&verbose=yes
>    "Keep Ted Turner and his goddamned Crayolas away from my movie."
>                             -Orson Welles


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

Date: Thu, 24 Sep 1998 16:03:42 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: Concatenating 3 strings
Message-Id: <y3uO1.660$_c5.6068575@news.shore.net>

Craig Berry <cberry@cinenet.net> wrote:
: : 
: : $subject = $a.$b."String";

: "Doesn't work" in what sense?  What are your inputs ($a and $b), what
: output do you expect, and what are you seeing instead? 

: Note also that the above can be expressed more succinctly as:

:   $subject = "$a${b}String";

More succinct? It's the same number of characters. :)

It is a little more obfuscated, I'll give you that, but I prefer the first
method of notation (just what I'm used to I guess).

--Art
-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


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

Date: Thu, 24 Sep 1998 16:24:53 GMT
From: ssantini@my-dejanews.com
Subject: Re: exec cgi in apache 1.3.1
Message-Id: <6udrol$hgv$1@nnrp1.dejanews.com>



  sevo@inm.de wrote:
> Time for my standard disclaimer: .htaccess files provide directory
> administrators without server administration privileges with a
> controlled subset of configuration directives pertaining to their
> directory. Except for that particular case, they are not the right place
> for per-directory settings! Anything possible in a .htaccess file (and
> more) can be done inside Directory or Location sections of the config
> file.
>
> Apart from questionable security of putting configuration files in a
> world readable (and often script-writeable) place, .htaccess files have
> to be searched, read and parsed at every hit, and on heavily loaded
> servers, that extra stat and filesystem activity can be particularily
> undesirable.
>

What can I do inside Directory or Location sections of the config file for run
SSI "exec cgi" ?

Thanks for help.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Thu, 24 Sep 1998 08:15:23 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: File Reading
Message-Id: <blgdu6.qp8.ln@flash.net>

Ronald J Kimball (rjk@coos.dartmouth.edu) wrote:
: Reiner <slug@labyrinth.net.au> wrote:

: > The problem is if the $question does not exist. I tried things like the
: > line below but had no luck.
: > while ((<FILE> != $question)) && (!$!) {  }
            ^^^^^^^^^^^^^^^^^^^

Read an input line, but don't save it anywhere...


: I don't know that $! gets set if you try to read past the end of a file.

: while (defined($line = <FILE>) && $line != $question) {  }


The original poster left "the problem" unstated  ;-(

I think the problem is that after the loop exits, he cannot tell
if the question was found or not (because he discarded the line
that was read).



Keeping the line around would help with that (UNTESTED):

   while (<FILE>) {
      last if $_ == $question;
   }

   if ($_ == $question)
      {print "found the question\n"}
   else
      {print "question NOT found!\n"}



--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 24 Sep 1998 16:07:53 GMT
From: drummj@mail.mmc.org (Jeffrey R. Drumm)
Subject: Re: Help: What's wrong with sysread?
Message-Id: <360b6d16.14588917@news.mmc.org>

[ posted to comp.lang.perl.misc and a courtesy copy was mailed to the cited
author ]

On 24 Sep 1998 14:24:35 GMT, "Stan" <Stan_Majka@vapower.com> wrote:

>Can anyone tell me what's going wrong with sysread?
>
>I'm trying to read a 711 KB file, but sysread quits after only about 42 KB.

Please see the most excellent Perl documentation regarding the binmode
function. Enlightenment will ensue.

C:\>perldoc -f binmode

Betcha the 11th byte of record 163 is a ^Z . . .

-- 
                               Jeffrey R. Drumm, Systems Integration Specialist
                       Maine Medical Center - Medical Information Systems Group
                                                            drummj@mail.mmc.org
"Broken? Hell no! Uniquely implemented!" - me


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

Date: Thu, 24 Sep 1998 09:23:29 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Help: What's wrong with sysread?
Message-Id: <MPG.107411d823b63f7e9897ba@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <01bd3887$f84edbe0$adea6a9e@oj-majkas> on 24 Sep 1998 14:24:35 
GMT, Stan <Stan_Majka@vapower.com> says...
 ... 
> I'm trying to read a 711 KB file, but sysread quits after only about 42 KB.
 ...
> Running Perl for Win32 on NT 4.0.

Did you remember to 'binmode' the file before reading it?  There is 
probably a control-Z character there which is being interpreted as end-
of-file. 

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 24 Sep 1998 09:05:07 -0700
From: Colin Kuskie <ckuskie@cadence.com>
To: "Jari Aalto+mail.perl" <jari.aalto@poboxes.com>
Subject: Re: How to combine hash %b to hash %a? (union)
Message-Id: <Pine.GSO.3.96.980924090310.18944D-100000@pdxue150.cadence.com>

[free (meaning with peanut butter, merlyn) copy via email

On 21 Sep 1998, Jari Aalto+mail.perl wrote:

> 
> 	I feel little stupid because I can't figure out the
> 	syntax to add hash %b into existing hash %a
> 
> 		%a = ( aa => 11, bb => 22 );
> 		%b = ( a => 1, b => 2 );

Hashes sometimes act like arrays, especially when you're initializing
them:

%c = (%a, %b);

> 	I assume this is faq material....

I assume that you looked in the faq before posting?  If so, you
wouldn't have found this via the same kind of quick search that
I did.

HTH,
Colin



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

Date: Thu, 24 Sep 1998 16:24:10 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: how to reduce ugly multiple if statements
Message-Id: <KmuO1.384$7Q6.4022410@news2.voicenet.com>

vicuna@my-dejanews.com <vicuna@my-dejanews.com> wrote:
[ About wanting to find files with nested ifs ]

Yikes!  That seems like a lot of work.  I'd cry if I had to support it.
See if this works any better for you:

#!/usr/local/bin/perl -w
use strict;
use File::Find;

my $dir   = shift || '.';
my $fname = shift || 'file.ext';
my @files;

find \&wanted, $dir;

print "Found:\n\t";

{
    local $, = "\n\t";
    print @files;
}

print "\nTotal found: ", scalar @files, "\n";

sub wanted
{
    push @files, $File::Find::name if /\Q$fname/i;
}
__END__

-- 
Matt Knecht - <hex@voicenet.com>


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

Date: 24 Sep 1998 14:39:26 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: How to tinker with @_ in threaded Perl?
Message-Id: <6udliu$p93$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Dan Sugalski 
<sugalskd@netserve.ous.edu>],
who wrote in article <6uco90$a26$1@news.NERO.NET>:
> In comp.lang.perl.misc Mark-Jason Dominus <mjd@plover.com> wrote:
> : 	sub wrapper { unshift @_, qq{$cref}; goto &_handler }
> 
> : 	sub _handler {
> : 	  my $cref = shift;
> : 	  ...
> : 	}

> Seriously, I don't think there's a whole lot you can do. @_ being lexical
> breaks these tricks pretty badly. Tell folks "threads are experimental.
> Don't be surpised that it breaks" 

I do not follow.  What has the implementation of @_ to do with the fact
that 
     goto &_handler
does not work as expected?  It looks like a bug in pp_goto, nothing more.

So the solution may be as simple as sending a patch for pp_goto.

Ilya


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

Date: Thu, 24 Sep 1998 10:00:37 -0700
From: "Suman Misra" <sumanm@abctech.com.nospam>
Subject: Installing Win32::API??
Message-Id: <DOuO1.1119$S23.2034740@news14.ispnews.com>

I'm a newcomer to Perl scripting and have just installed Activeware 5.005_02
(Build 502) on my Windows 95 machine.

The reasons for doing this were to address a specific technical requirement:
Write a script to return system .dll version numbers as well as sizes, build
a table of this information, and then compare this table with similar tables
created at later dates.

I came to understand that Perl was the best language with which to write
such a script and my research gave me to indicate that it would take the
Win32::API module to provide the functions required (e.g. Getversion)

Unfortunately, I do not have access to a C compiler on my machine and,
consequently, cannot install the Win32::API module (the install.pl script
fails--I suspect because it is trying to compile the api.xs C module).

Does anyone have any suggestions on alternate ways to accomplish the task of
compiling and comparing dll information in Windows using Perl? Would it be
more advisable to use some other language (e.g. Java, Python??) instead?

Thanks in advance,

--
Suman Misra
Technical Support Engineer
ABC Technologies <<Remove .nospam on reply>>





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

Date: Thu, 24 Sep 1998 15:30:55 GMT
From: droby@copyright.com
Subject: Re: Perl & Java - differences and uses
Message-Id: <6udojf$d5t$1@nnrp1.dejanews.com>

In article <6ubchg$7bs@enews3.newsguy.com>,
  "Felix S. Gallo" <fsg@newsguy.com> wrote:
>
> Really, this thread should end here, to preserve this distilled
> majesty in dejanews for eternity.
>

Really, this thread should have ended three weeks ago when it started.




-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 24 Sep 98 16:13:05 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Perl & Java - differences and uses
Message-Id: <906653836.885276@thrush.omix.com>

arw@pythonpros.com wrote:
: Okay, I read that to mean you either don't understand
: the question and don't care to bother trying, or you
: can't think of an example and are blustering.

	You read it wrong.  Do we really need to teach *basic* functional
	programming here?  I really hope we don't have to act out "Mr Rogers
	Teaches Lisp" or "Barney's Scheme Hour"...

: For my purposes classes work as well as lambdas.

	That's great, glad to hear it.

: I don't need closures (at least not where a class encapsulation
: doesn't work as well) and don't like them much.

	Pray tell, why do you not like them?

: Continuations might
: be nice once in a blue moon, but multithreading is even better,
: and no less difficult to use.  YMMV.

	We're not talking about continuations or threaded programming. 
	That's an entirely different can of worms.

: Please see
: http://grail.cnri.reston.va.us/cgi-bin/faqw.py?req=show&file=faq06.027.htp

	Python's "Callable objects" do not have deep binding.  For example,
	one can not do:

    {
        my $counter = 0;
        sub set ($)   { $counter = shift }
        sub up ()     { ++$counter }
        sub down ()   { --$counter }
    }

    print up, "\n";
    print up, "\n";
    print set(20), "\n";
    print down, "\n";
    print up, "\n";

    ## prints
    ## 1
    ## 2
    ## 20
    ## 19
    ## 20

	Could you make a count object instead?  Of course, but that would
	not be functional programming, which of course is fine as functional
	programming isn't all that either.  Beyond this however, there are
	limitations.  For instance, what if many (as yet unknown) classes needed
	access to this counter?  A global counter object?  Now we're talking
	name space divisions, not objects, and we're back to functional and
	procedural programming.  What if only one class needed access to it?
	You'd need a class visible "global" object, buy why carry around
	such an animal when all you need is $counter?

	And what of call backs?  For instance, here's a Perl/Tk example that
	uses a counter and two levels of closures to implement GUI callbacks:

    #!/usr/local/bin/perl
    
    use strict;
    use Tk;
    
    my $MW = new MainWindow;
    
    {
        my $Button = 0;
    
        sub makeMeAnAlertButton {
            my $frame       = shift;
            my $showText    = shift;
            my $button      = ++$Button;
    
            $frame->Button (
                -text    => "($button) Push me" . ($button > 1 ? " too!" : "..."),
                -command => sub {
                    my $alert = $frame->Toplevel();
                    $alert->Label   (-text  => $showText)->pack;
                    $alert->Button  (
                        -text       => "ok $button",
                        -command    => sub { $alert->destroy() },
                    )->pack();
                },
            )->pack();
            return $button;
        }
    }
    
    for (
        my $button = makeMeAnAlertButton ($MW, "default");
        print("button $button>"), my $alertText = <STDIN>;
    ) {
        $button = makeMeAnAlertButton ($MW, $alertText);
    }
    
    MainLoop;

    __END__

Can similar functionality be had with OO?  Of course, but I challenge
that it can not be done nearly with the same clarity, simplicity, or
efficiency of both the programmer and the program.

For instance in the case of "-command => sub { $alert->destroy() }", why
would it make any sense to create an entirely new class and object simply
to carry around the $alert?  Let the run time deal with tracking $alert, 
I've got real work to do.

There's the examples you asked for.  Like any more?

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: Thu, 24 Sep 1998 15:58:27 +0000
From: Xavier Cousin <cousin@ensam.inra.fr>
Subject: Re: Perl & Java - differences and uses
Message-Id: <360A6C23.D83A947@ensam.inra.fr>

Behavioral questions : Is this kind of exchange often in this group ?
(yes i'm a recent subscriber)

WWW questions : Isn't this slowing the net ?

Sincerly,

Xavier


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

Date: Thu, 24 Sep 1998 09:45:11 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl & Java - differences and uses
Message-Id: <MPG.107416f0358c7a5d9897bb@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <360A6C23.D83A947@ensam.inra.fr> on Thu, 24 Sep 1998 15:58:27 
+0000, Xavier Cousin <cousin@ensam.inra.fr> says...
> Behavioral questions : Is this kind of exchange often in this group ?
> (yes i'm a recent subscriber)

Yes, too often -- and I abstain in general.  Nevertheless, apart from the 
ad-hominem crap, there have been several enlightening technical 
presentations in this particular thread.
 
> WWW questions : Isn't this slowing the net ?

See the "Tragedy of the Commons" (Garret Hardin, 1968).  Individuals 
behave to optimize their own perceived benefit, without regard to the 
global impact of their behavior.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 24 Sep 1998 15:51:53 GMT
From: droby@copyright.com
Subject: Re: problem retreiving cookie
Message-Id: <6udpqp$eqg$1@nnrp1.dejanews.com>

In article <6uapas$3qk$1@newsreader1.core.theplanet.net>,
  "Guillaume Buat-Menard" <guillaume@nospam.com> wrote:
> Hi all,
>
> I have a perl script on my NT server that works fine, setting a cookie and
> retreiving the value with another script.
>
> When I installed these two scripts on another server (Unix) and made all the
> according changes (domain name...) the first script setting the cookie works
> and I checked the cookie was set. The retrieving script does read the cookie
> string but this string is empty ($ENV{HTTP_COOKIE}).
>
> My question is: is it possible that the configuration on the new server
> doesn't allow to read the cookie string or not?
>

Yes, it is possible, and sounds likely.  You'd best consult the documentation
and newsgroups related to the server.  If indeed the program worked on the old
server and your changes with the move are minimal, it's almost certainly not a
Perl problem.

--
Don Roby

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Thu, 24 Sep 1998 18:08:39 +0200
From: Stefanie Wiemann <s.wiemann@ais-gmbh.de>
Subject: Problems with Socket.pm on AIX
Message-Id: <360A6E87.A14A6593@ais-gmbh.de>

Hello out there,

I use perl 5.004 on AIX. My perlscript includes Socket.pm.

If I try to to execute the script or do a "perl -wc myscript.pl" I get a
memory fault and a core dump. If I comment out the line "use Socket;"
perl -wc works ...

Is there anything wrong with the Socket.pm/Socket.so file?
Or are there any tricks how to compile and install perl on AIX? I didn't
install it on AIX (and thus I don't know the compiler options etc ...)
but I know there have been
some problems ...

On Solaris all works fine ...

Thanks for hints and comments!


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

Date: 24 Sep 1998 16:53:06 GMT
From: bjepson@ids.net (Brian Jepson)
Subject: Re: Problems with Socket.pm on AIX
Message-Id: <slrn70kua8.27k.bjepson@gelvis.ids.net>

On Thu, 24 Sep 1998 18:08:39 +0200, Stefanie Wiemann 
  <s.wiemann@ais-gmbh.de> wrote:
>Hello out there,
>
>I use perl 5.004 on AIX. My perlscript includes Socket.pm.
>
>If I try to to execute the script or do a "perl -wc myscript.pl" I get a
>memory fault and a core dump. If I comment out the line "use Socket;"
>perl -wc works ...
>
>Is there anything wrong with the Socket.pm/Socket.so file?
>Or are there any tricks how to compile and install perl on AIX? I didn't
>install it on AIX (and thus I don't know the compiler options etc ...)

I ran into some problems the first time I tried to compile Perl on AIX
4.1.3 using gcc.  In my case, it was related to the ccdlflags option in
config.sh.  Make sure it is set to:
 
   -Xlinker -bE:perl.exp

instead of just
 
   -bE:perl.exp

>but I know there have been
>some problems ...
>

Would those problems have included only 80% or so of the tests suceeding
during 'make test'?  That's how it manifested itself on my system.  It
seems to have problems with dynamically loaded extensions - in my case, the
tests caused perl to dump core.

You can find out what your ccdlflags option is with perl -V - there may be
other useful information in there.  If in fact, the ccdlflags wasn't set
correctly when Perl was compiled, you'll need to run Configure again and
recompile Perl.  You can set the ccdlflags option during the Configuration
or when it gives you a chance to edit config.sh.  After I got the setting
right for ccdlflags, all tests were successful, and everything has been
happy since...

If that doesn't help, feel free to mail me the output of perl -V, and I'll
compare it to mine.

-- 
Brian Jepson * (bjepson@ids.net)  * http://users.ids.net/~bjepson
              Choosy mothers choose to chew Chew-Z


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

Date: 24 Sep 1998 16:42:46 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Q: Picking an element from a hash (not knowing which!) [Zorn's lemma?]
Message-Id: <6udsq6$pq9$1@client3.news.psi.net>

Mark-Jason Dominus (mjd@op.net) wrote on MDCCCL September MCMXCIII in
<URL:news:6uc5up$rcl$1@monet.op.net>:
++ 
++ You could probably shorten this up a good deal if you were good at
++ obfuscation, which I'm not.  Certainly APL's mighty powers of source
++ code compression are unnecessary here.


Here's an implementation that doesn't use recursion, but regexes:

%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)(
 .))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print # Towers of Hanoi



Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


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

Date: Thu, 24 Sep 1998 09:20:18 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Rotating an array.
Message-Id: <MPG.1074111fb947c3549897b9@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <6udnio$i8k$2@client3.news.psi.net> on 24 Sep 1998 15:13:28 
GMT, Abigail <abigail@fnx.com> says...
> Larry Rosler (lr@hpl.hp.com) wrote on MDCCCXLIX September MCMXCIII in
> <URL:news:MPG.10731134b9d1cf8f9897b5@nntp.hpl.hp.com>:
> ++ In article <6ubo8u$dl1$1@client3.news.psi.net> on 23 Sep 1998 21:13:02 
> ++ GMT, Abigail <abigail@fnx.com> says...
> ++ > Casper Kvan Clausen (ckc@dmi.dk) wrote on MDCCCXLIX September MCMXCIII in
> ++ > <URL: news:Pine.GSO.3.92.980923163020.6326Z-100000@edb>:
> ++ > ++ I'm mainly asking this to see what sorts of strange and twisted answers
> ++ > ++ you guys can come up with, since, given the fickle nature of Usenet, I
> ++ > ++ doubt any answers will appear in time to make into my code.
> ++ >
> ++ > @a = @a [$rot .. $#a, 0 .. $rot - 1];
> ++ 
> ++ Benchmark: timing 16384 iterations of Slice, Splice...
> ++      Slice: 16 secs ( 7.29 usr  0.04 sys =  7.33 cpu)
> ++     Splice:  0 secs ( 0.63 usr  0.01 sys =  0.64 cpu)
> 
> Did you expect otherwise? The question wasn't about efficiency, but
> for strange and twisted answers.
> 
> Now, if your complaint is that the answer isn't very strange or
> twisted, you might have a point.

I made no complaint -- I just posted the data, and let people draw their 
own conclusions.

I think Casper Kvan Clausen was being whimsical about "strange and 
twisted", as he seems to have wanted answers in time to make into his 
code.  So many people posted the same "array slice" solution (without a 
single comment about it being "strange and twisted", let alone 
inefficient) that I feared it might become enshrined as "The Way To Do 
It".  It looks *clever*, like your prime-number-generator .sig, which has 
O(n!) complexity, IIRC.  In each case, there is at least one Much Better 
Way.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 24 Sep 1998 09:52:42 +0000
From: "Xah" <xah@best.com>
Subject: string as file handle
Message-Id: <6udssv$a8c$2@nntp2.ba.best.com>

I learned from the Advanced Perl Programming (panther) book (by Sriram
Srinivasan), that strings can be used as file handles. For example,

open("myFile","~/loveLetter.txt")

instead of

open(MYFILE,"~/loveLetter.txt")

I really like the idea, and intent to always use strings as my file handles.
Is there any potential problem with this? Especially, will this feature be
obsolete in the future?

 Xah, xah@best.com
 http://www.best.com/~xah/PageTwo_dir/more.html
 Little penguins make way: GNU HURD is coming! <www.gnu.org>


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

Date: Thu, 24 Sep 1998 16:16:37 GMT
From: dave@mag-sol.com
Subject: Re: Where to put cgi-lib.pl
Message-Id: <6udr94$h20$1@nnrp1.dejanews.com>

In article <906633948.7548@wren.supernews.com>,
  robert.van.der.elst@centric.nl (Robert) wrote:
> I know this sounds stupid, but I'm entirely new to PERL programming in
general.
> I want to know where to put the cgi-lib.pl file ...

Put it in the bin.

Use CGI.pm instead.


--
dave@mag-sol.com
London Perl M[ou]ngers: <http://www.mag-sol.com/London.pm/>

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Thu, 24 Sep 1998 17:33:47 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: Where to put cgi-lib.pl
Message-Id: <360b821d.20228822@news.ping.be>

Patrick Timmins wrote:

>> I want to know where to put the cgi-lib.pl file ...
>
>Ohhhhhhhhh ... I don't know ...
>
>Please re-phrase that ... and probably in a cgi news group!

Oh come on! I'm SURE this must qualify as a Perl question! The question
is, rephrased: "where can I put it so that Perl can find it", and this
has NOTHING to do with the CGI protocol.

As for an answer, Robert: you can add an extra directory somewhere where
YOU have access to, and add a reference to it (absolute or relative) to
@INC in a BEGIN block. For example, if you add a "lib" folder in your
cgi-bin directory, this works (using a relative path):

	BEGIN {
		unshift @INC, './lib';
	}

Note that this directory must be readable by everyone; chmod
appropiately when installing it.

And don't worry too much about people being able to see the source of
this or other library files, as it's mapped into WWW space. Most servers
won't allow the user to actually access it.

	Bart.


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

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


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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