[10103] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3696 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 11 19:07:57 1998

Date: Fri, 11 Sep 98 16:00:22 -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           Fri, 11 Sep 1998     Volume: 8 Number: 3696

Today's topics:
    Re: #!/usr/bin/perl not working? (Gregory Spath)
    Re: buffer flushing (Larry Rosler)
        Cheap WWW Hosting - $1/MB/Month mh6225@my-dejanews.com
    Re: Have problem with import of global variables (Mark-Jason Dominus)
    Re: Have problem with import of global variables <jdf@pobox.com>
    Re: How do you shadow/replace a subroutine? (Jasmin F. Patry)
    Re: How do you shadow/replace a subroutine? (Bernard Cosell)
        How to determine if Application is in memory? (RonBo)
        Incrementing a Multi-dimensional Hash Array <kevin_skelton@mgic.com>
    Re: Incrementing a Multi-dimensional Hash Array (Matt Knecht)
    Re: Incrementing a Multi-dimensional Hash Array <ajohnson@gpu.srv.ualberta.ca>
    Re: Incrementing a Multi-dimensional Hash Array (Larry Rosler)
    Re: IO::File Permissions - Enlightened! (Tye McQueen)
    Re: multiple patern matches (Faust Gertz)
        passing an argument. nguyen.van@imvi.bls.com
    Re: passing an argument. (Mike Kozlowski)
    Re: Pattern substitution (David A. Black)
    Re: Pattern substitution dzuy@my-dejanews.com
    Re: Perl & Java - differences and uses (Mike Stok)
    Re: Perl & Java - differences and uses (Matt Knecht)
    Re: Perl & Java - differences and uses <zenin@bawdycaste.org>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 11 Sep 1998 22:27:49 GMT
From: gspath@NOSPAM.epix.net (Gregory Spath)
Subject: Re: #!/usr/bin/perl not working?
Message-Id: <z2H2FGLjexoj-pn2-DKS5U36FhBum@hobbes.epix.net>

On Fri, 4 Sep 1998 14:43:49, "Dennis M. Parrott" <dparrott@ford.com> 
wrote:

> depending on who set up the path for Andrew, it *may* have been left
> out on PURPOSE. I don't remember where I read it, but, there are some
> admins who consider having "." in the PATH as a security risk (and I 
> may not have the whole story here either -- it may well relate to the 
> position of "." in the PATH)
>  
> possibly some of our other more Unix-admin fluent readers could 
> confirm this...
>  
> all of this is a long way of saying that leaving "." is probably not
> due to a 'fruity reason'...
> 

I'll confirm the security thing.

Is the executable flag set on the file?




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

Date: Fri, 11 Sep 1998 14:12:07 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: buffer flushing
Message-Id: <MPG.106332056c64d11398979f@nntp.hpl.hp.com>

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

In article <35F9380E.C3EFF0DA@acad.stedwards.edu> on Fri, 11 Sep 1998 
09:47:42 -0500, Nathan Bell <nbell@acad.stedwards.edu> says...
> How do I get the output buffer to empty to a file without closing the
> file?

DejaNews for September 2, a thread on this.
 
http://x14.dejanews.com/getdoc.xp?AN=387243848&search=thread&threaded=1&C
ONTEXT=905548192.1108738119&HIT_CONTEXT=905548082.1108607011&hitnum=0

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


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

Date: Fri, 11 Sep 1998 21:50:36 GMT
From: mh6225@my-dejanews.com
Subject: Cheap WWW Hosting - $1/MB/Month
Message-Id: <6tc5vc$s2d$1@nnrp1.dejanews.com>

New!!!New!!!New!!!New!!!New!!!New!!!New!!!New!!!New!!!New!!!New!!!

No Frills Web Hosting
$1/Megabyte/Month
http://www.nofrills.clintondale.com

* Robust, efficient, UNIX servers
* High speed T-1 access
* Both FTP and WWW access included in the price
* Real Audio/Video support -  Put streaming video and audio online
* Easy account maintenance - increase/decrease your space, cancel your
  account, view usage statistics all online
* CGI, C, PERL, PHP 3.0 support
* Microsoft Frontpage extensions
* Your own private subdomain eg. <b>www.yourname.nofrills.com</b>
* Best of all - only <b>$1/Mb/month</b> with only a $2 minimum

http://www.nofrills.clintondale.com

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


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

Date: 11 Sep 1998 17:46:17 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Have problem with import of global variables
Message-Id: <6tc5n9$6lc$1@monet.op.net>

In article <m3vhmuo4uf.fsf@joshua.panix.com>,
Jonathan Feinberg  <jdf@pobox.com> wrote:
>"Alex Litvak" <alitvak@shrike.depaul.edu> writes:
>
>> I use this template.  Actually I think my problem is that I use my when I
>> initialize exported variables (they are global to begin with).
>
>Of course.  The my() builtin gives a name package scope, and nothing
>outside that package can ever refer to it.


There is no such thing as `package scope'.  Maybe you meant `file
scope'?  Consider:

        package A;
        my $v = 119;
        package B;
        print "v= $v\n";                # Prints `v= 119'.

But it's hard to guess what you meant, since you seem to be mistaken
anyway.  You said that nothing outside the package can ever refer to a
variable declared with `my', but that simply isn't so:

        package A;
        my $X = 119;
        sub import { 1 }
        sub xref { \$X }

Now you can say:

        use A;
        $xref = xref();
        print "X = $$xref\n";           # Prints `X = 119'.

You can clearly refer to a `my' variable from outside its scope if
you have some other way to figure out where it is.  The name `X' is
out of scope, but that doesn't matter if you have a reference to the
variable.

Also, more to the point of the original question, `my' variables are
exportable, just like package variables:

        package F;
        my $X = 119;
        sub import {
          my $caller = caller;
          *{$caller . '::X'} = \$X;     # Export $x into calling package
        }
        1;


Now you can say:

        use F;                          # Defines new $X variable
        print "X = $X\n";               # (prints `X = 119')

The scope of the name of a my variable is from the point of
declaration to the end of the file or the end of the smallest
enclosing block.  But the name that a variable was declared with is
only one of several ways to access the variable.  It might have other
names that were created with the exporting process, or you might have
a reference to it somewhere.  These will access the variable even
outside the scope of the original name.



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

Date: 12 Sep 1998 00:24:24 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Have problem with import of global variables
Message-Id: <m367eus2xz.fsf@joshua.panix.com>

mjd@op.net (Mark-Jason Dominus) writes:

> Jonathan Feinberg  <jdf@pobox.com> wrote:
> >Of course.  The my() builtin gives a name package scope, and nothing
> >outside that package can ever refer to it.
> 
> 
> There is no such thing as `package scope'.  Maybe you meant `file
> scope'? 

Indeed; I was asleep at the switch.

> But it's hard to guess what you meant, since you seem to be mistaken
> anyway.  You said that nothing outside the package can ever refer to a
> variable declared with `my', but that simply isn't so:

No; I said the *name* is inaccessible.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Fri, 11 Sep 1998 19:02:35 GMT
From: jfpatry@undergrad.math.uwaterloo.ca (Jasmin F. Patry)
Subject: Re: How do you shadow/replace a subroutine?
Message-Id: <Ez4vKC.nw6@undergrad.math.uwaterloo.ca>

In article <35f95ebb.593402808@ganymede.rev.net>,
Bernard Cosell <bernie@fantasyfarm.com> wrote:
>The kind of thing I'd like to do is have a 'require' file that
>includes definitions that "intercept" calls to a few routines in an
>already-existing program.  I've been trying to do something like:
>   *origfcn = \&fcn ;
>   *fcn = \&newfcn;
>That doesn't work [it gets me the proper result, but gets me a warning
>about redefining &fcn].  so I tried:

Actually, I think that this is OK. (By coincidence, I just posted a question
very similar to this one, because I was surprised that the above code actually
works.  But I think I now (sort of) understand what's going on when you
redefine a subroutine.)

I assume you're running with -w turned on, which is why you're getting the
warnings.  You can suppress the warnings by doing something like this:

    *origfcn = \&fcn;
    {
        local $^W = 0; # suppress warnings for this block
        *fcn = \&newfcn; 
    }
    # The value of $^W is now restored to its value before entering the block

HTH,
Jasmin Patry



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

Date: Fri, 11 Sep 1998 22:04:35 GMT
From: bernie@fantasyfarm.com (Bernard Cosell)
Subject: Re: How do you shadow/replace a subroutine?
Message-Id: <35fb9cc1.609283653@ganymede.rev.net>

On 11 Sep 1998 15:19:52 -0400, mjd@op.net (Mark-Jason Dominus) wrote:

} In article <35f95ebb.593402808@ganymede.rev.net>,
} Bernard Cosell <bernie@fantasyfarm.com> wrote:
} >... I've been trying to do something like:
} >   *origfcn = \&fcn ;
} >   *fcn = \&newfcn;
} >That doesn't work [it gets me the proper result, but gets me a warning
} >about redefining &fcn].  
} 
} There are two things happening here: Perl is redefining the
} subroutine, and it is also emitting a warning message.  You want it to
} redefine the function, but you don't want the warning message.

That's right...

} Sometimes warning messages are delivered inappropriately, but this is
} not one of those times.

That's what I didn't know....  The key bit of data that there *is*no*
"canonical" or "correct" way to do what I want, and so I actually need
to brute-force override the checking machinery...

} ..  It is strange that you should conclude from
} this that the function was not redefined, and ask `how do you replace
} a subroutine' when that is the part you are not having trouble with.
} Your real question is `how can I suppress the warning message?'

If you think about it a second, you'll realize that it isn't strange
at all: how am I to tell that there isn't some real problem or danger,
perhaps deep in the symbol table code or some such, lurking when you
do the redefinition the way I did?  I've actually grown rather
trusting of the -w/strict/taint checks and warnings from Perl and I
figure that programming in a way to keep all of that machinery happy
makes for fairly robust programs... hence, my first reaction when
getting a funny warning like that is not "how do I suppress the
warning message", but rather "what am I doing wrong, and what's the
"right" way to be doing whateveritis".

If this is true (that -w is just -wrong- in this situation and there's
no way to make it happy), it'll make the first and only time I've had
to do something real that couldn't be done in a perl-happy way.  Maybe
I just work on simple/baby stuff problems, but surprising as it may
seem the truth is that in writing a LOT of Perl code over the years,
I've -never-before- *had* to do the local $^W=0 hack.. I know how, but
I've managed to avoid the necessity... before now.

So I'll fix my code with the "local..." and not worry about it again,
but nonetheless I'm glad I asked [and I appreciate the advice].

Thanks!
  /Bernie\
-- 
Bernie Cosell                     Fantasy Farm Fibers
mailto:bernie@fantasyfarm.com     Pearisburg, VA
    -->  Too many people, too few sheep  <--


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

Date: Fri, 11 Sep 1998 20:22:03 GMT
From: snorjb@wnt.sas.com (RonBo)
Subject: How to determine if Application is in memory?
Message-Id: <35fa85c7.199471562@newshost.unx.sas.com>

I'd like to know if anyone has figured out how to determine if a
specific application or process is currently in memory?

I only have the application name (dsmcsvc.exe) and I don't have the
PID available to lookup.  

I looked and saw the Win32::Process module, but have no idea if or how
this can tell me if a specific application is currently running in
memory.

Thanks for any help or snippets. 


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

Date: Fri, 11 Sep 1998 15:10:22 -0500
From: Kevin Skelton <kevin_skelton@mgic.com>
Subject: Incrementing a Multi-dimensional Hash Array
Message-Id: <35F983AE.657E@mgic.com>

Hi, I have a file of user-id's and reports they have accessed.

user1,report1
user1,report1
user1,report8
user2,report3
user2,report8
etc....

I would like to create a report in Perl that would show me the users and
the number of times they have accessed any given report.

I know that I can increment a single hash array like this:

While (<FILE>) {
  ($userid,$reportid) = split(/,/);
   $total{$userid}++;
}

This would give me the total number of times a given user accessed ANY
report.  But how do I create a multi-dimensional array and print off the
totals for a given user for each report?

$total{$userid}{$report}++;
does not work.

perldsc did not appear to be any help.  What am I missing???

Thanks
Kevin


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

Date: Fri, 11 Sep 1998 21:18:16 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Incrementing a Multi-dimensional Hash Array
Message-Id: <ssgK1.77$VG5.769414@news2.voicenet.com>

Kevin Skelton <kevin_skelton@mgic.com> wrote:
>Hi, I have a file of user-id's and reports they have accessed.
> [snip]
>
>$total{$userid}{$report}++;
>does not work.

Funny, it should.  Anyway, see how different this appears from your
code.


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

my %total = ();

while (<DATA>) {
    chomp;
    my ($user, $report) = split /,/;
    $total{$user}{$report}++;
}

for my $user (keys %total) {
    print "$user\n";
    for my $report (keys %{$total{$user}}) {
        print "\t$report = $total{$user}{$report}\n";
    }
}

__END__
user1,report1
user1,report1
user1,report8
user2,report3
user2,report8

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


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

Date: Fri, 11 Sep 1998 16:28:31 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Incrementing a Multi-dimensional Hash Array
Message-Id: <35F995FF.37ED2B71@gpu.srv.ualberta.ca>

Kevin Skelton wrote:
> 
> Hi, I have a file of user-id's and reports they have accessed.
> 
> user1,report1
> user1,report1
> user1,report8
> user2,report3
> user2,report8
> etc....
> 
> I would like to create a report in Perl that would show me the users and
> the number of times they have accessed any given report.
> 
> I know that I can increment a single hash array like this:
> 
> While (<FILE>) {
>   ($userid,$reportid) = split(/,/);
>    $total{$userid}++;
> }
> 
> This would give me the total number of times a given user accessed ANY
> report.  But how do I create a multi-dimensional array and print off the
> totals for a given user for each report?
> 
> $total{$userid}{$report}++;
> does not work.

what does "does not work" mean? maybe you meant $reportid there? 
this works fine:

#!/usr/bin/perl -w
use strict;
my %hash;
while(<DATA>){
    chomp;
    my ($user,$report)=split /,/;
    $hash{$user}{$report}++;
}
foreach my $user (keys %hash){
    print "$user:\n";
    foreach my $report (keys %{$hash{$user}}){
        print "\t$report: $hash{$user}{$report}\n";
    }
}
__DATA__
user1,report1
user1,report1
user1,report8
user2,report3
user2,report8

hope it helps
regards
andrew


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

Date: Fri, 11 Sep 1998 14:57:26 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Incrementing a Multi-dimensional Hash Array
Message-Id: <MPG.10633c9c7c2e2ae09897a2@nntp.hpl.hp.com>

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

In article <35F983AE.657E@mgic.com> on Fri, 11 Sep 1998 15:10:22 -0500, 
Kevin Skelton <kevin_skelton@mgic.com> says...
> Hi, I have a file of user-id's and reports they have accessed.
> 
> user1,report1
> user1,report1
> user1,report8
> user2,report3
> user2,report8
> etc....
> 
> I would like to create a report in Perl that would show me the users and
> the number of times they have accessed any given report.
> 
> I know that I can increment a single hash array like this:
> 
> While (<FILE>) {
>   ($userid,$reportid) = split(/,/);
>    $total{$userid}++;
> }
> 
> This would give me the total number of times a given user accessed ANY
> report.  But how do I create a multi-dimensional array and print off the
> totals for a given user for each report?
> 
> $total{$userid}{$report}++;
> does not work.

Why not?  Maybe you forgot to chomp the $reportid.

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

my %total;

while (<DATA>) {
	chomp;
	my ($userid, $reportid) = split /,/;
	$total{$userid}{$reportid}++;
}

my $userid;
foreach $userid (sort keys %total) {
	foreach (sort keys %{$total{$userid}}) {
		print "$userid,$_: $total{$userid}{$_}\n";
	}
}
__END__
user1,report1
user1,report1
user1,report8
user2,report3
user2,report8

Output:

user1,report1: 2
user1,report8: 1
user2,report3: 1
user2,report8: 1

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


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

Date: 11 Sep 1998 12:32:47 -0500
From: tye@fiinix.metronet.com (Tye McQueen)
Subject: Re: IO::File Permissions - Enlightened!
Message-Id: <6tbmrv$8ij@fiinix.metronet.com>

Bill 'Sneex' Jones <sneaker@sneex.fccj.org> writes:
) my $fh = new IO::File $file, O_APPEND, 0600;

O_APPEND is just a modifier and O_RDONLY is usually 0 so
C<O_APPEND> is the same a C<O_RDONLY|O_APPEND> and O_APPEND
only changes what happens when you write which you can't
do with O_RDONLY so C<O_APPEND> is the same as C<O_RDONLY>.

Basic modes:
    O_RDONLY	Read-only access
    O_WRONLY	Write-only access
    O_RDWR	Read and write access (*not* O_RDONLY|O_WRONLY)

Modifiers:
    O_APPEND	Seek to EOF on each write (ignored if you never write)
    O_CREAT	Create if doesn't exist (ignored if file exists)
    O_TRUNC	Truncate if file exists (ignored if file doesn't exist)
    O_EXCL	Fail if file exists (useless without O_CREAT)

So the sensible combinations are:

    Exactly one of:
	O_RDONLY
	O_WRONLY
	O_RDWR
	O_WRONLY|O_APPEND
	O_RDWR|O_APPEND

    Combined with nothing or one of the following:
	O_CREAT
	O_TRUNC
	O_CREAT|O_EXCL
	O_CREAT|O_TRUNC

And that includes some combinations that are hard to justify using.
But I also wouldn't be surprised if I made a mistake or two above --
I had hard time coming up with those lists [no coffee this morning].
-- 
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)


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

Date: Fri, 11 Sep 1998 20:15:02 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: multiple patern matches
Message-Id: <35f9828e.467639@news.wwa.com>

On Fri, 11 Sep 1998 16:38:22 GMT, syarbrou@ais.net (Steve .) wrote:

>I have a variable called $ip which holds the obvious an ip address.  I
>want to see if it matches any one of a group of addresses.
>
>I have 
>
>if ($ip =~ /123.933/)
>  {
>    bla bla bla
>  }
>
>but I also want it to check if it matches 203.543.12.54 and anything
>in 205.123.  I can do this with a bunch of or statements, but figured
>there was an easier way.  

See perlfaq6, "How do I efficiently match many
regular expressions at once?" and _The Perl Cookbook_ '6.10: Speeding
Up Interpolated Matches'
<http://perl.oreilly.com/cookbook/day2_2.html> for some suggestions.

>didn't know if /[123.933][205.123][203.543.12.54]/ would work or not.

It will work, but it won't do what you think it is doing.  See perlre,
perlfaq6, the chapter on regular expressions in Joseph N. Hall's book,
_Effective Perl Programmming_
<http://www.effectiveperl.com/EP.04.pdf>,  and Tom Christiansen's
'PERL5 Regular Expression Description'
<http://language.perl.com/all_about/regexps.html> for more
information.


Streben nach Wahrheit

Faust Gertz
Philosopher at Large



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

Date: Fri, 11 Sep 1998 22:19:43 GMT
From: nguyen.van@imvi.bls.com
Subject: passing an argument.
Message-Id: <6tc7lv$tqi$1@nnrp1.dejanews.com>

Hi guys,

I have a problem with passing an argument. I write a perl script with a input
like this : "1998/08/23-1998/08/24". In this script, I also call a korn shell
script which has the same in put as the perl script (i.e
1998/08/23-1998/08/24). But somehow, I guess the korn shell didn't recieve
the input. Any body knows why. The following is the part of my codes:

chomp($DATE = <STDIN>);
$DATE = shift;
`browser_crno.ksh $DATE > $DOCS_DIR/browser_crno.html`;

Note: I used backstick b/c I want a output.

My output from korn shell is looking good but $DATE variable didn't show up. I
did try to echo it to a temp file but the temp file never showed up. Your help
is highly appreciated.

Van


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


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

Date: 11 Sep 1998 22:46:24 GMT
From: mkozlows@guy.ssc.wisc.edu (Mike Kozlowski)
Subject: Re: passing an argument.
Message-Id: <6tc980$16vo$1@news.doit.wisc.edu>

In article <6tc7lv$tqi$1@nnrp1.dejanews.com>,  <nguyen.van@imvi.bls.com> wrote:

[There's nothing in the $DATE variable!]

>chomp($DATE = <STDIN>);
>$DATE = shift;

Consider that second line long and hard, and ask yourself what conceivable
purpose it could serve.

-- 
Michael Kozlowski                                        mlk@cs.wisc.edu
Recommended SF (Updated 8/6):   http://www.cs.wisc.edu/~mlk/sfbooks.html


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

Date: Fri, 11 Sep 1998 16:09:12 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: Pattern substitution
Message-Id: <6tc018$1pe$1@earth.superlink.net>

Hello -

cberry@cinenet.net (Craig Berry) writes:

>: 2. then I tried using the substituion routine
>:     $new_url = ~ s/$./ /;
>: 
>: It also doesn't work. Can anyone please help me on this. 

>That's wrong three, possibly four ways:

>0. The binding operator is =~, not '= ~' as you have it.
>1. You want to match a period before end-of-line, not after, right?
>   So the pattern is backward.

Moreover, $. will match $INPUT_LINE_NUMBER - so there could be some
really strange results.  Call it 4-1/2 ways of being wrong :-)


David Black
dblack@saturn.superlink.net


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

Date: Fri, 11 Sep 1998 21:51:09 GMT
From: dzuy@my-dejanews.com
Subject: Re: Pattern substitution
Message-Id: <6tc60d$s30$1@nnrp1.dejanews.com>

In article
<Pine.OSF.3.96.980911110228.23929A-100000@hilbert1.ms.washington.edu>,
  Meenu <meenu@ms.washington.edu> wrote:
> I have following URL
>        www.aol.com.
> and what I need to do is delete the (period at end) meaning make it
>        www.aol.com
>
> 1.  I tried using Chop & chomp.. how ever it doesn't work. Can anyone tell
>    me why it doesn't work?
> 2. then I tried using the substituion routine
>     $new_url = ~ s/$./ /;

	You almost got it right:

	$url = "www.aol.com."
	$url =~ s/.$//;		# Get rid of the last .
>
> It also doesn't work. Can anyone please help me on this.
> Thanks
>
>

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


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

Date: 11 Sep 1998 20:03:45 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Perl & Java - differences and uses
Message-Id: <6tbvn1$g48@news-central.tiac.net>

In article <3oeK1.950$E9.3226998@ptah.visi.com>,
George Reese  <borg@imaginary.com> wrote:

>I agree that perl does not want to have clean syntax--in fact, that is
>really what it supporters tend to think is so cool about it.  My point
>is that while that may help the short term productivity of an
>individual perl developer, it hurts long term maintainability and thus
>no coherent argument can be made to support such a language.

There's nothing in perl's syntax which stops a programmer writing
maintainable code.  While rigid indentation rules and "clean" syntax,
whatever that means, might lead to neatly laid out and regimented code
it's still up to the programmer or local coding standards to make sure
that "higher level" maintainability is maintained.  This includes things
like adhering to local variable naming and commenting guidelines - I have
had a couple of good experiences with peer reviews of my perl code from
people unfamiliar with perl.

The maintainability of the code reflects more on the programmer than the
language they're using.  Neatness and "cleanness" mean squat if the code
is littered with ill-named variables and misleading comments.

Perl offers me really good short term productivity, and in the saved time
I can make sure that supporting docs and test cases and code reviews are
up to date (or being lined up) which helps the code's long term
maintainability.

There's more to a language than its syntax.  Perl fits some people's way
of thinking very well.  I suspect that there are as many opinions about
the relative merits of languages as there are people thinking about it.  I
don't rhink OO or clean syntax is a big deal for the projects I work on,
convenient - yes.  

A language feature some consider a strength may be viewed by others as a
weakness.

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Fri, 11 Sep 1998 20:08:55 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Perl & Java - differences and uses
Message-Id: <rrfK1.63$VG5.734654@news2.voicenet.com>

George Reese <borg@imaginary.com> wrote:
>: Because I love Perl!  It's reminded me why I got into this field.  It's a
>: joy to program in.  As you said before "It's my pet language".  It may
>: not be rational or logical (The statement, not the language), but man I
>: love it!
>
>I am sorry, I fail to see how a language is something one should get
>emotionally atatched to.  Either it is the best tool for the job, or
>it isn't.

Well, I guess it can't be explained, then.  I know it's irrational to be
emotionally attached to a language, but it's hard not to be.  Perl is
*fun* to program in.  It's made my job fun again.  To me, Perl is the
best for any job that doesn't require the speed of C.  Perl has also
made me vastly more productive in what I can can accomplish.

>In order to read perl code, you have to understand a lot more than the
>basics of the language--you have to understand the programming style
>of the original author.

This is the exact reason I love seeing others people's code.  It's like
reading a new book.  They take the same rules, and semantics, and use
them in different ways.  I don't need to know their style.  It's
apparent from the way the use the language.  The differences in use
actually help to highlight what's going on.

Of course, all this goes out the window if the original programmer was
an idiot, but that's true in any language.


Anyway, I've probably mispoken enough about Perl in these last few
messages to last me a lifetime.  I have nothing left to add until I
actually start learning Python.  And if it's a tough language to learn,
I'll be sure to troll through comp.lang.python plenty! :)

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


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

Date: 11 Sep 1998 22:33:51 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Perl & Java - differences and uses
Message-Id: <905553026.251116@thrush.omix.com>

bjohnsto_usa_net@my-dejanews.com wrote:
        >snip<
: Given the way that current databases work, an applications which requires each
: user to hold a database connection will not scale.
: Since this is well known and application which is required to scale should not
: be architected this way.

        Exactly my point.

: However Database vendors could enable simpler architectures to scale better
: by by changing the limitations of their implementations.

        Sure, they could provide a new TCP/IP stack for every system they
        run on and write there server code in assembly so that large numbers
        of connections would not require as much memory. :-)

: Instead they have
: created requirement to pool connections and diverted some of their potential
: revenue to products which provide this service.

        Some would call this modular programming.  There is nothing
        inheritably wrong, non-scalable, or non-maintainable with
        multi-tier designs.  Are you saying this should be part of the
        core server, or the server should ship with such a tool as
        standard?  Maybe so, maybe not.

        There are a large number of middleware/application server
        systems that would actually *suffer* if forced to go through
        such a layer.  Such a completely generic pool server/system
        interface would only be useful to the simplist of designs.

: >         That's the key, low volume.  One can easily write low volume inetd
: >         servers in shell script.  If you're only doing low end server work,
: >         they pretty much any language and/or code design will work.
: A common mistake that many involved in a specialized area of computing
: science is to assume all other aspect of the trade are simple.

        Another aspect?  Are we not both talking about server code?  We're
        not talking about what the server actually does (as that could
        be anything), we're talking about how the server management
        code is designed.

: People with a large number of users assume that those with a lower number of
: users can get by with any language, like shell script.

        For the internal server management code, they likely can.  For
        whatever work the server is actually there to do, that's another
        topic.

: >         Yes.  They are sponsored by the memory and CPU manufactures, I'm
: >         sure of it.  Personally, I feel people should be required to test
: >         for a competency license before being allowed to use threads.  Of
: >         course, I feel the same way about USENET. :-)
: I have no real problem with asking for a bit more memory or CPU at todays
: prices if it saves on programmer time.

        That's the problem, they tell people it's only a bit.  And they
        are right, it is only a bit.  In most application code you can
        affort to give a bit here and there as it only is multiplied by
        one.  In server code, those little bits are often multiplied by
        the number of clients you're required to handle at any given
        point.  In a Java server, 3000 connections requires at least
        3000 threads just to start, simply because it can not muliplex
        IO at any level.  If the server needs to do almost anything
        interesting with other IO systems, each one of those threads
        will likely need to spawn at least one other thread.  6000 threads,
        not to mention the TCP stack overhead to of 3000 connections,
        would toast all but the largest servers.  We're not talking
        about a "bit" more RAM here, we're now talking in GIGs.

        This is why great application programmers more often then
        not create really, really bad server code.  The two worlds
        are completely and totally different.

: I agree on threads, however even those competent with threads will create more
: bugs by using them.  It is important to limit the amount of code which can
: potentially have concurrency bugs.

        I'm not worried about them for the sake of bugs, at least not
        in server code.  I'm worried about them for the extra system
        overhead costs.

: Oracle, and Web servers seems to run OK on NT.

        In lower level systems only.

: My experience with AIX servers here says they are slower than NT boxes that
: cost 1 tenth the price.

        I haven't worked with AIX myself.  Solaris, FreeBSD, BSDI, Linux,
        and yes NT are my primary domain.

        Bang for the buck, nothing can beat FreeBSD or Linux on x86
        hardware, but it doesn't scale.  It's not the system, it's the
        hardware.

        I've yet to see the NT box that can touch the mid to high end
        Sun boxes, and I'm nothing close to a Solaris fan.

: I suggest that working within the limitations of a tool, good solutions can be
: architected.

        It depends.  If the tools lack the primitives required to build a
        good architecture, you have to make do with kluges and then hope
        no one will ask you to scale them too big.  Thus is the case with
        NT and Java for server use.  Great for clients, trash for servers.

: >         Remember, if you've got 20 httpd children, you've got 20 cached
: >         database connections.
: I take it that the reason you have 20 children is because you don't have
: threads.

        Apache doesn't use threads under Unix, with good reason.  Unlike
        Win32 systems, context switching between processes is nothing close
        to as expensive and for long running servers memory leaks (either
        in the server or the operating system) can be minimalized.

        Even in a threaded system, you'd have to multiplex your database
        connections.  With some databases (ala Sybase or ODBC based
        driver) you even need to serialize all your queries through a
        particular connection.

        Theads have there place on nearly every general use system.
        On Unix however, they are best used for reducing memory
        requirements IMHO.  While you gain a few other nice features
        with threads, you lose features of processes.

: You could stick your development, and test boxes on different boxes or on
: different ports.
: But your point still holds.

        Yep, because it's at the database that the problem comes in.  The
        database machine doesn't care if the connections all come from
        one box or from 20.  It still has to allocate resources for all
        of them.

: Maybe the Java Web server would do OK.

        Maybe, but you'd need to jump through a lot of hoops to do
        it.  Bacically, you'd need some kind of secondary system in
        the server to handle the connection poll for you.  I'd personally
        rather have them talk to another middlewere server of some
        form, but that's me.  A monolithic server could work as well,
        but IMHO it would get pretty klugy pretty quickly.

: Many that exeed the bottleneck solve the problem by buying more hardware.
: We could run all our applications on two independent web servers, and no code
: would change.
:
: The database is the only limitation.

        It depends.  In some systems you can farm databases like one does
        Web servers.  Web server farms still have the bottleneck of the
        incomming proxy, as do most farmed services behind them such as
        databases.  It all depends on what you want to do and how big
        you want to do it.

: Please be more precise.  I have been working with relational databases for 8
: years.  I have always found that if I start from the assumption that any
: operation which hits a relational database 100000 times more expensive than
: getting some data from local memory my applications perform well.

        Agreed, completely.  Now if we could just get Oracle to run
        inside the system's L2 cache we'd have no more problems. :-)

        >snip<
: This is because using relational databases is slow.

        True, however.  Have you tried to do relational data queries
        without one?  With guaranteed transaction support?  Almost
        unlimited rollback support?  Relational databases do far more
        then just relate data.  As I mentioned before, if that's all
        one wanted from a database they'd use MiniSQL or MySQL and
        blow Oracle et al away in performance.

: >         Databases can
: >         more then keep up with the requirements of web and similar
: >         technologies.
: Only if you understand how slow they are and make sure you code around the
: performance problems that would otherwise result.

        However much people have tried to not fess up to it, this is the
        case for each and every single aspect of software engineering.

        In computer languages everyone feels they shouldn't have to
        think about how there code is actually going to be executed.
        That somehow the compiler writers are gods that will be able
        to take whaterver they write however they write it and execute
        it in the most efficient mannor to get that job done.

        They are all on crack.

        Anyone that does not understand what is happening underneath
        there code is guaranteed to write wasteful and slow code.  This
        is why I feel assembly, and assembly, should be a hard requirement
        for all CS and MIS courses of study.  They don't have to be great
        assembly programmers, they just need the basic concepts of memory
        stucture and low level program execution.

        >snip<
: Perl, Java are fast (C and C++ are very fast).

        Ya know, I've never quite seen it so well put before.

: CORBA I am not sure.

        No one is, and I don't think anyone really cares. :-)

: The perl task to mulge the data took 1 minute to code and a few seconds to
: run.
: The Oracle upload took ten minutes.  That is because relations databases
: are slow.
        >snip<

        Ouch!  There must be a missing piece here someplace.  Was the
        Oracle server or the machine it runs on under heavy load?  How
        much data are we talking about here?  Did it require something
        fireing off a procedure for every row you inserted?  Did you
        not commet any data until the entire upload was done?

        I'm just wondering because I've only seen this while importing
        or exporting very large tables.

-- 
-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: 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 3696
**************************************

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