Thanks for your reply :)
I think we're just saying the same thing. Perl lets you do a lot, but
it's on the programmer's back the responsibility to do the correct
thing(TM).

Regards,

  Duarte


-----Original Message-----
From: Paul Johnson [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, December 03, 2002 11:26 AM
To: Duarte Cordeiro
Cc: [EMAIL PROTECTED]
Subject: Re: $_ @_ and others
Importance: Low


Duarte Cordeiro said:

> I don't know if is just us in here, but perl seems to "help"
programmers
> make fuzzy and hard to understand scripts.

> but why use $_ or even nothing ( because almost every function can
use
> $_ by default)? if I have  a problem in a script, and I see a $_, I
> just have to backtrack and read the actual code just to see what that
> particular variable is supposed to hold.  That's why they invented
> variable names, no? no use to have a var called $a or $xyz.  Ins't a
> line like: s/$_[1]//;
> or even s/.+\w*?//; (assuming some things, its the same , no ? :) more
> cryptic then: $fullname=~s/$lastname//;
> Eveybody can see that I want to take out the last name from the the
var
> that holds the full name. But in the first two cases, I just have to
> read the actual code to just understand what that line is supposed to
> do.

> I don't want to be flamed :) I'm not saying its bad by itself... it's
> like having a goto in a language. It doens't harms anyone by itself..
> but allow programmers to shoot themselfs in the foot.

Well, it's true, Perl gives you more than enough rope with which to hang
yourself.  But sometimes you need that rope, and if you didn't have it
you'd have to jump through hoops instead and might end up painting
yourself into a corner.

It's fairly easy to write ugly programs in Perl, if thats what you want
to
do.  It's also fairly easy to write ugly programs in other languages, if
thats what you want to do.

But on the plus side, it's also fairly easy to write extremely elegant
programs in Perl,  and that's not always true about other languages.

One way in which Perl is different from most other langauges is that it
allows you to program in a number of styles - and there is no officially
correct style to use.  In fact, it may be appropriate to use different
styles at different times and for different purposes.

For example, you might program "quick and dirty" for a 10 line script
you
think you'll only use once or twice.  You might decide to use a style
that
is fundamentally imperative, or objective, or functional.  Or you might
mix and match.  You might "use English", you might use default values,
you
might put parentheseis around all your function calls, you might use
lots
of REs, you might use pack, you might drop down to XS for parts of the
program, you might be learning and program "baby Perl", you might use
CPAN, you might reinvent wheels.  All of these are OK, and might be
appropriate at different times.

Perl takes the attitude that you are the programmer, and you should know
how best to solve your problem.  You can ask perl for some help, but you
will not be forced into a certain style just because someone thought
they
knew better than you.  It is up to you to provide the discipline, if
that
is what you want.

With respect to your point about $_.  $_ functions like "it" in English.

It saves you from having to continually specify the variable with which
you are working, but yes, you then have to understand the context.  This
is one way in which you can write elegant programs, but if your use of
$_
gets too far away from where the topic is set then you get ugly
programs. 
Again, the programmer must enforce his own discipline.  Use it where
appropriate, don't use it where it is not.  You get to decide what is
appropriate.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net




________________________________________________________________________
____
For your protection, this e-mail message has been scanned for viruses.
Visit us at http://www.neoris.com/

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to