[10222] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3815 Volume: 8

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

Date: Thu, 24 Sep 98 12:00:23 -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: 3815

Today's topics:
    Re: any way to encrypt my script? <zenin@bawdycaste.org>
    Re: Array of hashes: a better way? <jdporter@min.net>
    Re: Calling java from cgi(Perl W32) run on Windows NT <baliga@synopsys.com>
    Re: Checking if open dir contains a sub directory scott@softbase.com
    Re: Database with Perl <perlguy@inlink.com>
    Re: exec cgi in apache 1.3.1 <sevo@inm.de>
        fcgi && win32 <yinso@u.washington.edu>
        How to activate a process on filechange? (Beaker Ben Shapiro)
    Re: How to activate a process on filechange? <evonzee@tritechnet.com>
    Re: How to combine hash %b to hash %a? (union) <uri@camel.fastserv.com>
        how to print output from pppstats using perl? <triangle@iinet.net.au>
    Re: how to reduce ugly multiple if statements <david.corcoran@pss.boeing.com>
    Re: How to tinker with @_ in threaded Perl? <sugalskd@netserve.ous.edu>
    Re: ls or dir comand in perl (Doran L. Barton)
    Re: MLDBM object methods <jdporter@min.net>
        mod_perl problem <jeffb@mcguckin.com>
    Re: mod_perl problem <sevo@inm.de>
    Re: Perl & Java - differences and uses <zenin@bawdycaste.org>
    Re: Perl & Java - differences and uses <zenin@bawdycaste.org>
    Re: Perl & Java - differences and uses <zenin@bawdycaste.org>
    Re: Perl & Java - differences and uses <jdane@hawaii.edu>
    Re: Perl & Java - differences and uses <fsg@newsguy.com>
        Perl & Redirecting STDIN & NT (Stephen Elias)
    Re: Poll: How Did You Learn Perl? droby@copyright.com
    Re: Poll: How Did You Learn Perl? (Will Morse)
    Re: Poll: How Did You Learn Perl? (Larry Wall)
    Re: Poll: How Did You Learn Perl? <danw@execpc.com>
        portable open() <jspin@csd.sgi.com>
    Re: Q: Picking an element from a hash (not knowing whic (Mark-Jason Dominus)
    Re: Q: Picking an element from a hash (not knowing whic <jdporter@min.net>
        require statements cause netscape server errors rockwell@shr.dec.com
        Retrieve cgi results to file rather than to display <dundee@dnai.com>
    Re: Trouble with ActiveState Perl on WinNT Workstation  (Stephen Elias)
    Re: Where to put cgi-lib.pl <perlguy@inlink.com>
    Re: Where to put cgi-lib.pl <zenin@bawdycaste.org>
    Re: Where to put cgi-lib.pl <upsetter@ziplink.net>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 24 Sep 1998 17:49:40 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: any way to encrypt my script?
Message-Id: <906659335.854398@thrush.omix.com>

[posted & mailed]

jmh@pubserv.com wrote:
: Can anyone suggest additional methods for implementing (or resources
: discussing approaches for) obfuscating Perl code?
	>snip<

	I have already offered this in a step by step example.  Please
	see message ID <906620410.569011@thrush.omix.com> in this same
	thread.

-- 
-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 14:36:25 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Array of hashes: a better way?
Message-Id: <360A9129.5992B854@min.net>

Uri Guttman wrote:
> 
> Andre L <alecler@cam.org> writes:
> 
> > my ($key,$value) = split /\s*=>\s*/, $line, 2;
>                                     ^^^^^^^^
> i don't think this is was you meant. it won't return the 2 fields,
> probably just null strings. the split should be on '=>' or it should be
> a match like $line =~ /(\s+)=>(\s+)/

I think you're confused... maybe you thought those were \S, not \s.
He's trying to include any whitespace in what gets stripped by the
split.

-- 
John "Many Jars" Porter


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

Date: Thu, 24 Sep 1998 10:24:05 -0700
From: Yogish Baliga <baliga@synopsys.com>
To: johnvun@asiapac.net
Subject: Re: Calling java from cgi(Perl W32) run on Windows NT
Message-Id: <360A8035.586C8EEF@synopsys.com>

Use system() function of Perl to call the native application.

Baliga

johnvun wrote:

> Dear Expert,
>
> How to call java application from a cgi (Perl W32) run on Windows NT?
>
> I want to run a cgi, from the cgi call a java application, then format a
> html page back to user.
>
> Thanks !
>
> johnvun





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

Date: 24 Sep 1998 17:51:26 GMT
From: scott@softbase.com
Subject: Re: Checking if open dir contains a sub directory
Message-Id: <360a869e.0@news.new-era.net>

Doyle Johnson (sales@madm.com) wrote:

>   So if any one can tell me how to check to see if the contents of a
> directory is a file or sub, please let me know.

Use the -d file test against the pathname.

Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more. 


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

Date: Thu, 24 Sep 1998 17:00:42 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: Database with Perl
Message-Id: <360A7ABA.B385232C@inlink.com>

Simply put, no.  I'm sure if you wanted to write a web server and run
that off of the CD, that may be an option - but I doubt it.

Without a web server, your browser doesn't know what to do with a .cgi
or a .pl file.  Try to access one from your browser that is on your hard
drive.

HTH,

Brent

-- 
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$            Brent Michalski             $
$         -- Perl Evangelist --          $
$    E-Mail: perlguy@technologist.com    $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


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

Date: Thu, 24 Sep 1998 19:34:50 +0200
From: Sevo Stille <sevo@inm.de>
Subject: Re: exec cgi in apache 1.3.1
Message-Id: <360A82BA.D3FC568C@inm.de>

ssantini@my-dejanews.com wrote:

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

"Options Includes", just as in .htaccess. To repeat it: Anything that
can go inside a .htaccess file (and some more) can go inside a directory
context. 

Sevo

-- 
Sevo Stille
sevo@inm.de


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

Date: Thu, 24 Sep 1998 11:27:15 -0700
From: Y Chen <yinso@u.washington.edu>
Subject: fcgi && win32
Message-Id: <Pine.OSF.3.96b.980924111752.24660A-100000@saul5.u.washington.edu>

Hi,

has anyone gotten FCGI to work under win32?  My understanding is that you
would need SFIO compiled into Perl.  Currently I am using ActiveState's
Perl Build 502.  I have VC++ on my computer as well, but I don't know how
to build extensions using VC++.  Can someone please enlighten me on the
following:

1. can FCGI work with ActiveState's build? 

2. or should I change to GS's build?

3. how can I build the SFIO (do I need it?) into the perl?

4. can someone give me a pointer on how to build extension on Win32 (is it
something similar to the way to do it on Unix?).  Like what kind of
settings I would require, etc., etc.

Any help is greatly appreciated :)

yin-so				



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

Date: Thu, 24 Sep 1998 16:12:57 GMT
From: bjshapir@undergrad.math.uwaterloo.ca (Beaker Ben Shapiro)
Subject: How to activate a process on filechange?
Message-Id: <EzsqDM.CJ8@undergrad.math.uwaterloo.ca>


	Hi everyone - up until this time, I've been a pretty
successful lurker on this newsgroup, but a problem has come up
that is beyond my perl knowledge.

	I am in the situation where I need to write a program that
essentially sits and watches a set of files to see if any one of
them changes, and if it does, it needs to copy it quickly to a
few other filenames as well - they are configuration files and any
one of them may change.

	Obviously I can write some CPU-intensive code that checks
and checks and checks and checksandchecksandchecks..  But that is
unfeasible (infeasible?); also if I choose to check only every
five minutes - or two minutes - or 10 seconds, then I am opening
up windows where collisions may occur (well, _bigger_ windows,
anyway.)..

	I've checked through the llama and the camel and couldn't
find any command or routine, and quite frankly, I'm doubting that
even perl is up to the task.. (Ooo.. making friends..)

	But seriously - if anyone has a helpful comment, I'd really
appreciate it - even if it's written with extreme derision and/or
contempt - I'll TAKE IT!!

	Thanks for any help!
	Ben



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

Date: Thu, 24 Sep 1998 13:17:05 -0500
From: Eric Von Zee <evonzee@tritechnet.com>
Subject: Re: How to activate a process on filechange?
Message-Id: <360A8CA1.BCAC4490@tritechnet.com>

MMmmmmmmm... Synchronization.......

The VB/C programmer here was up against the same sort of difficulty...

He licensed code from Lotus, I think (sob)...


>         I am in the situation where I need to write a program that
> essentially sits and watches a set of files to see if any one of
> them changes, and if it does, it needs to copy it quickly to a
> few other filenames as well - they are configuration files and any
> one of them may change.
>
>         Thanks for any help!
>         Ben

--
Best Regards,
Tritech Marketing Inc.

Eric Von Zee
Webmaster




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

Date: 24 Sep 1998 14:55:10 -0400
From: Uri Guttman <uri@camel.fastserv.com>
Subject: Re: How to combine hash %b to hash %a? (union)
Message-Id: <sarzpbpwdbl.fsf@camel.fastserv.com>

>>>>> "CK" == Colin Kuskie <ckuskie@cadence.com> writes:

  CK> [free (meaning with peanut butter, merlyn) copy via email
  CK> 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 );

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

  CK> %c = (%a, %b);

this has been answered before with more accurate code. yours creates a
new array and the poster asked about adding to an existing array.

@a{ keys %b } = values %b ;

it is probably faster too.

  >> I assume this is faq material....

i hope it gets in there.

uri


-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

Date: Fri, 25 Sep 1998 01:01:47 +0800
From: Andrew Mulvey <triangle@iinet.net.au>
Subject: how to print output from pppstats using perl?
Message-Id: <360A7AFB.376062D@iinet.net.au>

Hi

Pretty (well very) new to Perl.

I was wondering if anyone could shed some light on the best way to use
perl to print out the output of pppstats - i want to run the command
from w32 so that i can set up a constant pppstats output for my linux
box on my w98 client but not have to use telnet.

Any advice would be great :)

Thanx

T :)

--
___________________________________________________________

Andrew Mulvey              [TRB]_Triangle
ICQ UIN ---->1642641

email:    triangle@iinet.net.au
              mulvea@royalst.training.wa.gov.au (work)

'Why is it that everytime you tick a box in windows you have to
reboot?????'
___________________________________________________________




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

Date: Thu, 24 Sep 1998 17:18:08 GMT
From: David Corcoran <david.corcoran@pss.boeing.com>
To: vicuna@my-dejanews.com
Subject: Re: how to reduce ugly multiple if statements
Message-Id: <360A7ED0.204BA06D@pss.boeing.com>

vicuna@my-dejanews.com wrote:
> 
> Hi,
> 
<snip>

 What I want to do is loop over guesses as to
> the name of directory.  I am using a set of if statements which work but just
<snip>

>     if (!-e $first_guess$first_guess ne $real) {
>         $first_guess =~ s/control/cntrl/i;
>         if (!-e $first_guess) {
>             $first_guess =~ s/cntrl/cntrl1/i;
>             if (!-e $first_guess) {$first_guess = ();print "not found\n";}
>         }
>     }
> And this works but I have a bunch of these and it just looks ugly to me.  Any
> feedback or suggestions?
> 
> Bob
> 

Bob,

I have no idea what this line is doing so I ignored it:)
if (!-e $first_guess$first_guess ne $real)

 ... a suggestion:
----------------8<------------------------
    $_ = 'h:\first\second\third\cntrlrev\file.ext';

    for $guess (qw(control cntrl cntrlrev)) {
        if (/\Qh:\first\second\third\E\\$guess\Q\file.ext/) {
            print "found $_";
            $found = 1;
            last;
        }
    }

    print "not found\n" unless ($found);
----------------8<------------------------


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

Date: 24 Sep 1998 17:49:13 GMT
From: Dan Sugalski <sugalskd@netserve.ous.edu>
Subject: Re: How to tinker with @_ in threaded Perl?
Message-Id: <6ue0mp$gq2$1@news.NERO.NET>

In comp.lang.perl.misc Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
: [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.

No, it's not. Would that it was that simple.

The lexical @_ inside of wrapper() isn't available to _handler() any more
than a my variable in wrapper would be. Lexical scope for @_ begins at the
sub's opening {, IIRC. _handler's completely outside the scope of wrapper,
so there's no way it'd have access to wrapper's lexicals.

The situations' identical to this:

	#! perl -w
	my $foo = "1";
	sub bar { my $foo = "2"; goto &baz;}
	sub baz {print "$foo\n"}
	bar();
	
with $foo taking the place of @_.

Lexical @_ screws Mark's trick hard, and there's no easy workaround that
leaves @_ lexical. Reglobalizing it is the only way to get it to work.

I'm seriously thinking that making @_ per-thread would be A Good Thing.
I'm just not sure of how much work it'd be. (And I don't have the time for
it now regardless)

					Dan


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

Date: 24 Sep 1998 11:12:46 -0600
From: fozz@xmission.xmission.com (Doran L. Barton)
Subject: Re: ls or dir comand in perl
Message-Id: <6uduie$pq5$1@xmission.xmission.com>

"Claudio Villa Santa" <claudio@crpweb.com> writes:

>Someone can tell my how I can have list of file present in a directory in an
>perl array?

  opendir DH, "/dir/to/read/from";

  @file_array = readdir DH;

  closedir DH;

-=Fozz
-- 
Doran L. Barton = fozz@xmission.com && http://www.xmission.com/~fozz/;
"Where do you want Microsoft to go today?" --Ron Barry <ronb@cc.usu.edu>
"This may seem a bit weird, but that's okay, because it is weird."
  -- Larry Wall <lwall@sems.com> in the Perl v5 man page


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

Date: Thu, 24 Sep 1998 14:42:29 -0400
From: John Porter <jdporter@min.net>
Subject: Re: MLDBM object methods
Message-Id: <360A9295.8E525DE6@min.net>

Steve Manes wrote:
> 
> i.e. like their dbm counterparts.  They seem to traverse the physical
> hash rather than the table in a logically sequential way, i.e. in a
> hash of $Msg{0}.. $Msg{9} this won't work:
> 
>         for ($key = (tied %Msg)->FIRSTKEY;
>               $key < 26;
>               $key = (tied %Msg)->NEXTKEY($key)) {
>                 print $key;     ## print 0 -> 9, sequentially
>         }
> 
> Instead, FIRSTKEY returns 21 and subsquent calls to NEXTKEY return a
> quarterback snap call: 6, 19, 15, 4, etc.
> 
> Do you know how to get around this?  I know I can get an ordered list
> of keys with sort(keys %Msg) but that means hauling a potentially huge
> array into memory.  But it also means that I can't arbitrarily set
> $key to, say, 6789, call NEXTKEY and expect 6790 (or 9 zillion, if
> there were lots of empty records in between).

Well, I don't know why you would expect any behavior other than what
you got, considering it's well-documented in many places.

If you want a hash which remembers the order in which the keys
were added, check out the Tie::IxHash module.

-- 
John "Many Jars" Porter


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

Date: Thu, 24 Sep 1998 10:55:12 -0600
From: Jeff Beard <jeffb@mcguckin.com>
Subject: mod_perl problem
Message-Id: <360A7970.B86F231B@mcguckin.com>

Hello,

I hope you'll excuse the cross post. I'm running Apache and have just
built mod_perl into it. I setup the configuration to srm.conf to use
mod_perl for any .pl files. Now my scripts fail with the following error
messages in the Apache error log:

[Thu Sep 24 10:20:47 1998] [error] Can't locate Apache/Registry.pm in
@INC (@INC contains: /usr/lib/perl5/5.005/i586-linux
/usr/lib/perl5/5.005 /usr/lib/perl5/site_perl/5.005/i586-linux
/usr/lib/perl5/site_perl/5.005 . /usr/local/apache-fp/
/usr/local/apache-fp/lib/perl) at (eval 3) line 2.

[Thu Sep 24 10:23:06 1998] [error] Undefined subroutine
&Apache::Registry::handler called.

Attempt to free unreferenced scalar.

The problem is that Apache/Registry.pm is in /usr/lib/perl5/site_perl
where everything else is and has been. I've tried adding the following
to the scripts:

use lib '/usr/lib/perl5/site_perl' ;

That didn't work. So, I'm wondering where else can I change the @INC
search path. Or is there something else I'm missing?

The system is RedHat Linux 5.0 perl 5.004_04 mod_perl 1.15 and Apache
1.3.0


Any help is appreciated.



Cheers,

Jeff


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

Date: Thu, 24 Sep 1998 20:04:46 +0200
From: Sevo Stille <sevo@inm.de>
Subject: Re: mod_perl problem
Message-Id: <360A89BE.4807FBEC@inm.de>

Jeff Beard wrote:

> [Thu Sep 24 10:20:47 1998] [error] Can't locate Apache/Registry.pm in
> @INC (@INC contains: /usr/lib/perl5/5.005/i586-linux
> /usr/lib/perl5/5.005 /usr/lib/perl5/site_perl/5.005/i586-linux
> /usr/lib/perl5/site_perl/5.005 . /usr/local/apache-fp/
> /usr/local/apache-fp/lib/perl) at (eval 3) line 2.

> The problem is that Apache/Registry.pm is in /usr/lib/perl5/site_perl
> where everything else is and has been. I've tried adding the following
> to the scripts:
> 
> use lib '/usr/lib/perl5/site_perl' ;
> 
> That didn't work. So, I'm wondering where else can I change the @INC
> search path. Or is there something else I'm missing?

Looks like an installation problem to me. Make sure you have built
mod_perl entirely with only one perl version - installing the necessary
perl libs with one perl binary and building the apache module with
another may lead to the problems you described, if the perl versions
have differing library paths. You can add the missing lib paths to @INC,
but I'd strongly advise to fix the problem and build a consistent perl
library tree.

Sevo

-- 
Sevo Stille
sevo@inm.de


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

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

George Reese <borg@imaginary.com> wrote:
: Inner classes should be avoided like the plague for the most part.

	IYO, of course.

	Please be carful not to phrase your opinions as declarations,
	at least without sighting proof.

: The only exceptions I would make would be for event handlers that do
: not provide any external access to their containing class.

	Eg, anything that might even remotely look like a closure.

	God forbid Lisp programmers work in Java. :-)

: Not only are inner classes an ugly kludged,

	See, we can agree.  Inner classes are (IMHO), a major kluge.

	-Java (IMHO) really should have made everyone's life easier
	and just supported real closures. :-}

: they allow priveledged package
: level access to the private members of their containing class.

	In the functional programming paradigm this is considered a
	feature.  Beyond that, it is a form of encapsulation.  Not object
	based encapsulation of course, but encapsulation none the less.

-- 
-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: 24 Sep 1998 17:24:08 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Perl & Java - differences and uses
Message-Id: <906657807.94332@thrush.omix.com>

droby@copyright.com wrote:
	>snip<
: Really, this thread should have ended three weeks ago when it started.

	But if it had, I would not have all the great little quotes for my
	.sig that George has been so kind to offer me. ;-)

-Zenin

-- 
You are bordering on ridiculous if you think you need to support your
premises.  Such an argument is an infinite regression.
  -- George Reese in <wv0O1.1521$Ge.4809664@ptah.visi.com>


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

Date: 24 Sep 1998 17:28:41 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Perl & Java - differences and uses
Message-Id: <906658079.700858@thrush.omix.com>

Xavier Cousin <cousin@ensam.inra.fr> wrote:
: Behavioral questions : Is this kind of exchange often in this group ?
: (yes i'm a recent subscriber)

	Only when the thread is cross posted to the *.java.* and/or
	*.python.* groups. :-)

: WWW questions : Isn't this slowing the net ?

	Huh?  The Web != The 'Net, despite any claims AOL and friends
	like to make.

	In any event, a single "Best viewed with <insert bloated browser>"
	graphics on someone's web page does far more to "slow the net".

-- 
-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: 24 Sep 1998 08:28:23 -1000
From: Joseph Allen Dane <jdane@hawaii.edu>
Subject: Re: Perl & Java - differences and uses
Message-Id: <291zp1l60o.fsf@honlab.nmfs.hawaii.edu>

Zenin <zenin@bawdycaste.org> writes:

 [ closure stuff ]

> 
> 	Java can not do this.  Not with interfaces, inner classes, or
> 	anything else (well, except for JPL <evil grin>).
> 

Are you sure about this?  Look at the following and tell me what makes
it different from what you are talking about above.

public interface printer {
    void print();
    void set(int n);
}

public class closure {

    public closure() {}

    public printer closureMaker(int num) {
	final int pnum = num;
	return new printer() {
	    int foo = pnum;
	    public void print() {
		System.out.println(foo);
	    }
	    public void set(int n) {
		foo = n;
	    }
	};
    }

    public static void main(String args[]) {
	closure c = new closure();
	printer p10 = c.closureMaker(10);
	printer p20 = c.closureMaker(20);

	p10.print();
	p20.print();

	p10.set(15);
	p10.print();
    }
}
    
Which produces

10
20
15

as output.

Admittedly, the syntax required above is nasty, but unless I'm missing
something it does what you say can't be done in Java.

> 	Now for George, please show us how this aspect of lambda functions
> 	(*not* function/method pointers) can be replicated in an OO framework.

In fact, the interactions between the OO system and the lexical name
resolution required for the closures above to work are partly to blame
for the heinous syntax, from what I gather.

-- 

joe


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

Date: Thu, 24 Sep 1998 10:42:10 -0700
From: "Felix S. Gallo" <fsg@newsguy.com>
Subject: Re: Perl & Java - differences and uses
Message-Id: <6ue03t$49a@enews4.newsguy.com>

DRoby writes:
>[I, Felix, write:]
>> 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.

On that I disagree.  Maybe more than most, this thread has had a
very high educational content -- both sociological and academic.

On the sociology axis, anyone who's read the whole of the thread
now understands Internet Flamewar Rule Number Twelve: if you
simply have no clue, don't pretend you do.  Perhaps some young
impressionable kindling wannabe, learning from the example of
George Reese, will now go learn something before posting --
a positive result, wouldn't you agree?

Academically, the very exact and logical ripostes by the various
people who have dropped the rhetorical gloves on George have
been top notch examples of how to think, and even argue.  As
long as one can slog through the unhappy quagmires of George's
blathery thought processes, one can find interesting points here.

Speaking from a personal point of view, this thread is also
very, very funny to those of us with a certain cynically skewed sense
of humor.  George's graceless pratfalls bring on a certain
schadenfreude.  Maybe it's cruel, but more than once I've enjoyed
several minutes of laughter while having breakfast.  Sure beats
trying to decipher some newbie's CGI script question.

Felix
p.s. all of comp.lang.perl.misc's daily output would fit into a single
HTML page containing several banners and ads; so one hopes
that nobody out there believes that this 'slows down the web'.




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

Date: Thu, 24 Sep 1998 17:50:42 GMT
From: steven_elias@ml.com (Stephen Elias)
Subject: Perl & Redirecting STDIN & NT
Message-Id: <360a8401.77212435@news.ml.com>

Hello,

I'm using the following version of Perl under NT 4.0

This is perl, version 5.005_02 built for MSWin32-x86-object

Copyright 1987-1998, Larry Wall

Binary build 502 provided by ActiveState Tool Corp.
http://www.ActiveState.com
Built 10:59:41 Aug 11 1998

It appears STDIN isn't working as I had expected with Perl. I'm trying
to redirect (from STDIN) a single line.

I have a file named, driver.txt which contains :

   STDIN Perl Test

I have a Perl program named stdin.pl

 $my_var = <STDIN> ;
 print("Test Line\n") ;
 print($my_var) ;

I run: stdin.pl <driver.txt   & the output is:

Test Line


So, what happened to the file ???

I should point out, running the program, and typing from the keyboard
works fine as seen in this output

Test Line
I can type  --- * note this line is entered directly from the keyboard
I can type

Thanks





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

Date: Thu, 24 Sep 1998 16:36:58 GMT
From: droby@copyright.com
Subject: Re: Poll: How Did You Learn Perl?
Message-Id: <6udsfb$ian$1@nnrp1.dejanews.com>

In article <6udgv1$mm9$1@csnews.cs.colorado.edu>,
  tchrist@mox.perl.com (Tom Christiansen) wrote:
> :. Other book (give name)
> K&R?

Good point.  Building on prior knowledge is a big part of learning anything.

Learning to think logically and solve problems goes back to kindergarten at
least.	How to put blocks together so that they stay up or at least fall down
in an interesting way...

I guess that means I've been at it something over 40 years.  I'm not done yet
either.

> --
> "People think it must be fun to be a super genius, but they don't
>  realize how hard it is to put up with all the idiots in the world."
> 	--Calvin
>

Excellent sig!

--
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 16:43:48 GMT
From: wtm001@anadarko.com (Will Morse)
Subject: Re: Poll: How Did You Learn Perl?
Message-Id: <Ezsrt2.CzA@anadarko.com>


I had two or three scripts from studying example code, then bought
the first Camel book.  Most of the scripts I have written up
until recently have been fabulously helpful, but not really terribly
complicated or used very much obscure commands.  That has recently
changed a little as I wrote a program using sockets and hashes
of lists recently, which I pretty much learned out of the second
Camel book.

I have had my students buy the Learning Perl book, which ever
was available at the time, but I myself didn't find anything
I hadn't already known.  My class is focused on solving scientific
problems with perl, rather than a general perl programming class.

Hope this helps

Will

John Porter (jdporter@min.net) wrote:
: Matt Knecht wrote:
: > 
: > Jonathan Feinberg <jdf@pobox.com> wrote:
: > >It really depends on your learning style. I'll wager that most of the

  snip 

: So here's a poll for everyone.

: From what resource(s) did you learn Perl?

: . Llama v.1
  snip 


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

Date: 24 Sep 1998 10:38:11 -0700
From: larry@kiev.wall.org (Larry Wall)
Subject: Re: Poll: How Did You Learn Perl?
Message-Id: <6ue023$t1h@kiev.wall.org>

In article <360d0c81.58155423@thunder>,
David Cantrell <NukeEmUp@ThePentagon.com> wrote:
>On 23 Sep 1998 11:25:18 -0700,
>  larry@kiev.wall.org (Larry Wall) enlightened us thusly:
>
>>In article <360923EC.8E9919D0@min.net>, John Porter  <jdporter@min.net> wrote:
>>>From what resource(s) did you learn Perl?
>>
>>I dunno how I learned it.
>
>From the source code?

Hmm, doubtful.  The source code generally wasn't there when I needed it.

Larry


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

Date: Thu, 24 Sep 1998 13:27:03 -0500
From: "Charlene Wroblewski" <danw@execpc.com>
Subject: Re: Poll: How Did You Learn Perl?
Message-Id: <6ue2r7$s3c$1@news2.alpha.net>

I actually have used Perl for two projects.

One project was to fill in a Post Script Windows Word doc Template on a HPUX
box.  (Lots of fun - edit doc on Windows.  Copy doc printed file to HP.  Run
perl script.) - Actually only modified working code.  (Much easier)

Second project was a simple one for a co-worker to count files in a
directory.

Hopefully, soon I will have a grand time converting DCL scripts to perl on a
VMS system for a UNIX upgrade!  (Any conversion scripts available - just
kidding! - I KNOW to look first before asking!)


Ilya Zakharevich wrote in message
<6ubheq$k3m$1@mathserv.mps.ohio-state.edu>...
>[A complimentary Cc of this posting was sent to John Porter
><jdporter@min.net>],
>who wrote in article <360923EC.8E9919D0@min.net>:
>> . Llama v.1
>> . Llama v.2

This was great!  - Also going through the Win32 version.
>> . Camel v.1
>> . Camel v.2
Own it, but have not really opened it!
>> . Other book (give name)
Also Own Advanced Perl Programming - not opened yet!
>> . Docs included in the distribution
Have consulted these.
>> . Something on the WWW
Lots of neat stuff in clpm!
>> . Studying existing code
>> . Class/tutor
>
>o Excellent perl4 manpage
>o Excellent (but extremely buggy) perl5 source code (+ Emacs macros to
>  browse it).
>
>(bugginess is what forces you to look there).
>
>Ilya




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

Date: Thu, 24 Sep 1998 10:28:03 -0700
From: Joe Spinney <jspin@csd.sgi.com>
Subject: portable open()
Message-Id: <360A8123.620ED8ED@csd.sgi.com>

Hello,

I'm writing a utility that needs to open files for reading and writing.
To make it portable, I was wondering the Windows equivalent to the
following:

open(FILE, "< file_name");    # read

and

open(FILE, "> file_name");        # write


thanks...
--Joe




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

Date: 24 Sep 1998 13:16:31 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Q: Picking an element from a hash (not knowing which!) [Zorn's lemma?]
Message-Id: <6udupf$2c5$1@monet.op.net>

In article <6udj6m$6qj$1@nnrp1.dejanews.com>,  <droby@copyright.com> wrote:
>Actually, the description she gave was the Axiom of Choice.  

Actually, it wasn't.  AC is not about selecting an element from a set.



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

Date: Thu, 24 Sep 1998 14:53:09 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Q: Picking an element from a hash (not knowing which!) [Zorn's lemma?]
Message-Id: <360A9514.E23EBF65@min.net>

Ronald J Kimball wrote:
> 
> John Porter <jdporter@min.net> wrote:
> 
> > Andrea Spinelli wrote:
> > >
> > > if ( $#a < 0 ) {
> > >     my ($k,$v) = each %h;
> > >     @a = ($k);
> > > }
> >
> > This is an excellent way of doing it -- as long as you
> > truly don't care how the element is chosen.
> > If you actually need randomness, then you could do
> > something with keys() and rand().
> 
> And as long as you don't care if @a is assigned the list (undef) if the
> each iterator for %h happens to be at the end of the hash...

Oh, you're right.  Need to reset the iterator (which might upset
other things, I realize...)

  unless ( @a ) {
      scalar keys %h;
      @a = each %h;
      pop @a;
  }

-- 
John "Many Jars" Porter


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

Date: Thu, 24 Sep 1998 17:13:49 GMT
From: rockwell@shr.dec.com
Subject: require statements cause netscape server errors
Message-Id: <6udukc$kos$1@nnrp1.dejanews.com>

whenever I try to use a require statement in a perl script, on my netscape
enterprise server 3.0, I get back the "Server Error" page, and the error log
has the invalid headers code

[24/Sep/1998:12:56:47] failure: for host ..... trying to GET
/scripts/require.pl, cgi-parse-output reports: the CGI program
C:\Perl\bin\perl.exe did not produce a valid header (program terminated
without a valid CGI header (check for core dump or other abnormal
termination)

Perl otherwise works well there. All that is need to get good execution of the
hello world script below is to comment out the require statement.

I can take the script and its require to another system running IIS and it
works fine (I normally would expect the opposite behavior).

perl is activestate build 316. system is NT4.0-SP3

any ideas how a require statement can mess up headers? Its related to Netscape
cause the program runs fine at console (yes it finds the require'ed file in
the same directory, and the scripts directory is wide open.)...

thanks in advance...here is simple case which fails

<XMP>
use strict;
require 'SDwebTool.pl';
use vars qw($footer);
print "Content-type: text/html\n\n"; # Must be present for html to work.


print "<!DOCTYPE HTML PUBLIC \"-//W3O/DTD HTML//EN\">";
print "<HTML>\n";
print "<HEAD>\n";
print "<TITLE>Hello World</TITLE>\n";
print "</HEAD>\n";
print "<H1>Hello World</H1>\n";
print "<BR>$footer\n";
print "</HTML>\n";
</XMP>

-----== 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 1998 18:38:23 GMT
From: "Sean Scannell" <dundee@dnai.com>
Subject: Retrieve cgi results to file rather than to display
Message-Id: <01bde7ea$a51dd080$52c9b5cf@fritz.ccnet.com>

I want to run a script using crontab to periodically send form data to a
cgi.  Then I want to retrieve those results to file rather than display so
I can perform text searching.  How do I do this?  



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

Date: Thu, 24 Sep 1998 18:01:13 GMT
From: steven_elias@ml.com (Stephen Elias)
Subject: Re: Trouble with ActiveState Perl on WinNT Workstation 4.0SP3
Message-Id: <360b8892.78381226@news.ml.com>

Works great on my machine.

Check your system variable PATH and rearrange it to put
C:\WINNT\SYSTEM32 in front.

Perhaps outlook is looking for dll's and it's taking longer to search
the PATH ???

Just a guess however



On Mon, 21 Sep 1998 12:30:58 -0400, "Zach Frey" <ztf@one.com> wrote:

>I just tried the ActivePerl release from ActiveWare, and I found an odd
>problem.  After installing and rebooting, I then tried to run Outlook 98
>(my normal email client), and it had become painfully, excruciatingly,
>unusuably slow.  (Yes, even more than usual.)  I uninstalled ActivePerl
>and Outlook returned to it's previous speed.
>
>Does anyone know what the problem is?  Is there a workaround?
>
>
>Thanks in advance,
>
>Zach Frey
>ztf@one.com
>



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

Date: Thu, 24 Sep 1998 16:57:10 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: Where to put cgi-lib.pl
Message-Id: <360A79E6.91EA220B@inlink.com>

I'll tell you where to put it.  ;-)  Just kidding!

If you are using a newer port of Perl, 5.004 or 5.005, CGI.pm should
already be on your system.  It is much more powerful that cgi-lib.pl and
I recommend using it.

If you are using an older version of Perl (upgrade it!), you can install
the CGI.pm module or if you still want to use cgi-lib.pl, I think the
most common place for it is in the cgi-bin directory.   At least that is
always where I keep it.

Try CGI.pm out.  It even has a mode that emulates cgi-lib.pl so you
really don't even need to learn anything new.

CGI.pm can be found at:
http://stein.cshl.org/WWW/software/CGI/cgi_docs.html


Good luck!
Brent
-- 
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$            Brent Michalski             $
$         -- Perl Evangelist --          $
$    E-Mail: perlguy@technologist.com    $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


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

Date: 24 Sep 1998 17:47:07 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Where to put cgi-lib.pl
Message-Id: <906659182.475435@thrush.omix.com>

Scratchie <upsetter@ziplink.net> wrote:
: Zenin <zenin@bawdycaste.org> wrote:
:
: : 	That said, if you really want/need to run cgi-lib.pl, run this
: : 	command:
:
: : 	cp cgi-lib.pl `perl -MConfig -e 'print $Config{sitelib}'`
:
: Or just put it in the same directory with your script.

	Nope, this won't work.  This would require that the web server
	actively chdir() to the directory containing the script before
	it executes it, which is not the case.

	There is the FindBin module that can work around this in some
	cases however, but why would you want to have to maintain umpteen
	copies of the same library when it could be put in a place that
	perl will look for it already?

-- 
-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 18:44:42 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: Where to put cgi-lib.pl
Message-Id: <uqwO1.689$_c5.6173971@news.shore.net>

Zenin <zenin@bawdycaste.org> wrote:
: :
: : Or just put it in the same directory with your script.

: 	Nope, this won't work.  This would require that the web server
: 	actively chdir() to the directory containing the script before
: 	it executes it, which is not the case.

It's worked that way on every webserver I've ever used. Which ones doesn't
this work on??

--Art

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


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

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

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