[10505] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4097 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 28 21:06:19 1998

Date: Wed, 28 Oct 98 18:00:25 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 28 Oct 1998     Volume: 8 Number: 4097

Today's topics:
        [Q] on scope and my with foreach (Geoff Newton)
    Re: [Q] on scope and my with foreach <baliga@synopsys.com>
    Re: after gathering information through a form and prin <rootbeer@teleport.com>
        Another regexp help? (Doug O'Leary)
    Re: CGI.pm and 5.003 for win32? <rootbeer@teleport.com>
    Re: CGI.pm and 5.003 for win32? (Larry Rosler)
    Re: CGI.pm and 5.003 for win32? dturley@pobox.com
    Re: CGI.pm and 5.003 for win32? dturley@pobox.com
    Re: Checking Input for Exactly 2 numbers <r28629@email.sps.mot.com>
    Re: Database Search with Perl <rootbeer@teleport.com>
    Re: Date 2 Num (Steffen Beyer)
        Environment confusion Win32 Perl. <mikep@5circles.com>
    Re: Forcing perl to garbage collect (Ilya Zakharevich)
    Re: Is undef the best way to initialize a hash? <rootbeer@teleport.com>
    Re: leading spaces and pipes <ChintanA@worldnetcorp.com>
    Re: leading spaces and pipes (Martien Verbruggen)
    Re: leading spaces and pipes <r28629@email.sps.mot.com>
    Re: Monitoring a child process. (Charles DeRykus)
        new version of perldb.pl bobmorgan@my-dejanews.com
    Re: new version of perldb.pl <rootbeer@teleport.com>
    Re: Not to start a language war but.. <jorendorff@ixl.com>
    Re: Not to start a language war but.. <zenin@bawdycaste.org>
    Re: Not to start a language war but.. (Ilya Zakharevich)
    Re: Not to start a language war but.. <zenin@bawdycaste.org>
    Re: Not to start a language war but.. <zenin@bawdycaste.org>
        Perl how-to question <webmaster@topproducer.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 29 Oct 1998 00:00:24 GMT
From: gjn@hydra.itc.gu.edu.au (Geoff Newton)
Subject: [Q] on scope and my with foreach
Message-Id: <718b6o$r3i$1@kraken.itc.gu.edu.au>
Keywords: scope,my,foreach,camel


G'day. Well, I've been reading through the Camel book and came
across some fine print in one of the subscripts.

Chapter 2 (The Gory Details - Global Declarations) p.106

"* For esoteric reasons related to closures, lexicals, and the _foreach_
aliasing mechanism, these _my_ variables must not be the index variable of a
_foreach_ loop, because any named subroutine or format will only have been
compiled with the first binding."

Does this mean that I cannot do something like:

sub func {
	my $key;

	# I don't want to use each()
	foreach $key (keys %array) {
		func2($key);
	}
	foreach $key (keys %other_array) {
		func3($key);
	}
}

It seems to work...

Comments appreciated.

cheers,
gjn
--
 _-_|\  | Geoff Newton (gjn)               Email: g.newton@gu.edu.au
/     * | Network Engineer                 Phone: (61 7) 3875-6435
\_.-._/ | Information Technology Services  Fax: (61 7) 3875-6767
     v  | Griffith University              "It works for me"                


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

Date: Wed, 28 Oct 1998 17:11:02 -0800
From: Yogish Baliga <baliga@synopsys.com>
To: Geoff Newton <gjn@hydra.itc.gu.edu.au>
Subject: Re: [Q] on scope and my with foreach
Message-Id: <3637C0A6.4A82570B@synopsys.com>

I am using this format in many of my programs and I am not facing any kind of
problems because of this.

If anybody knows the dis-advantages of this, Please let me know..

ThanX and Regards,
-- Baliga

Geoff Newton wrote:

> G'day. Well, I've been reading through the Camel book and came
> across some fine print in one of the subscripts.
>
> Chapter 2 (The Gory Details - Global Declarations) p.106
>
> "* For esoteric reasons related to closures, lexicals, and the _foreach_
> aliasing mechanism, these _my_ variables must not be the index variable of a
> _foreach_ loop, because any named subroutine or format will only have been
> compiled with the first binding."
>
> Does this mean that I cannot do something like:
>
> sub func {
>         my $key;
>
>         # I don't want to use each()
>         foreach $key (keys %array) {
>                 func2($key);
>         }
>         foreach $key (keys %other_array) {
>                 func3($key);
>         }
> }
>
> It seems to work...
>
> Comments appreciated.
>
> cheers,
> gjn
> --
>  _-_|\  | Geoff Newton (gjn)               Email: g.newton@gu.edu.au
> /     * | Network Engineer                 Phone: (61 7) 3875-6435
> \_.-._/ | Information Technology Services  Fax: (61 7) 3875-6767
>      v  | Griffith University              "It works for me"



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

Date: Thu, 29 Oct 1998 00:12:50 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: after gathering information through a form and printing out response want to continue printing on the same page using a PERL script
Message-Id: <Pine.GSO.4.02A.9810281605090.3421-100000@user2.teleport.com>

On Wed, 28 Oct 1998, John Hardy wrote:

> Subject: after gathering information through a form and printing out response
    want to continue printing on the same page using a PERL script

What a subject! But didn't you ask this same question earlier today? Maybe
my earlier answer was unclear.

As far as I can tell, what you are asking for is something that Perl can
easily do. It's simply a matter of producing the right output at the right
time, after all.

"Simply," of course, IF the protocol you're implementing can do that.
That's a big "if". Probably, you're using HTML, HTTP, and CGI, to talk to
a browser from a server. The docs, FAQs, and newsgroups about those topics
should be able to help you more than a newsgroup about Perl can. Good
luck!

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



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

Date: 29 Oct 1998 01:20:39 GMT
From: dkoleary@wwa.com (Doug O'Leary)
Subject: Another regexp help?
Message-Id: <718ft7$qbk$1@hirame.wwa.com>

Hi;

I'm close, but I just can't seem to bust that \n barrier.  To make a long story 
short, HPUX has a command that will display all the disks on the system with 
the following format:

Class     I  H/W Path   Driver S/W State H/W Type Description
===============================================================
disk      5  0/4.2.0    disc3  NO_HW     DEVICE    TOSHIBA CD-ROM XM-5401TA
                       /dev/dsk/c0t2d0      /dev/rdsk/c0t2d0   
                       /dev/floppy/c0t2d0   /dev/rfloppy/c0t2d0
disk    162  0/52.1.0   disc3  CLAIMED   DEVICE    SEAGATE ST32550W
                       /dev/dsk/c6t1d0      /dev/rdsk/c6t1d0   
                       /dev/floppy/c6t1d0   /dev/rfloppy/c6t1d0

What I'm looking for is a hash with the h/w path as the key - eg:

$Hw{0/4.2.0} => /dev/dsk/c0t2d0.  

I can get this by running through the HPUX command twice - first time to get 
the hw paths, second time to get the disk names; however, I *know* there's a 
way to get them both with one run of the ioscan command.  

The short snippet of the code that I'm working with follows:

open (Scan,"ioscan -fun -C disk|") || die "Can't execute ioscan - $!";

while (<Scan>)
{ if ( 
m#(\w+\s+){2}(\d+/\d+\.\d+\.\d+)\s+(\w+\s+){3}(\w+)\s+\w+\n*(/\w+/\w+/\w+)#s)

#{ if ( m#(\w+\s+){2}(\d+/\d+\.\d+\.\d+)\s+(\w+\s+){3}(\w+)\s+\w+\n*#s)
   {  $Hw=$2;
      $Manu = $4;
      $Disk=$5;
      printf ("%-15s\t%-10s%s\n",$Hw,$Manu,$Disk);
   }
}

If I switch 'if' statements, it works - but I don't get the $Disk variable 
defined.  I've also tried switching the #s to #m's with no luck.  Any 
combination that I try to get the $Disk var defined, and the whole line doesn't 
match.  

I've been pounding my head against this wall for about five hours now.  Any 
help/tips would be greatly appreciated.

Doug O'Leary


-- 
------------
Doug O'Leary
Senior System Administrator
dkoleary@wwa.com
dkoleary@mayspeh.com
------------



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

Date: Thu, 29 Oct 1998 00:26:00 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: CGI.pm and 5.003 for win32?
Message-Id: <Pine.GSO.4.02A.9810281625020.3421-100000@user2.teleport.com>

On Wed, 28 Oct 1998, Brian P. Barnes wrote:

> The active state port is only at 5.003 (I just downloaded it yesterday).

Really? That's old. Well, you can get something _much_ newer from CPAN.
Look for the standard ("Sarathy") binary for Win32.

    http://www.perl.org/
    http://www.perl.com/

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



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

Date: Wed, 28 Oct 1998 16:57:34 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: CGI.pm and 5.003 for win32?
Message-Id: <MPG.10a15d55f2cc13a1989848@nntp.hpl.hp.com>

In article <Pine.GSO.4.02A.9810281625020.3421-100000@user2.teleport.com> 
on Thu, 29 Oct 1998 00:26:00 GMT, Tom Phoenix <rootbeer@teleport.com> 
says...
> On Wed, 28 Oct 1998, Brian P. Barnes wrote:
> 
> > The active state port is only at 5.003 (I just downloaded it yesterday).
> 
> Really? That's old. Well, you can get something _much_ newer from CPAN.
> Look for the standard ("Sarathy") binary for Win32.
> 
>     http://www.perl.org/
>     http://www.perl.com/

The 'download' page from there is rather out of date, as it still refers 
to a 5.003 release.  But the link takes you here:

http://www.ActiveState.com/ActivePerl/download.htm

where you will find a 5.005_02 release, now at build 506, October 27, 
1998.

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


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

Date: Thu, 29 Oct 1998 01:20:14 GMT
From: dturley@pobox.com
Subject: Re: CGI.pm and 5.003 for win32?
Message-Id: <718fse$3cu$1@nnrp1.dejanews.com>

In article <363784C5.92FF9096@dev.tivoli.com>,
  "Brian P. Barnes" <bbarnes@dev.tivoli.com> wrote:

> The active state port is only at 5.003 (I just downloaded it yesterday).
> Where can I get 5.004 binaries for windoz?
>
You need to go back to www.activestate.com

The current release is 5.005*

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 29 Oct 1998 01:20:10 GMT
From: dturley@pobox.com
Subject: Re: CGI.pm and 5.003 for win32?
Message-Id: <718fsa$3cs$1@nnrp1.dejanews.com>

In article <363784C5.92FF9096@dev.tivoli.com>,
  "Brian P. Barnes" <bbarnes@dev.tivoli.com> wrote:

> The active state port is only at 5.003 (I just downloaded it yesterday).
> Where can I get 5.004 binaries for windoz?
>
Ypou need to go back to www.activestate.com

The current release is 5.005*

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 28 Oct 1998 17:24:46 -0600
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: Checking Input for Exactly 2 numbers
Message-Id: <3637A7BE.CE5122D0@email.sps.mot.com>

brian d foy wrote:
> 
> In article <36376C1B.26C3B2CD@counter.w-dt.com>, Mike <support@counter.w-dt.com> posted:
> 
> > How would you check the input then to make sure it has exactly two
> > numbers inputed. Not more not less.
> 
> two numbers or one number with two digits?  if the latter, which base?

good question ;)

-tk


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

Date: Thu, 29 Oct 1998 00:00:45 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Database Search with Perl
Message-Id: <Pine.GSO.4.02A.9810281600050.3421-100000@user2.teleport.com>

On Wed, 28 Oct 1998 fcga@my-dejanews.com wrote:

> I'd like to obtain some information on how to do a perl program that
> searchs a database created with Access97.

It sounds as if you need to know how to access that kind of database. If
there's a module which does what you want, it should be listed in the
module list on CPAN. If you don't find one to your liking, you're welcome
and encouraged to submit one! :-)  Hope this helps!

    http://www.perl.org/CPAN/
    http://www.perl.com/CPAN/

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



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

Date: 28 Oct 1998 13:43:37 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: Re: Date 2 Num
Message-Id: <717729$gij$1@en1.engelschall.com>

Craig Pickles <pickles_c@hotmail.com> wrote:

> Thank anyway guys..... I gave in and wrote the subroutines myself :)

Instead of writing your own, you could have taken the C code of Date::Calc
and converted the relevant portions of it to Perl; this should be rather
easy.

Moreover, there is also Date::Manip on CPAN which is written entirely in
Perl, which might suit you better.

> It is a shame though I feel that there arent more routine archives out
> there (yes I know there are loads of module archives) but sometimes
> just a few lines of clever code would suffice, like in the early days
> of my career programming BASIC.

Have you looked at www.snippets.org?

> I wonder if there is any call for this type of resource? I might even
> think about setting one up..

See above.

HTH.

Yours,
-- 
    Steffen Beyer <sb@engelschall.com>
    Free Perl and C Software for Download: www.engelschall.com/u/sb/download/


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

Date: Wed, 28 Oct 1998 17:14:59 -0800
From: "Mike Pritchard" <mikep@5circles.com>
Subject: Environment confusion Win32 Perl.
Message-Id: <nkPZ1.1292$GZ6.3217@news14.ispnews.com>

This feels like it might be a dumb question - since I haven't been using
Perl for a while.

I'm porting a CGI script written for UNIX onto a WinNT machine (running
ActiveState Perl on IIS).  The script uses templates to write to logfiles
and email, and has examples using environment variables, including DATE_GMT.
When I tested, there was no value for DATE_GMT.

Since I didn't recall DATE_GMT as one of the environment variables from
scripts running on UNIX, I decided to check out the IIS configuration, and
also to run one of the old scripts that shows environment.  Confusion
increased.

The IIS documentation describes a number of variables accessible through
shtml using #echo including DATE_GMT, as well as some of the ones I'm
familiar with such as REMOTE_HOST.

The env.pl script prints out the keys & values from %ENV, but there doesn't
seem to be a good correlation between those keys and the IIS #echo
variables.

I could modify the script to figure out the date/time (and the result would
probably be more useful than the built in DATE_GMT) but that isn't the
point.  I'd like to stick to the ability to configure output using
environment variables, so I'd like to understand what is available and how
to access.

Thanks
Mike






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

Date: 29 Oct 1998 01:09:22 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Forcing perl to garbage collect
Message-Id: <718f82$3rc$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Tye McQueen
<tye@fohnix.metronet.com>],
who wrote in article <71885l$jug@fohnix.metronet.com>:
> I think there are several steps to be taken to reduce Perl's
> memory consumption before resorting to periodically searching
> for circular references that could be freed (which is what I
> think of first when I hear "garbage collection").  Freeing large
> buffers associated with lexicals and temporaries would be a
> good first step.

I would think that the first good step should be to never create big
buffers in temporaries ;-).  (Details later on p5p.)

About freeing buffers of lexical: the position of performance police
(but not imne) was that these big buffers have a good chance to grow
in small steps, so keeping them will save a lot of realloc()s.

Ilya

P.S.  I see no problems with Perl using garbage collection as far as

      a) refcounting is preserved, thus simple things go out of scope timely;
      b) it is not a general purpose GC, so it scans SV arenas only;


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

Date: Thu, 29 Oct 1998 00:21:43 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Is undef the best way to initialize a hash?
Message-Id: <Pine.GSO.4.02A.9810281616520.3421-100000@user2.teleport.com>

On Wed, 28 Oct 1998, Joseph Norris wrote:

> I have seen the following ways to initialize a hash:

In general, if you think you need to initialize a hash, you probably
aren't using lexical variables properly. That is, you're pounding with the
wrong end of the hammer. But, having said that...

> %my_hash = ( );

That sets %my_hash to have zero key/value pairs.

> %my_hash;

That does nothing but waste time. :-)

> undef  %my_hash;

That tells Perl to forget that %my_hash ever existed, as much as possible.

> I remember reading somewhere that the undef is better.

If you're going to use the hash again, you probably want to set it to the
empty list. If not, you probably want to undef it.

But, almost certainly, you really wanted a lexical hash in the first
place. Check out 'my' variables in the docs. Cheers!

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



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

Date: Wed, 28 Oct 1998 18:07:56 -0600
From: Chintan Adhyapak <ChintanA@worldnetcorp.com>
Subject: Re: leading spaces and pipes
Message-Id: <3637B1DC.282B2831@worldnetcorp.com>

Marcus J. Foody wrote:
> @field2 = split(/\|/,$prefix);
> 
> This takes out the pipe for me but leaves me with a space in front of
> the field as a result.
> 
> I would like to delete or truncate that space entirely.
> 
> If anyone has any ideas on how to first delete the leading pipe symbol,
> then delete the leading space left over.
> 
> thank you
> marcus

$prefix =~ s/^\|//; 	#Get rid of the pipe symbol
$prefix =~ s/^\s+//;	#Get rid of any leading spaces
$prefix =~ s/\s*$//;	#Get rid of any trailing spaces
-- 
________________
Chintan Adhyapak


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

Date: Thu, 29 Oct 1998 00:16:24 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: leading spaces and pipes
Message-Id: <stOZ1.14$vh5.59288@nsw.nnrp.telstra.net>

In article <3637AD58.7D72@idiom.com>,
	"Marcus J. Foody" <marx@idiom.com> writes:
> Hello, I have a field that has a pipe symbol as its first character I
> would like to get rid of the nasty pipe symbol.  The field that is given
> me problems is $prefix

nasty? Does it smell? :)

> Here is what I have:
> 
> @field2 = split(/\|/,$prefix);
> 
> This takes out the pipe for me but leaves me with a space in front of
> the field as a result.

Does $prefix contain something like: "stuff| more stuff", and you want
to really split, or does it contain something like "| stuff", and you
want to just get rid of the '|' and any whitespace following it?

To split on '|' with any possible whitspace around it:

@f = split( /\s*\|\s*/, $prefix );

To just get rid of the stuff at the beginning:

$prefix =~ s/^\|\s*//;

In case you don't know how to get to the documentation:

# perldoc perlre
# perldoc perlop
# perldoc perlfunc
# perldoc -f split

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


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

Date: Wed, 28 Oct 1998 18:36:10 -0600
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: leading spaces and pipes
Message-Id: <3637B87A.31748118@email.sps.mot.com>

Marcus J. Foody wrote:
> 
> Hello, I have a field that has a pipe symbol as its first character I
> would like to get rid of the nasty pipe symbol.  The field that is given
> me problems is $prefix
> 
> Here is what I have:
> 
> @field2 = split(/\|/,$prefix);
> 
> This takes out the pipe for me but leaves me with a space in front of
> the field as a result.
> 
> I would like to delete or truncate that space entirely.
> 
> If anyone has any ideas on how to first delete the leading pipe symbol,
> then delete the leading space left over.

delete it?? too much work. If you are not particular about memory usage,
try this:

($junk, @field2) = split(/\|/,$prefix);

Of course you can always undef $junk, if you even bother;

-tk


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

Date: Wed, 28 Oct 1998 23:57:55 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Monitoring a child process.
Message-Id: <F1KAKJ.586@news.boeing.com>

In article <F1K4MD.A1s@world.std.com>,
Andrew M. Langmead <aml@world.std.com> wrote:
>"Bowler, Michael (EXCHANGE:CRK:5T11)" <mkbowler@americasm01.nt.com> writes:
>
>>Ok, now how do I tell if the child has gone defunct?  The above still returns
>>true if this is the case.
>
>How about using waitpid() with the WNOHANG option. It will return the
>$pid of the process if the child has exited, and -1 if it has not.
>

Um, normally 0 if the child hasn't exited, or -1 if the
child has exited (ECHILD -- but also generated if EINTR, 
EINVAL).
 
Another possibility often: $SIG{CHLD} = 'IGNORE';


hth,
--
Charles DeRykus


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

Date: Thu, 29 Oct 1998 00:49:42 GMT
From: bobmorgan@my-dejanews.com
Subject: new version of perldb.pl
Message-Id: <718e36$nl$1@nnrp1.dejanews.com>

Hi,

  Does anyone know where I can get a new version of perldb.pl - debugging 
library for perl. The current version I have is patch level 0.94 for Unix/AIX
 4.1.4.

  I have not been able to find any new references to it on CPAN. Has it been
  updated or not ? Any tips appreciated.

  Also: If anyone uses the perl debugger, do you have any clues why I would 
be getting a message about 100 levels deep in recursion ? Can this be fixed ?

  Thanks,

  Bob Morgan
  bob.morgan@computer.org

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 29 Oct 1998 01:06:48 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: new version of perldb.pl
Message-Id: <Pine.GSO.4.02A.9810281705140.3421-100000@user2.teleport.com>

On Thu, 29 Oct 1998 bobmorgan@my-dejanews.com wrote:

>   Does anyone know where I can get a new version of perldb.pl

It comes with Perl. It's probably not a good idea to use one from a
different version of Perl than you have, though. So maybe you should
simply install 5.004 (or later) to get the new debugger, if that's what
you need.

>   do you have any clues why I would be getting a message about 100
> levels deep in recursion ? Can this be fixed ?

Have you seen what the perldiag manpage says about that message? Hope this
helps!

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



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

Date: Wed, 28 Oct 1998 18:50:20 -0800
From: Jason Orendorff <jorendorff@ixl.com>
Subject: Re: Not to start a language war but..
Message-Id: <3637D7EC.EEFE5E47@ixl.com>

> Mind if I ask what it is specifically about class creation in Perl
> that you find to be painful?

I have to come to Perl's defense (in my own indifferent way) on this
one.  The terms Perl uses are incomprehensible to non-Perl programmers,
but that's only typical:

  #Python
  class Widget(Frob):
      pass

  //C++
  class Widget : public Frob {
  };

  #Perl
  package Widget;
  @ISA = (Frob);
  sub new { bless {} }

When I read about this, I thought, "That's so bizarre as to be
practically unuseable," but apparently there's nothing so bizarre
that Perl hackers won't embrace it.  And I can respect that.
Seriously.

-- 
Jason
Python hacker and mediocre Perl hacker


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

Date: 29 Oct 98 01:05:58 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Not to start a language war but..
Message-Id: <909623452.948196@thrush.omix.com>

Dave Kirby <dkirby@see.sig.for.addr> wrote:
	>snip<
: Yes python is OO, and so is perl. However creating a class in perl is
: frankly a pain in the ass,

	Huh?  What ya been smoking?

		package Foo;
		sub new { bless {}, shift }

	Or even shorter:

		sub Foo::new { bless {}, shift }

	Want a sub class?

		package Bar;
		use base qw(Foo);

	Want that in a one liner?

		perl -e 'sub Foo::new { bless {}, shift }'

: so a lot of people stick to procedural
: programming in that language. If you want to learn OO techniques then
: python is a good language to do it in.

	Yet no better then many others, and far from the "best" (SmallTalk
	and friends get that role).

	>snip<
: Here are a few reasons why I prefer python (in no particular order):
:
: * its cleaner and simpler.

	Perl is complex, it's a feature.

	Java is simple too.  Yet that same "simplicity" makes even the
	simplest tasks a highly complex project.

: This makes it easier to learn, but it does
: not sacrifice any power for that simplicity.

	That is highly arguable.

: * better OO - see earlier comments.

	Different and much more limited OO.  If you want Python style
	OO in Perl you have only to use your own self control to limit
	yourself to it.

: * better cross platform support. Since I work in Windows/NT this is a
: biggie.

	Save for fork() and one or two other opts, Win32 Perl is rock
	solid.  Hell, even Perl/Tk et al work from Unix to Win32 without
	a line of code change.  What issues do you have with it?

: Although there are Windows versions of perl it is primarily a
: UNIX tool and the Windows support is secondary.

	Perl is primarily a tool, period.  Windows support is quite
	advanced.

: Python is truely cross platform

	Name a platform Python supports that Perl doesn't, I dare you.
	However I'd be surprised if I couldn't name a few that Perl
	supports but Python doesn't.

: and with PythonWin I can create COM objects, do Active
: Scripting, access the windows API & MFC etc.

	And there goes your praised "truely cross-platform" argument. :-)

	Seriously, you really should check out the Win32::* modules.

: * better interactive support. The interactive consol is a joy to use,
: particularly via PythonWin or PTUI.

	Ever try 'perl -d'?  Inside Emacs and similar debugger enabled
	editors?  Or ptkdb for a pretty GUI interface?

: You can try out code interactively,

	Like this maybe?

	perl -de ''

: including defining functions and classes, and immediately see the result.
: This is great for learning the language and for trying out new ideas.

	Ditto for Perl, your point?

: * JPython. I can write java applets in python (or a python/java mix)
: that can be downloaded and run in a browser.  I can create a java
: class and then subclass it in python, and if I want can compile the
: new class and subclass it again in java.

	This is a nice feature to have, I admit.

	Useless, but nice. :-)

	>snip<
: * Exceptions. These make error handling far easier and greatly
: simplify the code.

	Perl has had exceptions for dog years, before it even had
	OO.  We just call try, throw, and catch "eval", "if", and "die"
	respectively:

	sub MyException::new { bless {}, shift() }
	eval {
	    trySomething()
	        or die new MyException ();
	};
	if ($@) {
	    if (ref $@ eq 'MyException') {
	        cleanUp();
	    }
	    else {
	        die; // propagate the exception
	    }
	}

: * Easy embeding and extending. I can easily write extensions in C, C++
: or other languages and they become a part of python. I can also embed
: the interpreter in a C or C++ (or java with jpython) application to
: give it scripting capabilities.  These are possible in perl, but are
: far more complex.

	I was writing C extensions in Perl 20 minutes from the moment I
	started reading the perlxstut man page, and I'm far from the C
	expert.  Perl has also been embedable for likely longer then
	Python has existed.

	>snip<
: * Perl has better regex support. Regular expressions are built into
: the core of the perl language, so many text processing tasks are
: faster and simpler in perl.

	s/text processing/data processing/g;

	Perl is 8 bit clean, and for dozens of reasons beyond simple
	regexps is the data processing chainsaw of choice.

	>snip<
: * Block structuring by indentation. Some people hate this and some
: people love it. I was put off of trying python for a long time because
: of this, but after using it for a few days it seemed far more natural
: than cluttering up the screen with curly braces.

	your right all this punctuation stuff just makes languages harder to
	read i dont understand why english does it as well it must just
	be like the metric system in that people arent friendly to change
	maybe someday we shale all speek in python and the world will be a
	better place

: There is one caveat though

	There are a few more then one.

: - you have to be careful not to mix indentation
: by tabs with indentation by spaces.

	From my current (blagh) Java project:

    public StringBuffer append (boolean bool)   { _extractStringBuffer().append (bool); type = STRING; return string; }
    public StringBuffer append (char	ch)	{ _extractStringBuffer().append (ch);   type = STRING; return string; }
    public StringBuffer append (int     num)    { _extractStringBuffer().append (num);  type = STRING; return string; }
    public StringBuffer append (long    num)    { _extractStringBuffer().append (num);  type = STRING; return string; }
    public StringBuffer append (float   num)    { _extractStringBuffer().append (num);  type = STRING; return string; }
    public StringBuffer append (double  num)    { _extractStringBuffer().append (num);  type = STRING; return string; }
    public StringBuffer append (Object  obj)    { _extractStringBuffer().append (obj);  type = STRING; return string; }
    public StringBuffer append (String  str)    { _extractStringBuffer().append (str);  type = STRING; return string; }
    public StringBuffer append (char[]  data)   { _extractStringBuffer().append (data); type = STRING; return string; }

	Please show me how the readability of this code would be helped	by
	either indent style blocks or max 80 column text.  Give me a couple
	minutes and I'm sure I could dig up a couple dozen Perl and C
	examples as well.

	>snip<
: The bottom line is that both languages are freely available - it just
: costs some of your time to try them both and make up your own mind.

	Yep, and a bit of time to wade through the BS each side dish
	out to see what is really there.

: dkirby@   <-figure this out, spambots!
: bigfoot.   My opinions are my own,
: com        but I'm willing to share.

-- 
-Zenin (zenin@archive.rhps.org)
 My opinions are mine, and you can't have them, so there.


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

Date: 29 Oct 1998 01:17:55 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Not to start a language war but..
Message-Id: <718fo3$4c8$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Zenin 
<zenin@bawdycaste.org>],
who wrote in article <909623452.948196@thrush.omix.com>:
> : Here are a few reasons why I prefer python (in no particular order):
> :
> : * its cleaner and simpler.
> 
> 	Perl is complex, it's a feature.

No.  Some flavors of Perl's complexity form a feature indeed.  But a
lot of the complexity is the historic baggage which would better go.

Ilya


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

Date: 29 Oct 98 01:14:17 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Not to start a language war but..
Message-Id: <909623951.840118@thrush.omix.com>

John Porter <jdporter@min.net> wrote:
: Andrew M. Kuchling wrote:
: > 
: > ... JPython uses whatever GC your Java VM has, of course.
:
: Ugh! Reason enough to eschew JPython.
: Java's gc has notorious problems.

	Oh hell yes.  I have to run my Java servers with -noasyncgc (turn
	the broken auto-gc off completely) and do my own gc() calls to
	make them work even close to acceptably.

: (Not that I'm making any excuses for Perl's so-called gc!)

	Circular references are the only problem, and rarely are actually
	needed in Perl because primitive types are so flexible.  There are
	times you need a circular linked list in Perl, but not that often.
	Most uses of circular refs are to build containers that in Perl
	are much better built with basic arrays and hashes.

-- 
-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: 29 Oct 98 01:33:11 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Not to start a language war but..
Message-Id: <909625084.763801@thrush.omix.com>

Jason Orendorff <jorendorff@ixl.com> wrote:
: > Mind if I ask what it is specifically about class creation in Perl
: > that you find to be painful?
:
: I have to come to Perl's defense (in my own indifferent way) on this
: one.  The terms Perl uses are incomprehensible to non-Perl programmers,
: but that's only typical:
	>snip<
:   #Perl
:   package Widget;
:   @ISA = (Frob);
:   sub new { bless {} }
:
: When I read about this, I thought, "That's so bizarre as to be
: practically unuseable," but apparently there's nothing so bizarre
: that Perl hackers won't embrace it.  And I can respect that.
: Seriously.

	Well, if you want it to "look" more like Python or Java, it's
	quite easy ya know:

	{ package Widget; base qw(Frob);
	    sub new {
	        return bless {}, shift ();
	    }
	}

-- 
-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: Wed, 28 Oct 1998 17:36:51 -0800
From: "Alistair Calder" <webmaster@topproducer.com>
Subject: Perl how-to question
Message-Id: <718grq$elf$1@supernews.com>

I am creating an online survey for the company I work for.  I have
programmed in perl before, but this question has flummoxed me.

I want to create a single file that will store all the survey values,
including the survey Question, the possible responses and the number of
respondants.  The catch is that the surveys will have a varying number of
responses and I don't know how to tell perl to read that in.

Here is what the file will look like:

Survey_Date|Survey_Question|Number_Of_Responses|Response_A|Total_A|Response_
B|Total_B

So a real life example would be:

01/01/98|Do you think that Clinton should be impeached?|3|Yes, I think
so|301|Not Really|268|Couldn't care less|65

I know how to do a split on a file I have read in, but only if I know the
number of responses that I have.  How can I do this properly?

Thanks,
Alistair Calder
webmaster@topproducer.com






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

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

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