{OT} Perl Question

Discussion in 'UK Motorcycles' started by Desmond Coughlan, Sep 29, 2003.

  1. .... just a small question concerning a ****-up that I witnessed two days
    ago, at the University of Paris, whilst observing matriculations. A
    student [1] managed to enroll himself for two different 'options', both
    taking place on the same day, at the same time, but in two different
    locations. As the person doing the enrollments was using seven different
    Word for Windows documents, no one noticed the error until later.

    So I decided to try to write something in Perl, to place student names and
    options into a hash, and to 'flag' the user, if there is a conflict. Thing
    is, the more I get into it, the more it seems to me that what I really need
    is SQL, and my knowledge of that particular monstrosity, is weak to say the
    least.

    So the question is: four hundred students, each student enrolling for eight
    different classes. Is this possible without SQL ?


    [1] no, it wasn't me !
     
    Desmond Coughlan, Sep 29, 2003
    #1
    1. Advertisements

  2. Desmond Coughlan

    paul Guest

    Yes.

    HTH.

    Paul
     
    paul, Sep 29, 2003
    #2
    1. Advertisements

  3. Desmond Coughlan

    Ginge Guest

    Yes, that's what the students are doing right now.
     
    Ginge, Sep 29, 2003
    #3
  4. Desmond Coughlan

    Steve Guest

    Organising[1] this sort of information in Word documents is the start of
    your problems, at least use a spreadsheet[2].

    [1] Tenuous
    [2] Although a database of some sort would be better
     
    Steve, Sep 29, 2003
    #4
  5. What I envisaged doing, was a hash, feeding in <STDIN> progressively, and
    .... oh, ****, I have until next year to do it, so I'll off back to the
    books. :)
     
    Desmond Coughlan, Sep 29, 2003
    #5
  6. Fugoff. Nah, I've been mucking around with _Learning Perl_ in my spare
    time, and wondering, 'What the **** do I need to know Perl for ??'

    Well I don't. But now I at least have an excuse to learn it.
     
    Desmond Coughlan, Sep 29, 2003
    #6
  7. Desmond Coughlan

    Sean Doherty Guest

    Yes. Can't see why hashes can't do it. Get the Camel book for
    starters and I'd recommend The Perl Cookbook by the same publishers
    for useful bits and bobs.

    The learning process goes something like this:

    a> Find something to do
    1> Try.
    2> Fail.
    3> Try again
    4> Fail some more.

    After a few million iterations of the above, it becomes clearer.
     
    Sean Doherty, Sep 29, 2003
    #7
  8. Le Mon, 29 Sep 2003 15:14:26 +0100, Sean Doherty <> a écrit :

    { snip }
    I've got the complete 'Perl' CD-ROM ('learning ..', 'Programming'
    ...,'cookbook', etc.etc).

    The problem isn't that hashes can't do it, it's that my knowledge is not
    yet deep enough to allow me to manipulate them the way I want to.
    Something like ...

    while () {
    chomp ($option1 = <STDIN>);
    $option1 =~ tr /A-Z/a-z ;
    $option1 = $hash{something};
    ...

    .... and there it goes pear-shaped.

    Like I say ... now that I know it can be done, it's back to the books.
     
    Desmond Coughlan, Sep 29, 2003
    #8
  9. Desmond Coughlan

    Steve Guest

    [snip]
    I figure if you're going to the trouble of learning Perl, you may as well
    learn SQL.

    3 tables:

    #1: Student (one per student)
    #2: Class (holds the class and its weekday/time/duration)
    #3: StudentClass (maps between Student and Class for each class attended by
    each student)

    then query them with a single piece of SQL to find out (in a single
    statement) where the time/day conflicts lie. Easy, concise and fast. I'll
    write the SQL for you if you like.
     
    Steve, Sep 29, 2003
    #9
  10. Steve wrote
    Reconcile that to my satisfaction then.
     
    steve auvache, Sep 29, 2003
    #10
  11. { snip }

    Well learning Perl is a pasttime, so no hurry. Then again, as my cat
    jumped up behind the server last night, and ripped the keyboard cable out
    of the machine (leaving the metallic part in the socket), I now have no
    functionning PC at home (and am writing this in a Uni. computer lab).
     
    Desmond Coughlan, Sep 29, 2003
    #11
  12. Desmond Coughlan

    Steve Guest


    Easy, you just take the whole sentence in context by adding the "if you
    like" bit to the end of the last sentence. You can still learn even if
    you're given an example to learn from (if you're going to be picky :).
     
    Steve, Sep 29, 2003
    #12
  13. Steve wrote
    pardon?
     
    steve auvache, Sep 29, 2003
    #13
  14. Desmond Coughlan

    Steve Guest

    [snip]I'm not qualified I'm afraid.
     
    Steve, Sep 29, 2003
    #14
  15. Desmond Coughlan

    ogden Guest

    5> Try again
    6> Flame everyone else in the world for doing it a different way,
    and probably in Python or something.
     
    ogden, Sep 29, 2003
    #15
  16. Desmond Coughlan

    Simian Guest

    Desmond Coughlan :

    It's mind-bogglingly trivial.
     
    Simian, Sep 29, 2003
    #16
  17. Desmond Coughlan

    mb Guest

    But what if 2 (or more) people have the same name? I mean, aren't most
    French people called Pierre?
     
    mb, Sep 29, 2003
    #17
  18. Desmond Coughlan

    Ginge Guest

    And how did they come up with 8 classes. I mean you have the obvious
    ones...

    1 - Surrendering
    2 - Eating cheese
    3 - Riding bicycles, whilst wearing a string of garlic
    4 - Sitting in a cafe, chain smoking
    5 - Shrugging

    But the other 3 elude me completely.
     
    Ginge, Sep 29, 2003
    #18
  19. Desmond Coughlan

    YTC#1 Guest

    sort

    then pipe to awk, store field, read next record and compare

    QED.
     
    YTC#1, Sep 29, 2003
    #19
  20. Desmond Coughlan

    Verdigris Guest

    On Mon, 29 Sep 2003 13:42:01 +0000, Desmond Coughlan wrote:

    You could do it in almost any language.

    I'm on a Perl course this week, so if you haven't cracked it by Friday ask
    again and I'll confirm that it's piss easy.
     
    Verdigris, Sep 29, 2003
    #20
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.