http://www.perlmonks.org?node_id=445396

kocaweb has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: <> diamond Operator
by kutsu (Priest) on Apr 06, 2005 at 19:45 UTC

    If you want to pass a perl course....learn perl. Our Tutorials Section should help (Getting Started with Perl, esp.) - woofly's tutorial (Where and how to start learning Perl) is an excellent example of this

    Then when you get specific questions ask here.

    "Cogito cogito ergo cogito sum - I think that I think, therefore I think that I am." Ambrose Bierce

Re: <> diamond Operator
by Joost (Canon) on Apr 06, 2005 at 18:51 UTC
Re: <> diamond Operator
by jonadab (Parson) on Apr 06, 2005 at 21:22 UTC
    my teacher told me that it would take 10 minutes

    Right, but that's after you read the chapter. Obviously, if you haven't read the chapter, you won't know how to complete the assignment. What textbook are you using? (The prof *did* assign a textbook, I hope...) Does it have a picture of a camel on the front? Or a llama? (If it says "21 days" on the cover, you should probably hightail it to a library and get one of the ones with an animal on the cover to go along with it. They're much better.) We could probably point you to the right section of the textbook; OTOH, your professor probably can too, and may have already. You'll want to read the chapter before attempting the assignment.

    Of course, we could also probably just give you the answer to this assignment. (Ten minutes? I could do it in ninety seconds.) But that won't help you pass the class. It'll get you through this assignment, but if you don't understand this one, you'll be in over your head soon, as the class moves on to more involved programming. If you're going to pass the course, you need to understand the answer you turn in.

    update:
    Look Guys, my Major is not computers i had to take a computer course to get the degree, the only reason i took perl is because it sounded interesting

    Perl is interesting, and a lot of fun. We all (well, all of us with degrees) had to take courses outside our majors. My major was Math, but I took a drawing class, an Appreciation of Fine Arts class, and other things. And you don't have to be a computer major to enjoy dabbling in using computers just a little. We're not asking you to achieve Guru status, and neither does your professor expect that. But you will have to learn something.

    to be honest with you, i dont even know how to start, thats why i asked if somebody could do it for me or at least start then i could take it from there

    We're trying to help you know where to start. If we just start the problem for you, you will not very likely be able to <q>take it from there</q>. Computer programming, like math and foreign languages, is inherently cumulative. It's not like History, where once you pass the quiz on the first chapter you can move on to other things. The very first things you have to learn, you still need to understand to do the work at the very end of the course, and to pass the exam.

    if you dont want to do it and money is in your mind, i could pay for your service, just keep in mind I am a student.

    You'd have to pay one of us to take the exam for you too, including travel expenses to your university and whatever it takes to buy off your professor to look the other way when we don't look like you. As a student, you can't afford that. And then there's the risk of getting caught, not to mention the value of your personal integrity.

    The book that i have has a lama on the cover,

    Excellent. That's widely regarded as a good one, and is probably the best choice for you if you've never programmed before. I learned Perl from the Camel book, which is better if you have previous programming experience in other languages, but the Camel book starts out a little steeply for someone with no prior experience, so the Llama is probably the best possible textbook you could have for the course, in your situation.

    if it was something that i would do everyday i would learn perl, but once i pass this course may be i wont even work on computer anymore,

    Maybe, if you take the time to learn Perl, you'll change your mind about that, and decide to do a little programming on the side -- nothing complicated, just for a hobby. Or maybe not, but wouldn't you like to explore the possibility?

    and there are only 2 assignments on this course, test i have no problem i could just read the book and somehow pass it.

    I don't think you'll be able to pass the test, or the course, without learning enough Perl to complete this assignment. The test will have questions on it that require you to write some short bits of code -- nothing complicated, but then, this assignment isn't very complicated either. It is something you'll be able to do.

    So, get out that textbook and start looking it over. To complete this assignment, you'll need to learn the basics of just about half a dozen Perl features: print (start with that one, and you can complete the first requirement listed in the assigment just with that), @ARGV (and probably arrays in general), open, reading from filehandles (with the <DIAMOND> operator), pattern matching and substitution (notably, s///), and conditionals (i.e., if). None of these, individually, is very hard, since you only need to learn their basic features, not every nuance. If you have a specific question about any of these, or if there is some particular point you don't understand, ask us. We do try to be helpful, really. But just giving you an answer to the assignment, as much as you might think it would help, would not, in fact, help you -- not in the long run, and indeed almost certainly not even in your stated goal of passing the course.


    "In adjectives, with the addition of inflectional endings, a changeable long vowel (Qamets or Tsere) in an open, propretonic syllable will reduce to Vocal Shewa. This type of change occurs when the open, pretonic syllable of the masculine singular adjective becomes propretonic with the addition of inflectional endings."  — Pratico & Van Pelt, BBHG, p68
Re: <> diamond Operator
by ikegami (Patriarch) on Apr 06, 2005 at 18:52 UTC

    Which part do you need help with? What have you tried? We're not going to do your homework for you.

    <FILEHANDLE> and the special case <> are documented in the section "I/O Operators" of perlop

Re: <> diamond Operator
by fraktalisman (Hermit) on Apr 06, 2005 at 22:14 UTC
    kocaweb wrote:
    I'll i wanna do is pass this course

    That's very sad. Then didn't you choose to be in the programming class? In which kind of school is Perl mandatory? I am impressed (of the school). I have met so many people who are doing some kind of course or class to make them programmers or web designers or both, and many of them even get their certificates even though the showed little talent or effort. But I am not sure if you'll become one of them. Because:

    At least, kocaweb, you achieved some things: you wrote what has to be done. You have looked somewhere to find information. You even got information in the answers, hopefully you figured out the right chapter in the perl documentation and understood it. After all, you might be spending much more than ten minutes to get your homework done, but then maybe you will have learned more in the end, and this experience will help you for your next homework. Maybe it even gets you interested in the stuff you are about to learn - not only passing the exam. Now you've found Perlmonks, take some spare time and explore the site, it's a bit unconventional at first glance, but it's worth being discovered.

      look guys, my major is not in computers, I had to take one of the computer courses to finish my degree, i took perl just because the name sounded interesting, to be honest with you i dont know even how to start, thats why i asked if somebody can do it for me or at least start and then i could take it from there, and if you dont wanna help and money is in your mind , i am willing to pay for your service. Just have in mind that I am a student.

        It's not that we have a problem helping. That's what the whole site is about - if we didn't like helping, we would be elsewhere.

        It's that we generally don't like doing it for someone.

        It's just a lot easier to help someone who shows some effort than someone who shows no effort.

        My wife had to take a computer course for her degree, too. She took a course that taught QBasic on the Mac. She got mad at me for not doing some of it for her, too. But, when she completed the course, having written some really basic (no pun intended) programs, she was quite proud of them. No way she could write a lick of code now, but she was proud of it at the time. Got a good mark, too, if I recall correctly. But all I did was help - not do it for her.

        So, if you could show what you've attempted so far, and where it isn't doing what you think it should, there will be people falling over each other to help you. Really.

Re: <> diamond Operator
by Mr. Muskrat (Canon) on Apr 07, 2005 at 00:35 UTC

    I honestly don't know how you made it to your 8th lab without knowing anything about Perl...

    I realize that you're not majoring in computers. You did however sign up for the course! If you fail it, you'll have to start fresh with the same class or a class that very well could be much harder. If you read the textbook and do the assignments yourself, you should pass.

    You say the book has a llama on the cover so I'm guessing that it's "Learning Perl". You don't mention what edition though. Read every chapter up to and including the chapter on "Basic I/O". This will get you familiar with the things that you will need to finish this homework assignment. The chapter on "Basic I/O" will explain <> (the diamond operator).

Re: <> diamond Operator
by starbolin (Hermit) on Apr 07, 2005 at 00:58 UTC
    but once i pass this course may be i wont even work on computer anymore

    Don't sell yourself short. Many jobs involve computers nowdays. People with computers skills earn more money in any occupation. Learn how to use computers.

    starbolin
Re: <> diamond Operator
by Anonymous Monk on Apr 06, 2005 at 19:50 UTC

    I wouldn't use:

    $lc_str = $str | ("\x20" x (length $str)); push @index, $-[0] while $lc_str =~ /xxx/g; substr($str, $_, 3) = 'ggg' foreach @index;

    I also wouldn't use the diamond operator.

      yeah, also don't turn in something like this:

      undef$/;for my$f{open IN,$f xor<IN>;s/(x)\1{2}/'g'x3/iegm;s/alpha/uc$1 +/egm;open OUT =>'>',($f eq'file1')?'sysbacks/file1':(($f eq'file2')?'alpha/file2':(( +$f eq 'file3' )?'gamma/blue':(($f=~/^file[45]$/)?'gamma/green':'/dev/null')))or die; +print OUT $_; }@ARGV;

      Even if it works (which I didn't test), your prof will not give you a good grade for it.

Re: <> diamond Operator
by sh1tn (Priest) on Apr 06, 2005 at 18:49 UTC
    And you expect applause for posting your homework right here , I suppose?


      And you expect applause for posting your homework right here , I suppose?

      It's not like he was trying to hide the fact that it was homework. (Not like he could have, with an assignment like this, but some people try.) He probably really feels overwhelmed. I do wish he'd given us more info about the problem he's having, the textbook the class is using, and so on; we maybe could have helped him better then. Just saying "we won't do your homework for you" doesn't really help very much. (Okay, so it's better than just giving him the answer to the assignment. But it's not much better than saying nothing at all.)

A reply falls below the community's threshold of quality. You may see it by logging in.