develooper Front page | perl.beginners | Postings from December 2002

$_ @_ and others

Thread Next
From:
Duarte Cordeiro
Date:
December 3, 2002 00:29
Subject:
$_ @_ and others
Message ID:
0DA607347A46F649BA80F49ABAE83FE417A444@ptoermxs01.neoris.cxnetworks.net
Hi all,
 
 I'm following this mailing list for a while. Also, we had a small project inhouse that had some components made in perl.
 It was developped by 3 diferent guys, so we shared some code. In the end, I was the one who glued everything.
 
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.
 
Just my two cents,
 
 Duarte Cordeiro
 

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About