Exegesis 2: Damian Conway On Perl6
sumengen writes: "Damian's writing a series of articles parallel to Larry's Apocalypses.
These 'Exegesis' articles will show full perl6 programs, with
commentary exlaining the new features.
The first Exegesis (numbered 2, to keep in sync with Larry) shows a
perl6 version of a binary tree program from the Perl Cookbook.
Get excited to see things like:
my int ($pre, $in, $post) are constant = (0..2);"
my int ($pre, $in, $post) are constant = (0..2);"
"are constant" that's retarded...
for perl anyways, is this supposed to be some COBOL style shit or a language that has syntax like "s/\/=[ab]//" etc type crap...
Perl has always been nasty syntactically and the people who learned it and know how to use it like it that way. Regexs, $_, and all the other assorted funky magic stuff. Let's not try to throw in some stuff that looks like semi-english just to stop the weenies from switching learning python.
What is even more ironic is that Larry fancies himself some sort of "linguist" or "English" major. He went to college and read a couple books on Shakespeare so now he thinks he is some kind of language expert. Well it doesn't work that way.
Take a look at Perl. Does it look like it was designed by anyone who knew anything about the English language? No, it doesn't. It honest-to-God looks like it was designed by someone who was an Egyptian hieroglyphics major who spent all his free time watching Star Trek -- in other words, someone completely disconnected with reality.
So you can see why Perl sucks. Not to worry; there are other better languages to use. Try Python or Ruby, or gosh darn it -- Korn Shell. Any of these is better than Perl, a "language" which should be relegated to set decoration for Raiders of the Lost Ark.
This is off topic, but what the hell - everyone else does it !
Over the last couple of weeks, I've been doing some stuff in Perl. It's the first time I've used it, and I must say that it has, without a doubt, one of the most tortuous and confusing syntax of any language I've ever used.
I *HATE* all this stuff with preceding variable with $'s and %'s and stuff - it reminds me of the old BASIC days of 15 years ago.
In the latest Perl book, there's a couple of paragraphs that try and defend all this $ and % stuff. It basically says that if you don't like it you're missing the point and that you really ought to go back to school.
Well, Mr. Wall, YOU ARE WRONG ! This sort of crappy syntax should not be necessary. There is simply no reason for it at all.
It is INCREDIBLY difficult to just pass a variable about the place and actually get it to pop out at the other side in the same format as it was at the start. Or, more correctly, it's incredibly difficult to contrive some weird reference syntax (with the appropriate $ or % or whatever) in both the call to a function and the extraction of the variable out of that bloody stupid $_ thing within the function.
I agree with an earlier post - it is a jumbled mess. C++ is often criticized for being confusing and having weird syntax. This may well be a valid complaint, but at least once you know how to do it, it's consistent !
I don't doubt for a moment that someone will read this and think "idiot - he doesn't know what he's doing". The thing it, it shouldn't be difficult - it should be easy to do easy things.
I've often seen the following description of Perl.....
"It makes difficult things easy and it makes impossible things possible."
Added to this ought to be the phrase "it makes easy things UNBELIEVABLY difficult and contrived".
That brings me nicely to a general problem with the Perl book (and indeed most of the available Perl documentation) - why are the examples so crap ?
example (this is lifted straight out of the book)......
The 'while' loop..........
while ($tickets_sold ;
chomp($purchase);
$tickets_sold += $purchase;
}
This isn't actually that good an example of what my gripe is, but look at it !!! I mean, what's wrong with a READABLE example like.....
my ($blob) = 0;
while ($blob 10)
{
print "$blob\n";
}
In other words, stick to the topic in hand - why start introducing stuff about file input and stuff when all you want to know is "what does a while loop do ?", and "how do I write it ?".
This sort of crappy, over engineered, example is typical of what you get in the documentation.
Plus, the examples are often incomplete - they assume that variables are defined (OK, I know you don't need to do this), and they often assume that you've done lots of other stuff. Until you realize this, you tap in the example and find it won't even bloody compile !!!!!!
I HATE Perl !!!!!
OK, rant over.
Then { if ( why == simple ) then why = not happy elif (why = complex) then why = happy endif elif # perl6 elif # subject
What I find so difficult (and annoying) is that you can take a variable (@ping) and you can do something 'obvious' with it like @pong = @ping. Except, this ISN'T obvious, is it ? It doesn't do quite what you were expecting, does it ?
Well, actually, it does precisely what I was expecting. This is probably attributable to the fact that I bothered to learn perl before trying to code perl. What's with people confusing "easy to do powerful things" with "if you speak english, you can code"? To my knowledge, the latter has never been a stated goal of perl.
The $,@,%,etc. does not refer to the type of variable that was originally declared (that's why we have UNIQUE NAMES), it's supposed to tell perl what context you mean something in. It's a feature -- NOT a bug. But apparently enough of you have complained to get it changed, and since the change is elegant anyway, I'll do the manly thing and just suck it up.
Wow, looks like a few people forgot turn on their humor detectors this morning. -1 flaimbait and two flames? I guess it's a self fullfilling moderation!
Down that path lies madness. On the other hand, the road to hell is paved with melting snowballs.
I read the internet for the articles.
Damian Conway writes:
The first thing you'll notice is that reports of the diamond operator's death have been greatly exaggerated. Yes, even though the Second Apocalypse foretold its demise, Rule No. 2 has since been applied and the angle brackets live!
I assume this means that Larry has had a change of heart since he wrote Apocalypse 2, but what is this mysterious "Rule No. 2" that has been invoked?
--
Of course, to really get the advantage from Perl, you'll probably have to start messing with fairly high level conceptual stuff.
People just seem to have a problem getting their heads 'round the likes of pointers. A big difference between Perl and C is that you can get a lot done in Perl before you have to start using pointers/references, so when you do start to need them you are at least comfortable with the rest of the language.
Well, I'd just like to say that I love python. Then again I also love perl.
Vermifax
Vermifax
Logout
> I'm surprised Perl doesn't support the GO-FROM-idiom yet
_ Pr ogramming.html
You're thinking of "COME FROM".
See "A Linguistic Contribution to GOTO-less Programming"
http://neil.franklin.ch/Jokes_and_Fun/Goto-less
It's been implemented in INTERCAL.
http://www.tuxedo.org/~esr/intercal/
--
rant
Perl is indeed its own culture. It's a clique where Larry Wall and Perl are worshipped.
You even sound like Larry.
Perl is "legendary" (notorious) outside the Perl clique for being unreadable and unmaintainable.
Perl programmers tend to use regular expressions
and bizarre syntax far too frequently just because you can. I don't see that as a good thing for
people who will have to maintain that code.
I do not see anything Damian's document to convince me otherwise: Perl has gotten way out of hand from its simple beginnings. Perl 4 had a grammar that mere mortals like me could understand. Perl 5 was okay if you didn't use
its weird hacked on pseudo OO. Smalltalk,
Java, Python, and Ruby are all powerful OO
languages that are much easier to work with
IMNSHO. Perl 6 is just going off the deep end.
Perl has become too clever for its own good. In a company you just can't plan on many people being motivated enough to learn complex nuances like that. I think a simpler, less context-sensitive, and more orthoganal language is better for long-term, large scale development.
-Kevin
Good perl programmers can manage their code in such a way as to make it readable in 6 months and 9 months and 12 months. It's a matter of dicipline.
The vast majority of Perl programmers don't care about readability or maintainability. They care about reducing keystrokes. The few Perl programmers I've met that actually cared about readability and maintainability have since switched to Python. But I guess YMMV...
Programming languages and natural languages are used for different purposes. The expressiveness of english is very handy when writing poetry or interesting prose. If you want to write code, clarity is more important than expressiveness. If that weren't true then we'd be programming in english.
It's for much the same reason that mathematicians, scientists and engineers have precise notation, rather than just using plain english. English is fine for added documentation (ie: comments, etc.) but for the actual code, you want something clear and easy to parse (ie: not Perl).
How about:
$*ARGS is chomped;
Maby it's just me, but I fear that setting properties to variables that affect how fuctions work on them, will greatly decrease the quality of code, available.
Let's just face it, not everybody has even heard of Dijkstra, let alone know how to write 'proofable' programs.2 C3AF4F2snlbxq'|dc
--
echo '[q]sa[ln0=aln80~Psnlbx]16isb15CB32EF3AF9C0E5D727
echo '[q]sa[ln0=aln80~Psnlbx]16isb572CCB9AE9DB03273snlbxq' |dc
If you set $\ (or $OUTPUT_FIELD_SEPARATOR if you use the English pragma), you can use whatever you like, including \n.
My guess is Perl 6 will make this a property of filehandles... seems good to me.
--
how to invest, a novice's guide
Or functions like
touch (my $bitch) and die;
ZOMG I WOULD LOVE TO KNOW ABOUT YOUR FEELINGS ON MACINTOSH VERSUS WINDOWS, VI VERSUS EMACS, AND HOW YOU'RE NOT A DORK
Perl may look confusing, but there's nothing like having to work in VB for a week to make you miss the raw power Perl provides.
Some of these language changes disturb me too, but I trust Larry to ultimately make it fairly simple to transition from perl5-think to perl6-think. The transition will break a few things but it sounds like it will increase the power of the language by about as much as perl4 to perl5 did.
Caution: contents may be quarrelsome and meticulous!
Your right to not believe: Americans United for Separation of Church and
if $bitches = $da_shit, do $nasty_stuff
--
--
"Outlook not so good." That magic 8-ball knows everything! I'll ask about Exchange Server next.
10 PRINT "Fuck You!"
20 GOTO 10
Be sure to pipe the output through lpr.
--
--
"Outlook not so good." That magic 8-ball knows everything! I'll ask about Exchange Server next.
Do you really expect to see three variables initialized to 0, 1 and 2 in a tight inner loop? The ridiculous PL/I initialization syntax sought to be concise, and this was achieved at the expense of clarity. This Perl construct seems the same. Just about any syntactic monstrosity can be justified on the grounds of performance, but you have to wonder how much it's really going to help in practice.
I was also happy to see Basic's "dim" recycled.
Really guys, haven't we learned anything since oh, I don't know, 1965?
Ah, so instead of programming with a well designed language, well designed libraries, and a community bent on producing a top quality, readable, naturally extensible language, I get to program with.... culture!
I'll go down to the supermarket and get ten tons of yoghurt now, shall I?
</flamebait>
Being a C++ coder, the more I learn C++, the more I like C.
cpeterso
oh well, good show anyway.
Now in Perl 6, one can have such syntax as: my int ($pre, $in, $post) is constant = (0..2);
and: $ARGS is prompts("Search? ");
With the advent of this new "is" construction and the use of passive voice in the code, I think that the following should also be added:
This would allow for such conventions as:
$*ARGS be chomping;
"LibCGI.pl" is being required;
(or if one wants to be smart:)
recognize $foo!;
Just a thought.
Has anyone else out there sort of grown up with Perl during this dot.compost era and now started to check out C and the real guts behind ''world domination?''
I'm finally getting into C by taking a night class at UCLA, and my god, this stuff only gets cooler and cooler. To see the community RFC type thing go on with Perl6 and to watch/hear/readof the ISO committee floundering with other languages is very interesting too.
Of all the uninspiring things happening with government, the economy, environment, etc these days, I really recommend that any inclined kid such as myself out there get back to basics and check out what their local community college/college extension has to offer. I have, and every time I walk out of class it's like "oh, no shit, that's friggin sweet." Maybe it's just me, but for some of these things, it's just easier to be in an engaging classroom environment rather than to be all by your lonesone with Conway's ''OOP.''
Anywho, back to coding..
Your comment makes sense as far as it goes. However, that would be a goddamned evil way to design an object! You would be setting yourself up for unnecessary bugs when you call a method and the internal flip-flop happens to be in the wrong state at the time. Just as in Perl 6.
Anyway, do some research before you deride.
Try comp.lang.ada. It's swarming with Ada fans, many of whom would be happy to explain why they love the language so. Ada Home and AdaPower both have quite a bit of information and evangelism (the former is a bit of a 'classic', though).
Does Perl still support GOTO?
God, I love that command.
Feed the need: Digitaladdiction.net
Will it? I thought python was whitespace dependent ... :-)
"What I look forward to is continued immaturity followed by death."
You can set the line terminator to whatever you want. I do a lot of html and often use the following:
/>\n"; #Change the terminator from \n
/>\n
$\="<br
print "Hello World";
Result is:
Hello World<br
You can also define the defaults for input records, for outputting arrays or hashes, etc.
Peace, or Not?
$*STRONG being the force;
I think we have a winner here!
LABEL1:
...
LABEL2:
...
LABEL3:
...
GO FROM LABEL1 TO LABEL2
GO FROM LABEL1 TO LABEL3
As you can see, this simple but powerful idiom supports threads too!
(Btw, the idea of "go from" was indeed from Intercal's "come from", a much-recommended language I couldn't remember the name of. Thread-support has been suggested in that area before.)
- Steeltoe
http://www.debunkingskeptics.com/
After reading the page (ouch, my head hurts), I'm surprised Perl doesn't support the GO-FROM-idiom yet. It'd help alot in obfuscating the code more:
/* jumps to all "go from LABEL1"s in the code here */
LABEL1:
.....
go from LABEL1
By using multiple GO-FROMs you can even make threads! It's powerful, intuitive and obfuscated. Just the right thing for Perl 7.
If you think "go from" is too elaborate, you could probably use ${LABEL1}-> instead. Unless that's taken of course.
- Steeltoe
http://www.debunkingskeptics.com/
When i first went to this page I saw a shitload of RFC's. all numbers to low to be Real RFC's.
so whats up? Does this guy actually has to audacity to call something an RFC and actually just mean request for comment?
-Jon
this is my sig.
Context dependent evaluation of variables, could be really interesting to debug...
synatical (sic) declaration is not the same as typing - it is only an aid to the compiler.
Syntactic declaration is highly valuable to the maintenance programmer. It makes a believable statement about a data object. Misery is reading a program in a language where there are no type declarations on function parameters, but types do matter. Perl 5 comes to mind. Effectively, parameters have types, but nothing but comments (if any) tells you what they are. This is especially painful for object-oriented Perl. Smalltalk had the same problem. Attempts to deal with this problem via comments usually fail, unless some stringent management regieme is imposed. Such a regieme is usually worse than a declaration system.
Declarations force a nonlinear thinking style on programmers; you're continually jumping back and forth between declarations and executable statements, which are often in physically different places. It's unwieldy in text editing, and distracts from thinking about the executable code. And then there are the "header file" / separate compilation consistency problems. These are the issues that drive programmers to languages with lightweight or no declarations.
On the other hand, dynamic typing tends to defer error detection until the program blows up in operation, instead of detecting it during compilation. Some people think this is good, and some don't. As program size grows, it's more of a problem.
These are the sorts of issues that affect user acceptance. It helps to think of programming as a user interface problem. In fact, user interface testing of programming language constructs, where programmers are videotaped programming and their keystrokes logged, could be quite valuable. I've not heard of that being done.
Wash, rinse, repeat.
C went through this evolution, taking about 25 years to do so. Originally, everything in C was basically a 16-bit int. Structs were just a set of offsets. There was no type-checking; any struct field could be used with any pointer. Then came K&R C, which added a type system but made the syntax context-dependent, because the original language hadn't contemplated user-defined types. ANSI C made the type system consistent. C++ added objects. ISO C++ added templates, collections, and lots of other stuff. Now the language and its manuals are huge.
LISP also went through this cycle, again taking about 20-25 years to go from LISP 1.5 to Common LISP. So did FORTRAN and BASIC. Perl is now well along into this cycle.
If you put in the type system first, as Java, Python, Pascal, Ada, and Smalltalk did, the end result is cleaner, but the language gets an initial reputation of being complicated. Perl, though, has now grown to be more complex than any of those languages, so it's on the downslope of the cycle.
For those of you in Victoria, Australia, You can go see Damien Conway talk about some of the things he is doing for perl at the moment.
More details are at http://programmers.luv.asn.au/
I second that. It's 5.x forever or Python and Ruby, here I come.
In the immortal words of Socrates, "I drank what?"
There is a theory that if anyone ever discovers exactly what Perl is for and why it is here, it will immediately disappear and be replaced by something even more bizarrely inexplicable.
There is another theory which states that this has already happened...
There is yet a third theory which states that both the first two theories were concocted by a wily editor of the Camel Book in order to increase the universal level of uncertainty and paranoia, and so boost sales of the book.
siener's youtube channel
--I am just coming to grips with Perl 5. I can msostly write my own stuff without scurrying to the nearest Cookbook or CLPM...
.bat files can be hard.
--As for the other threads here about how hard it is to learn Perl. They're all hard. Perl, Python, C, Hell
---
This
Perl is the crack of programming languages...and I am an addict...with JUST the method of upgrading/installing CPAN modules...it makes it invaluable..to me.... So all you guys thinking about Perl...once you start...you cant stop....and NOTHING compares to the POWER of Perl... I screwed around for a cupla hours yesterday and wrote a complete statics system for my web page...without using 1 module!
--- Every day I am forced to add another to the list of people who can kiss my ass...
IMHO the two languages focus on different things. Perl vs. Python is like poetry vs. technical docs: the former has a lot of artistic freedom, and some things can be made more powerful/compact, but it is difficult to use properly, more so in larger projects. Or you could even say they are like Gimp vs. LaTeX as writing tools. Usually I prefer the latter, when I want to focus on content and not worry about formatting, but sometimes you just need that creative freedom.
--
Escher was the first MC and Giger invented the HR department.
Interesting selection of type-first systems at the end. No one loves Java; you might want to read the early years of Python (and since the semantic underpinnings of Python are similar to Perl, it's not a good example); Pascal - the bane of the 80s; Ada - ha! perhaps the worst, least loved language of all time; Smalltalk - the first system to do objects correctly, this is definitely 'cleaner'. But none of them were inspired type systems, and I can't say typing was 'first' as you said. Only Smalltalk is a wonder of cleanliness. Python is swimming in the same mire as Perl, Pascal - the language that wouldn't die, Ada - the great mistake, Java - the wonders of marketing.
You seem to have a real interest in languages. I urge you to research the background and modern issues, as I would enjoy continuing a real debate here on /.
You are certainly the first Ada fan I have encountered. I will take a closer look as soon I have the chance.
Thanks for the info, though.
This is so confusing. Just the sight of @_[0] to mean a scalar, the second argument to a sub, makes me feel dizzy, and the little hairs on the back of my neck stand up. Please, find Damian and Larry and wake them up somehow. Cold water, dope slap, whatever it takes!
Whew. I hate those early-morning nightmares. Both Larry Wall and Damian Conway were in this dream, wearing dark suits and Ray-Bans, and, and....
Perl proudly exists for the benifit of people who like to embrace "too many ways". It allows you to write crappy code that works while you are learning, and grow as a programmer while producing functional software. Speaking for myself, when I first jumped into writing in Perl for actual applications at my job, I found that it was only a matter of two or three weeks that my code got so much better that I cringed every time I looked at the stuff I wrote on day 1 of the project. A couple months later, I could not stand to look at the crap I had written after 3 weeks. But the point is, all of that lousy code from my days of baby-steps still worked. I could go back and clean it up if I needed to, or I could just leave that pile of spaghetti lying there, functioning perfectly, allowing me to move on to more pressing matters.
If you want your choices limited, to force you into mostly good coding habits, use Java or something.
I often think that the only reason anyone uses vi is so that they can point at people who don't use it and giggle.
There are several reasons why some folks like vi:
1. It is everywhere. Pretty much all *n[iu]x OS has it rolled in, so whether you are sitting at a Solaris box, a Linux box, an old SVR4 box, you can count on vi being available. This allows you to learn one text editor, and use it on any (non-MS) server.
2. It is fairly powerful. Once you learn it, you can do some pretty fast editing of multiple files. vi is not the only editor that supports expressions, sed, awk, etc., but it does it fairly well.
3. It feels a lot like the CLI of the more popular shells. Anybody who learns UNIX will already know a lot of what they need to know to use vi.
4. A lot of first-year college kids are taught how to use it, so it is fairly universal
All that said, there are "better" choices out there (the cheering section for emacs continues to swell), and vi is mostly used due to laziness... but then again, laziness is often considered a virtue in the CS world, is it not?
I'll refrain from getting much deeper into it than that, because nothing in the universe is more tedious that a debate about choice of text editor.
Perl is not THAT bad. But why isn't the obvious obvious ?
Because Perl was not written for doing the obvious. It was written for solving challenging problems. If you evaluate all languages according to how hard "Hello, world!" is to write, you are excluding the mort powerful features of all of them. Yes, all the $_ and \@ stuff looks, at a glance, like it is harder than it should be. The same could be said of the way C handles pointers. Some people find it hard to wrap their heads around Java's use of classes.
All I can say is, use Perl for some hard jobs, instead of just trying in out on "obvious" tasks, and check out how much time you can sometimes save, once you embrace the language. You will be a Perl zealot in no time. (After all, the biggest zealots for anything are always the converted critics.)
Information wants to be anthropomorphized.
To program Perl as if it was Perl is much harder and I've yet to master it after two years of using it, but I did learn to produce useful programs in it in an afternoon.
TWW
"Encyclopedia" is to "Wikipedia" what "Library" is to "Some people at a bus stop"
TWW
"Encyclopedia" is to "Wikipedia" what "Library" is to "Some people at a bus stop"
which is why we have use strict. it makes a lot of strange "what the hell is my variable doing?!?!" type problems go away instantly. and, as with everything else in perl, you don't have to use it if you don't want to.
Bzzzt! Try again!
Read further. 'are' may well be introduced as a synonym for 'is'. The editorial comment was a forward-looking one, was it not?
FP.
--
Also FatPhil on SoylentNews, id 863
Fuck, I'm mod, but have posted already.
Moderators - put down the spoon/inner-tube/whatever, and get upmodding!
--
Also FatPhil on SoylentNews, id 863
... fuck typed languages. That means. perl 5.* for
the rest of my life.
p.
come on, this is perl you're talking about! the canonical "write-once, read-nowhere" language... in my experience, the quality of perl code out there currently couldn't be significantly decreased anyway! :-)
(for anyone surfing at a higher number this is in response to an AC post :-)
Why should perl be easy to understand for you? Thats what BASIC is for, no hold on if you want it to be easy and effortless don't program at all!
You can't expect the rest of society to lower themselves down to your level just because you personally can't understand something..
The great thing about open source, the linux community and programming in general is choice - if you like and understand perl you can use it, if you dont look for an alternative (python, ruby,C++,va'raq...), it would be more productive than complaining.
Now the greatest thing about Perl is there is more than one way to do things and that is also (I think) what confuses some people, they expect less flexibility and power from a programming language.
no sig.
Well, I love perl too, and I think it's powerful, but.. it's pain in the ass, too complicated.. altough i love it i don't use it on simple scripts, i prefer php to perl on web/cmdline scripts.
First point I must make, I love Perl. Its far and away my weapon of choice for most programming tasks.
Perl isn't everybody's cup of tea. There are elements of syntax that can be somewhat oblique. There are aspects that are positively obscure compared to C or Java. However, there are some fantastic points about it too. First and foremost, learning Perl is a distinctly easier task than C, Java or any other higher level language. Simple tasks in C are very simple, but anything beyond the basics is extremely taxing for the beginner. Once you're into Perls way of working you're sorted. Perl also has a tendancy to be shown as a block of regexp code too. This doesn't help.
You mention that the example 'won't even bloody compile', inferring you're used to some other compiled langauge. This is another failing of Perl. Its syntacically(sp?) really quite different to everything else. Coming to Perl from another language is difficult, more so than Pascal to C for example.
In the end, live and let live. If you can't get on with Perl then don't. There are many other options open to you.
http://twitter.com/onion2k
First of all, I really wish they'd put in a println function, I really hate typing "\n"
but then again
sub println{ print "$_[0]\n";}
print "hello";
in other thoughts, the 'is' in
%node{VALUE} = $val is Found(0);
kinda scares me because it reminds me of applescript. I dont remember applescript, but I've done some sizeable things in it, and its so close to a natural language that you get confused and start programming in english. Its good that spoken language and programming languages look so different, otherwise I'd accidentally start speaking in code.
Sneakemail is to spam filters what an ounce of prevention is to a pound of cure.
$*ARGS->chomped(1);
and any further calls to $*ARGS "accessor methods" behave appropriately.
Of course, I'm no OO guru, so if this mental model has some fundamental flaw I'd appreciate feedback.
"Biped! Good cranial development. Evidently considerable human ancestry."
In cases like this, I use STDERR for my prompting, because
This is where someone should tell me it's OK, because there's Another Way To Do It where prompts binds STDERR instead.
[100% ISO 646 Compliant]
SVM, ERGO MONSTRO.
Well, easy is a relative concept. Learning Perl is at least an order of magnitude easier than learning C, C++, Java, or Assembly. But this doesn't mean that you can become a perl wizard in three days.
And because you can write some small perl scripts that are doing some cool stuff (which would have taken several thousands of lines code in C) doesn't mean that you learned perl (as most people think).
>I've written far more lines than I care to think about in C, C++, ...
Just guessing; maybe that's the reason why you have a problem with starting up with perl. You just need to learn the Perl way of doing things.
And how long did it take you to learn C or C++?
I think he is saying that your while statement uses an undeclared varible.
br. It should declare wha t$ticket_sold is and then do the while loop.
The Lottery:
"Not my manner of thinking but the manner of thinking of others has been the source of my unhappiness." - M
FAQs like...
"how do I pass an array into a function",
"how do I use a reference as a hash key"
"how do I create a 'static' variable"
-- SNIP --
These questions are in the FAQ because they get asked alot in newsgroups. Duh!!!
The answers to these questions should be obvious, and most likely are obvious, to anyone with a CompSci degree or a year or more experience with C-like languages.
These questions are asked because Perl, in spite of the general consensus that it's not a good teaching language, somehow manages to be the first language that many novice developers learn, or at least the second right after VB.
The "obvious" answer to the first two questions involve references.
The interesting thing about Perl is all the functionality that an amateur can squeeze out of it without even know what the h*ll a reference is!
At some point, the eager amateur thinks to him/herself "Wouldn't it save me alot of typing if I could pass a whole array into a function rather than iterating through it?" The aspiring developer then turns to the newsgroups for an answer, where he/she is immediately flamed for not checking the faqs.
Angered and embarrased, the newbie then checks the faqs, and eventually learns what references are and what they are good for.
The fact that these FAQs exist is not a sign that there is something wrong with the language. The fact that these FAQs exist is a sign that Perl is a language that many developers cut their teeth on, and that there is something oh-so-right about the language.
The only thing that we learn from history is that nobody learns anything from history.
Something like Euclid's equation for Perl. Something that elegantly uses all of Perl's special variables in a single statement.
It would likely solve for world peace.
Dancin Santa
Well, this isn't exactly the same, since it returns a new collection without mutating the old one, but in Dolphin Smalltalk one could do:
foo collect: [:x | (x beginsWith: 'comment') ifTrue: ['! ' , x] ifFalse: [x]].
so I'd have to answer 1, about 20 seconds, and yes. It's pretty easy in Common Lisp too.
I don't think Dolphin has a regex class built in, but I'd be surprised if such weren't readily available for Smalltalk - there are some pretty sizeable code archives out there. And perhaps some of the bigger implementations do have them built in.
I was thinking about it some more, and it's not to hard to do in an ML either (and at least some of these do have regexes included - SML does, and OCaml does too):
map (fn x => if String.isPrefix "comment" x then concat ["! ", x] else x) foo;
I'm not so familiar with the ML regexes, but I suspect it's merely a matter (instead of the String.isPrefix "comment" x part) doing something along the lines of (ML pseudocode follows :-)
Regex.match (Regex.regex "^[0-9][A-Z][A-Z] etc.") x. I don't know offhand what the exact syntax would be, though. Not as compact as Perl, to be sure, but certainly nothing difficult.
Perl4 to Perl5 was a real improvement. I had hopes that Perl6 might fix many of the idiosyncracies in Perl5. But it seems to add more junk to the language without helping much. $*ARGS is chomped? $ARGS prompts("Search?");? That isn't the kind of functionality that is complex enough to warrant new, oddball language constructs, and Perl5 has perfectly good constructs for those cases. And in addition to that, Perl6 also introduces lots of subtle incompatibilities with Perl5. As far as I'm concerned, Perl6 is shaping up to be the worst of both worlds: incompatibility and mess. Thanks for the heads-up: as a long-time Perl user, this really convinces me that it's time to switch.
I've never had any problems with the libraries in python. For example, the following will load SlashDot (just the html code, not parse it), and e-mail me that it has done so. import urllib,smtplib slashdot=urllib.urlopen.read() smtplib.connect('mail.local.com') smtplib.sendmail('sender@send.org','tyler@tylereav es.com','Subject: Slashdot\n\nLoaded')
TODO: Something witty here...
all my @base are Belong::To qw/parse error/;
My exception safety is -fno-exceptions.
The real strength of Perl lay not in its technical construct, or its syntax, or even in the vast set of modules and libraries available to it. The truest strength of Perl is its culture. Larry Wall, from very early on, has tried to foster a real, positive community.
Perl6 is yet another cultural extension to Perl5. The RFC process was very messy, disorganized, and perhaps a little out-of-control. Indeed, as Larry said, he spent several months mentally thrashing as he tried to grok all of the RFC's. But that is the way he wanted it. The RFC process was a picture of a real-life war-room or think-tank.
The end result will be very exciting, I believe. The Perl6 documents, to date, have capitalized on cultural strengths of the Perl community.
Truly, Perl6 is built on the most important resource available to Larry: the huge diversity of Perl programmers all over the world. That diversity has made Perl5 a great, legendary language. I think it will make Perl6 even better. As Perl advocates, I think our best effort is in being inclusive, rather than exclusive, in our thinking.