Re: Suggestions for writing a Perl application
by artist (Parson) on Aug 23, 2003 at 04:42 UTC
|
Tell us your application areas and more suggestion will follow.
Meanwhile
Few Links you can get ideas from:
One of the cool application would be displaying on mozilla toolbar, the titles of Perlmonks new nodes as they are posted.
artist | [reply] |
Re: Suggestions for writing a Perl application
by graff (Chancellor) on Aug 23, 2003 at 04:17 UTC
|
Well, if you've done some app in some other language, it might be educational to try redoing it in perl -- making sure that you add some enhancements to make the perl version a distinctly useful tool in its own right.
If you're approaching perl as your first programming language, then there are probably some other areas, involved with whatever OS you're using, that are new or unfamiliar to you as well, so you should consider what sort of app would allow you to learn/use/control your computing environment more effectively -- and write that app. | [reply] |
Re: Suggestions for writing a Perl application
by Abigail-II (Bishop) on Aug 23, 2003 at 23:19 UTC
|
Consider what you are usually doing behind your computer.
Most likely there is some job you do often, and do manually.
It could be as simple as repeating the same keystrokes several
times, or running a program, consulting its output, and doing
something based on that output. Perhaps you repeatedly visit
a website, waiting for something to happen.
My suggestion is that you automate that process. Add some
useful options to it. Let it print out a usage message.
Use POD to create a manual page.
Alternatively, consider the following problem. In the plane
you have a set of N red points, and M blue points. Find a
line such that on each side of the line, there are at most
floor (N / 2) red points, and at most
floor (M / 2) blue points.
But the latter might be a bit too advanced, and for most
people, pretty useless.
Abigail | [reply] |
|
|
-sauoq
"My two cents aren't worth a dime.";
| [reply] |
|
|
It's not at all impossible. Points can be on the line. If
M and N are both odd, the line will go through at least one
red and at least one blue point.
Of course, that still wouldn't address the problem with infinite sets.
In fact, it does work with infinite sets, and it works in
more dimensions as well. This theorem, saying that in d dimensions, given d sets there is a
hyperplane of dimension d - 1 that divides all
sets in two parts of equal size, is also known as the
"ham-cheese sandwich cut", because the theorem implies that
you can always divide a ham-cheese sandwich in two equal
parts (both parts having the same amount of ham, cheese and
bread) with a single cut, even if you leave the cheese in
the fridge.
Abigail
| [reply] |
|
|
|
|
Re: Suggestions for writing a Perl application
by sauoq (Abbot) on Aug 23, 2003 at 03:39 UTC
|
Any suggestions are welcome and I will try my best to write them and post them here.
Assignment: write a perl program which will take as input the source code of another perl program and will output a single character, either a 1, if the input program would eventually stop were it run, or a 0, if the input program would run forever.
-sauoq
"My two cents aren't worth a dime.";
| [reply] |
|
|
(ahem?) In other words, "put the newbie in a round room and tell him to piss in a corner". Really, sauoq, just because you're twiddling your thumbs at PM on a Friday night, don't take it out on the newbies...
| [reply] |
|
|
Someone once said, "Nothing is impossible for the man who doesn't have to do it himself."
Arthur C. Clark said, "the only way to discover the limits of the possible is to go beyond them into the impossible."
I made my suggestion quite seriously. Yes, the task itself is impossible but attempting it isn't and there are a great many things to learn by trying. The very limits of computing, for instance.
Furthermore, as Walt Disney said, "it's kind of fun to do the impossible." What suggestion did you offer? To take an app he had done before and redo it? Or to write a tool that he needs? That's not fun graff, that's work! (Useless busy work in the first case.) Would it be educational? Maybe. In the same sense that listening to a boring professor lecture in a monotone is. He'd learn something from it if he stuck through it.
My suggestion might be impossible to complete, but he would have had fun trying. When you are having fun with a new subject, it's amazing how quickly you learn without even realizing it. You just look back one day and think, "wow!" On the other hand, when you are focused on the learning itself rather than letting it take a backseat to enjoyment, it's a frustrating experience.
It wasn't my intention to poke fun at a newbie and I certainly wasn't taking anything out on him. You have misjudged my intentions and my character. Has my history here really left such a poor impression? Sigh. Oh well. Everyone lives in their own dream.
-sauoq
"My two cents aren't worth a dime.";
| [reply] |
|
|
|
|
$|++;
print "0";
open OUT, ">/dev/null";
select OUT;
eval $ARGV[0];
select STDOUT;
print "\cH1\n";
Update: Oops, I missed the part about outputting "1 character" - it looks like 1 character though.
All code given here is UNTESTED unless otherwise stated.
--Bob Niederman, http://bob-n.com | [reply] [d/l] |
|
|
#!/bin/perl
# usage testforever <scriptname>
#
$|++;
# Of course -- nothing can run forever.
print "1";
-Waswas | [reply] [d/l] |
Re: Suggestions for writing a Perl application
by bm (Hermit) on Aug 29, 2003 at 13:17 UTC
|
Hmm. What I would suggest depends on your experience in other programming languages.
I find a nice way to learn a language is to start of with something simple, and then more and more featues until it is quite involved.
So how about writing a quiz, and adding additional, increasingly complicated, features over time?
- Write a quiz that loads the questions and answers from a data file. The program asks the user each question and checks the answer for correctness. At the end of the questions the program displays the results "You scored 5/10"
- Modify your program so that the questions and answers are stored in XML. Use a module to parse the XML. With the XML, allow multiple choice questions. Some multi choice questions may have more than one answer, so cater for that in your program and XML. (module XML::Simple)
- add a timer, so that the quiz must be completed in at most X seconds, or each question must be answered in at most Y seconds
- Prompt the user for their username, then add a feature that saves the quiz results into a database. Develop reports, so the user can find out their average score, number of tests taken, standard deviation, etc (module: DBI).
- Add graphing, showing a say user's results or a average time taken to complete the quiz, over time (module: GD).
- Provide a CGI interface for your script, so you can put it onto the world wide web (module: CGI)
- Write a GUI for your quiz (module: Tk)
- Turn your progam into a client/server app, where the server sends the question, the client sends the answer (module: IO::Socket)
- Make your questions dynamic or random by querying the world wide web for the question/answer combinations, say from www.quiz.com or www.dictionary.com (module: LWP)
If you manage to implement these features (or even some), you will be amazed at the power of knowledge you have gained.
I hope this helps
--
bm | [reply] |
Re: Suggestions for writing a Perl application
by Theo (Priest) on Aug 23, 2003 at 22:15 UTC
|
Something I want to get around to writing, is a script that a teacher (with a password) can use to create an html page to post her class's homework assignments on the school's web site. There should be a selector box of teacher names, the teacher should be able to preview her post, and be able to edit or update it at will. Such a project would be both useful and, for me, fun. -ted- | [reply] |
Re: Suggestions for writing a Perl application
by jacques (Priest) on Aug 24, 2003 at 02:11 UTC
|
Demonstrate the solution to this puzzle in Perl:
A prison warden summons three convicts before him and suggests that whichever of them can pass a certain test shall be set free. 'Here are five discs,' he says, 'three white and two black. I shall fix one of these discs on each of your backs without telling you which color I select. You are not allowed to speak or to use a mirror, but you can look at one another ('s backs). The first one to guess the color of the disc he is wearing can go free, providing he can explain how he arrived at his conclusion.'
The prisoners agree to take the test, and the warden puts a white disc on each of their backs. After looking briefly at one another ('s backs), they all leave the prison yard together (i.e. they pass the test). Each one, by the same argument, has realized that he was wearing a white disc.
So the task, then, is to figure out how the prisoners discovered that they each were wearing a white disc.
| [reply] |
|
|
Well, the solution is fairly simple, if you can assume the
convicts are smart (which is quite bold), and they have a
similar sense of "how long it would take to figure out a
logic problem".
The solution is that if two convicts wear a black disk, the
third convict knows he has a white disk. But from looking at
the backs of the other convicts, the convicts know that there
is at most one black disk - and if there's a black disk,
it's on their back, and the others see a white and a black
disk. However, since noone leaves right away, the ones seeing
a black and a white disk will conclude their disk must be
white - there cannot be two black disk, and they can leave.
But this also doesn't happen, so the premises that one's
disk is black is false, ergo, everyone has a white disk.
But as I said, there's a timing problem, and the assumption
the others are smart. Usually, this question is asked with
perfect logican getting hats or disks to wear, and there is
some timing mechanism (for instance, each of them is asked
a question in a particular order).
I don't really see a way of demonstrating this puzzle in
Perl.
Abigail
| [reply] |
|
|
I don't really see a way of demonstrating this puzzle in Perl.
An algorithm should do it. The puzzle is a well-known one. Logical time is divided into three moments.
1. the instant of seeing
2. the time for understanding
3. the moment of concluding
The first prisoner to deduce the color of the disk on his own back will be granted his freedom.
The correct deduction appears to depend on the hesitation of the group. "If I had a black disk, then each of the other prisoners would not hesitate to deduce immediately that he was white. Since neither has done so, I must also have a white disk." In fact, this puzzle would make a nice Perl game.
| [reply] |
Re: Suggestions for writing a Perl application
by menolly (Hermit) on Aug 28, 2003 at 22:03 UTC
|
When I was re-familiarizing myself with Perl a few years ago, I wrote a text-based freecell game. It was amusing to write, still has numerous "nice" features I can add when I'm bored (I haven't touched it in ages), and gave me a time killer when it was done. | [reply] |