since you already know C/C++, perl is not that different from them
Actually, most of the apparent similarities between
Perl and C are deceptive superficial similarities that
hide large gotchas. Aside from basic syntax, Perl is
actually much more like lisp than it is like C.
$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}}
split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
| [reply] [d/l] |
But the "superficial similarities" will certainly help OP to write his first Perl program. I think OP needs a bit of assurance and encouragement at this stage. It's not that important for technical correctness yet.
| [reply] |
But the "superficial similarities" will certainly help OP to write his first Perl program.
Perhaps, but...
I think OP needs a bit of assurance and encouragement at this stage.
Sure, and responses like "Go for it, Perl isn't
that hard to learn" are fine, but...
It's not that important for technical correctness yet.
Glossing over details is one thing; outright lying
about a critical point
is something else. If you lead the guy to believe
that Perl works mostly like C, you're not doing him
any favours. Next week he'll try something like
the following:
print ($someval + $otherval), " blah blah blah";
He'll be thinking that the above is a statement,
because something like that in C would be a statement.
Perl, of course, doesn't
*have* statements, or anything that resembles them
very closely, so the above parses as a list in void
context, which is altogether a different thing (and
an unfamiliar thing previously, since C doesn't have
lists or context).
It's not a hard thing, but it's very different from
a statement, and the results are different.
Perl isn't hard to learn, but the very
first thing a C programmer needs
to learn about it is that it's fundamentally unlike
C in a handful of very important ways. You're not
helping him learn it if you tell him exactly the
opposite.
Fortunately, warnings will catch most of the worst
gotchas like the above, but then again a lot of C
programmers seem to be used to totally ignoring all
compiler warnings (judging by the stuff that scrolls
by when you compile most popular software), so at
minimum he needs to know to be alert for these things.
$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}}
split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
| [reply] [d/l] [select] |