On Fri, Jun 20, 2008 at 2:04 PM, Ludwig Isaac Lim <[EMAIL PROTECTED]> wrote:
>    It tries to incorporate features from different programming languages 
> (C,shell,awk), so people
> with C,shell,AWK can learn it easily. The flip side is that people that came 
> from "C","shell"
> background will write Perl in "C-ish" or "Shell-ish" way respectively. For 
> example, people from
> C/C++ will use "for" loop as opposed to "foreach" loop to iterate an array, 
> they probably tend to
> use "system" function as opposed to using backticks (``).

Right.  There's bunch of these documented in perltrap.  There are
sections for accustomed awk users, cerebral C/C++ programmers,
seasoned sed programmers, sharp shell hackers, and penitent Perl
programmers coming from older versions.

>   And some of the features that are supposed to make it easier, makes 
> (maintenance) life harder.
> Such as:
>   a) "return" is optional even in "non-void" subroutine (I hate keeping track 
> of $_ and friends)
>   b) stuff like $a->[1][2], where (IMO) $a->[1]->[2] is definitely clearer

For (a) there isn't really a distinction between void and non-void
subs.  All subs can return a value or not, and they're not required
to; return itself just acts as a control to get out of subs, with an
optional value, and if there's no return in a sub, the last expression
evaluated within the sub is returned.

For (b), the former is shorthand for the latter, though I agree the
latter is more readable; that could be better improved though:

for my $x (@$a) {
     for my $y (@$x) {
        # $y starts at $a->[0]->[0], so you can traverse a matrix
    }
}

>   And you can't guess from code such as " if ($var =~ /pattern/){...}" that 
> "$var =~ /pattern/
> can actually return an array context! (If you came from C/C++ background, you 
> probably can
> sympathize with me)

Yeah, context is especially delicate, but this here is Do What I Mean
(if I find one or more matches of pattern in $var...)  Since the if()
always supplies scalar context for the tested expression, the m/ATCH/
would return the scalar number of matches of pattern, which if() will
evaluate to true or false depending on the number (nonzero: true, 0:
false.)

>    Perl's OO model is really different from C++, Java, PHP and even VB. Seems 
> the "OO" is more an
> after thought than an intended feature.

And arguably, it is.  Perl is a multi-paradigm language (you can do
functional programming in it too; see Dominus' "Higher-Order Perl".)
Most folks find Perl OO different due to the way Perl handles objects
(it is really just a reference, though what kind it is (scalar, array,
filehandle, even code) is what makes it special ;)

>   I tend to use the "Camel" as  a reference. I used "Learning Perl" to learn 
> the language because
> it is systematic, (easy to read linearly, and with exercises), and it 
> immediately encourage good
> practice such as "use strict".
>
>     It seems that O'Reilly books are getting fewer, and you can't find books 
> such as "Effective
> C++","TCP Illustrated (Vol. 1-3)", "Effective STL", etc...

Book Sale and friends are the places to go for with this, although I
could imagine you can order directly from National or PowerBooks (at
huge cost though.)

Cheers,

Zakame


-- 
Zak B. Elep || http://zakame.spunge.org
[EMAIL PROTECTED] || [EMAIL PROTECTED] || [EMAIL PROTECTED]
1486 7957 454D E529 E4F1 F75E 5787 B1FD FA53 851D
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
http://lists.linux.org.ph/mailman/listinfo/plug
Searchable Archives: http://archives.free.net.ph

Reply via email to