Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Hey Fetzaa, part 2...

  1. #1

    Hey Fetzaa, part 2...

    ok, new challenge, *this time i pick the assignment. *here goes:

    i want you to translate my python code into perl (because that's essentially what the last one was, me translating your code).
    the code resolves host -> IP and IP -> host. *if a user gives bad input, and exception is raised and it loops back to the top.

    if you have any questions, please feel free to post them.

    Code:
    from socket import gethostbyname, gethostbyaddr, error
    import string
    
    #!/usr/bin/env python
    
    print '\n'
    print "Welcome to PyResolve!"
    quit = 1
    try:
     * *while quit == 1:
     * * * *print '\n'
     * * * *print "1. Get a domain name for an IP address."
     * * * *print "2. Get an IP address for a host."
     * * * *print "3. Buggar off..."
     * * * *x = int(raw_input())
     * * * *if x == 1:
     * * * * * *IP = raw_input("Enter IP address: ")
     * * * * * *host = gethostbyaddr(IP)[0]
     * * * * * *print "The domain name for %s is %s" % (IP, host) 
     * * * * * *quit = 0
     * * * *elif x == 2:
     * * * * * *addr = raw_input("Enter domain name: ")
     * * * * * *IP = gethostbyname(addr)
     * * * * * *print "The IP for %s is %s" % (addr, IP)
     * * * * * *quit = 0
     * * * *elif x == 3:
     * * * * * *print "Fine, didn't want to help you anyway..."
     * * * * * *quit = 0
     * * * *else:
     * * * * * *print "1, 2, or 3, buddy. This ain't rocket science..."
     * * * * * *print '\n'
     * * * * * *quit = 1
    except ValueError: 
     * *print "ValueError: these aren't hard questions, really..."
    except error:
     * *print "Couldn't resolve that host"
    except:
     * *print "something pretty bad happened, but damned if I know what it is..."

  2. #2

    Re: Hey Fetzaa, part 2...

    I haven't done anything with sockets yet, so you'll have to wait.

    Do you have any idea how utterly pointless this excercise is, btw? The only thing you could possibly hope to prove is that you know more Python than I know Perl.

  3. #3
    Guest

    Re: Hey Fetzaa, part 2...

    I haven't done anything with sockets yet, so you'll have to wait.

    Do you have any idea how utterly pointless this excercise is, btw? The only thing you could possibly hope to prove is that you know more Python than I know Perl.
    Bah, it keeps this board alive. Also, some other people might want to make versions in other languages.

  4. #4

    Re: Hey Fetzaa, part 2...

    Do you have any idea how utterly pointless this excercise is, btw? The only thing you could possibly hope to prove is that you know more Python than I know Perl.
    if that's actually the way you're taking all this, then you're totally missing the point. *here's why:

    - friendly competition isn't bad.
    - if you're going to make claims that perl is better than python, then you should at least understand that in order to support your claim you'll have to be able write programs that are a bit more complicated than rot13.
    - this is how you learn.


  5. #5

    Re: Hey Fetzaa, part 2...

    - friendly competition isn't bad.
    At times, it's far from friendly, which is what I'm trying to avoid.

    - if you're going to make claims that perl is better than python, then you should at least understand that in order to support your claim you'll have to be able write programs that are a bit more complicated than rot13.
    Oh, so just because I am not proficient with perl, the whole language is terrible? Right.

    - this is how you learn.
    I also have a 1,178 page book that's doing a fine job of teaching me perl, so far.

  6. #6

    Re: Hey Fetzaa, part 2...

    for somebody who claims to be trying to avoid unfriendly interaction, you're being a bit antagonistic.

    and i wasn't saying that just because you're not a perl expert that the language is bad. what i am saying is that in order for a person to claim that one language is inherently better than another (which is what we're both doing, despite what you might think), they should be fairly competent with that language.

    now i'm not picking on you for not being a perl expert. i'm far from a python expert and i'll freely admit that. but, your contention that perl is better than python carries very little weight with me because you really can't show me anything that would lead me to believe that you're correct.


  7. #7

    Re: Hey Fetzaa, part 2...


    I haven't done anything with sockets yet, so you'll have to wait.

    Do you have any idea how utterly pointless this excercise is, btw? The only thing you could possibly hope to prove is that you know more Python than I know Perl.
    use IO::Socket; for socket stuff, and it should be pretty darn easy.

  8. #8

    Re: Hey Fetzaa, part 2...

    for somebody who claims to be trying to avoid unfriendly interaction, you're being a bit antagonistic.
    Maybe I'm just an antagonistic person, and I'm trying to avoid conflict for your benefit, not mine. :P

    but, your contention that perl is better than python carries very little weight with me because you really can't show me anything that would lead me to believe that you're correct.
    You do realize that when I said "Perl is better" (if I in fact said that), I merely meant that I like it more? Jeez :

  9. #9

    Re: Hey Fetzaa, part 2...

    use IO::Socket; for socket stuff, and it should be pretty darn easy.
    You already know more about it than I do.

  10. #10

    Re: Hey Fetzaa, part 2...




    You do realize that when I said "Perl is better" (if I in fact said that), I merely meant that I like it more? Jeez :
    it isn't just the fact that you are blatantly biased toward perl (which is fine, language preferences are just that; preferences), but that you also took every opportunity to crap on python as though it were inferior, not just a language you don't particularly like.

Similar Threads

  1. C++ Journal - Part One
    By peter in forum Tutorials
    Replies: 0
    Last Post: 11-24-2008, 04:52 AM
  2. SCO v. IBM Part Deux
    By mcdougrs in forum General Chat
    Replies: 3
    Last Post: 11-06-2003, 02:37 AM
  3. Children of Dune Part 1
    By Schotty in forum General Chat
    Replies: 1
    Last Post: 03-17-2003, 05:56 AM
  4. Bash Pet - 2nd part
    By civ1492 in forum Linux - General Topics
    Replies: 2
    Last Post: 06-05-2002, 05:03 PM
  5. Using RPM: The Basics (Part I)
    By JimH in forum Redhat / Fedora
    Replies: 3
    Last Post: 08-04-2001, 06:19 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •