Beginner needs help with script :)

Discussion in 'Perl Misc' started by Player, May 31, 2004.

  1. Player

    Player Guest

    Hello all

    I am teaching myself perl, with the help of a few texts/tutorials and a
    book.
    I have installed the latest Activestate perl build ActivePerl 5.8 on my
    WindowsXP Pro machine.
    Everything seemed to be going alright with the first few scripts, up untill
    I did this one.

    %grades=();

    print "Enter students names (press <CTRL>+D when done): ";
    @names = <STDIN>;
    chomp @names;
    print "\n\n";
    print "Enter associated grades (press <CTRL>+D when done): ";
    @scores = <STDIN>;

    @grades{@names} = @scores

    The problem is when I am inside the command prompt window and run the
    script, i called it gradehash.pl, it runs fine to the first stdin line were
    after I have finished entering the names to go into the @names list, I have
    to press <CTRL>+D in order to stop that stdin and the script to go onto the
    next line.
    By pressing <CTRL>+D alls I get is this ^D coming up insteadof it
    stopping the stdin and going to run the next line of the script.

    Can anyone help me?
    Can I only use <CTRL>+D on a linux setup? and if so what is the windows
    alternative for what I am trying to do in those lines?

    Thanks in advance :)
    Player
     
    Player, May 31, 2004
    #1
    1. Advertising

  2. Gunnar Hjalmarsson, May 31, 2004
    #2
    1. Advertising

  3. Player

    gnari Guest

    "Player" <> wrote in message
    news:c9f1m7$meh$...
    > Hello all
    >
    > I am teaching myself perl, with the help of a few texts/tutorials and a
    > book.
    > I have installed the latest Activestate perl build ActivePerl 5.8 on my
    > WindowsXP Pro machine.
    > Everything seemed to be going alright with the first few scripts, up

    untill
    > I did this one.
    >
    > %grades=();
    >
    > print "Enter students names (press <CTRL>+D when done): ";
    > @names = <STDIN>;
    > chomp @names;
    > print "\n\n";
    > print "Enter associated grades (press <CTRL>+D when done): ";
    > @scores = <STDIN>;
    >
    > @grades{@names} = @scores


    this tutorial seems to be written for unix-like operating
    systems.

    on unix CTRL-D is an end of file character. a similar character
    on windows is CTRL-Z

    this tutorial is just to demonstrate how <> work in a
    list context (read whole file). it is dubious technique to use
    this for interactive user input.

    gnari
     
    gnari, May 31, 2004
    #3
  4. Player

    Paul Lalli Guest

    On Mon, 31 May 2004, Player wrote:

    > Can anyone help me?
    > Can I only use <CTRL>+D on a linux setup? and if so what is the windows
    > alternative for what I am trying to do in those lines?


    The windows equivalent of CTRL-D is CTRL-Z <enter>

    Paul Lalli
     
    Paul Lalli, May 31, 2004
    #4
  5. Player

    Player Guest

    "Gunnar Hjalmarsson" <> wrote in message
    news:...
    > Player wrote:
    > > Hello all

    >
    > Don't post the same question in different messages to multiple newsgroups!
    >
    > --
    > Gunnar Hjalmarsson
    > Email: http://www.gunnar.cc/cgi-bin/contact.pl
    >


    Its a legitimate question posted in two appropriate news groups.
    There is nothing wrong with that what-so-ever, as I am subscribed to both
    news groups and the news groups in questions are both there to offer help
    and advice on perl.
    So what-ever- got up your nose, isn't worth the effort of those few lines
    you wrote, because it's only two news groups and both are there to help
    people with perl.
    So take your bullying tactics else were they are not appreciated here, thank
    you very much.
    Player
     
    Player, May 31, 2004
    #5
  6. Player

    Player Guest

    "Paul Lalli" <> wrote in message
    news:...
    > On Mon, 31 May 2004, Player wrote:
    >
    > > Can anyone help me?
    > > Can I only use <CTRL>+D on a linux setup? and if so what is the windows
    > > alternative for what I am trying to do in those lines?

    >
    > The windows equivalent of CTRL-D is CTRL-Z <enter>
    >
    > Paul Lalli


    Thank Paul I will try that out :)
    Regards Player
     
    Player, May 31, 2004
    #6
  7. Player

    Player Guest

    "Paul Lalli" <> wrote in message
    news:...
    > On Mon, 31 May 2004, Player wrote:
    >
    > > Can anyone help me?
    > > Can I only use <CTRL>+D on a linux setup? and if so what is the windows
    > > alternative for what I am trying to do in those lines?

    >
    > The windows equivalent of CTRL-D is CTRL-Z <enter>
    >
    > Paul Lalli


    No Paul <CTRL>+Z simply did the same as <CTRL>+D did, only it displayed ^Z
    instead of ^D
    I don't understand this at all lol, as <CTRL>+C sends the sig term to quit
    the script ok, but the ctrl+d or ctrl+x simply print ^d and ^x respectively
    on the command console.

    Anyone no what I am doing wrong here?
    Regards Player
     
    Player, May 31, 2004
    #7
  8. Player

    Paul Lalli Guest

    On Mon, 31 May 2004, Player wrote:

    > "Gunnar Hjalmarsson" <> wrote in message
    > news:...
    > > Player wrote:
    > > > Hello all

    > >
    > > Don't post the same question in different messages to multiple newsgroups!

    >
    > Its a legitimate question posted in two appropriate news groups.


    No one's claiming it's not.

    > There is nothing wrong with that what-so-ever, as I am subscribed to both
    > news groups and the news groups in questions are both there to offer help
    > and advice on perl.


    No one's opposing that position either.

    What Gunnar is telling you is that posting the same question IN TWO
    DIFFERENT MESSAGES is rude. The correct etiquete is to type ONE message,
    listing both groups in the Newsgrps: or To: header. That way, people who
    subscribe to both groups don't have to see the same post twice. Please
    learn to follow established Usenet proticol.


    > So what-ever- got up your nose, isn't worth the effort of those few lines
    > you wrote, because it's only two news groups and both are there to help
    > people with perl.
    > So take your bullying tactics else were they are not appreciated here, thank
    > you very much.



    Now *that* was extraordinarily rude, uncalled for, and will likely prevent
    many more people from trying to help you in this group.

    Good day.
     
    Paul Lalli, May 31, 2004
    #8
  9. Player

    gnari Guest

    "Player" <> wrote in message
    news:c9f4g2$e34$...
    >
    > "Paul Lalli" <> wrote in message
    > news:...
    > > On Mon, 31 May 2004, Player wrote:
    > >
    > > > Can anyone help me?
    > > > Can I only use <CTRL>+D on a linux setup? and if so what is the

    windows
    > > > alternative for what I am trying to do in those lines?

    > >
    > > The windows equivalent of CTRL-D is CTRL-Z <enter>
    > >
    > > Paul Lalli

    >
    > No Paul <CTRL>+Z simply did the same as <CTRL>+D did, only it displayed

    ^Z
    > instead of ^D
    > I don't understand this at all lol, as <CTRL>+C sends the sig term to quit
    > the script ok, but the ctrl+d or ctrl+x simply print ^d and ^x

    respectively
    > on the command console.
    >
    > Anyone no what I am doing wrong here?


    are you sure the CTRL-Z is the only character in the line?

    gnari
     
    gnari, May 31, 2004
    #9
  10. Player wrote:
    > Gunnar Hjalmarsson wrote:
    >> Don't post the same question in different messages to multiple
    >> newsgroups!

    >
    > Its a legitimate question posted in two appropriate news groups.


    I did not claim otherwise.

    > There is nothing wrong with that what-so-ever, as I am subscribed
    > to both news groups and the news groups in questions are both there
    > to offer help and advice on perl.


    You obviously haven't learned to distinguish between cross-posting and
    multi-posting. For good reasons, multi-posting is considered wrong by
    the netiquette guidelines.

    http://asg.web.cmu.edu/rfc/rfc1855.html

    <rambling snipped>

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, May 31, 2004
    #10
  11. On Mon, 31 May 2004, Gunnar Hjalmarsson reveals to discerning readers
    that:

    > Player wrote:
    > >
    > > Its a legitimate question posted in two appropriate news groups.

    >
    > I did not claim otherwise.


    Seems to me that the subject line already told us as much as we needed
    to know about the questioner and its attitude to posting guidelines.

    > <rambling snipped>


    Indeed!
     
    Alan J. Flavell, May 31, 2004
    #11
  12. Player

    Player Guest

    "Paul Lalli" <> wrote in message
    news:...
    > On Mon, 31 May 2004, Player wrote:
    >
    > > "Gunnar Hjalmarsson" <> wrote in message
    > > news:...
    > > > Player wrote:
    > > > > Hello all
    > > >
    > > > Don't post the same question in different messages to multiple

    newsgroups!
    > >
    > > Its a legitimate question posted in two appropriate news groups.

    >
    > No one's claiming it's not.
    >
    > > There is nothing wrong with that what-so-ever, as I am subscribed to

    both
    > > news groups and the news groups in questions are both there to offer

    help
    > > and advice on perl.

    >
    > No one's opposing that position either.
    >
    > What Gunnar is telling you is that posting the same question IN TWO
    > DIFFERENT MESSAGES is rude. The correct etiquete is to type ONE message,
    > listing both groups in the Newsgrps: or To: header. That way, people who
    > subscribe to both groups don't have to see the same post twice. Please
    > learn to follow established Usenet proticol.
    >
    >
    > > So what-ever- got up your nose, isn't worth the effort of those few

    lines
    > > you wrote, because it's only two news groups and both are there to help
    > > people with perl.
    > > So take your bullying tactics else were they are not appreciated here,

    thank
    > > you very much.

    >
    >
    > Now *that* was extraordinarily rude, uncalled for, and will likely prevent
    > many more people from trying to help you in this group.
    >
    > Good day.


    No its quit obviously not rude at all.
    I don't like being bullied, its as simple that, and as I am new to news
    groups in general, I am hardly going to no every single detail of what-ever
    bunch of in-house-secret-guidelines people have made up over the years.
    A simple, please, "check this url" followed by the url were the rules sit,
    would of been enough.
    I don't take kindly to people telling me, "DON'T" one something I pay money
    to gain access to, especially when those people are not in any position of
    authority were my money heads to.

    However I can see this from both sides, so as it is my experience that
    people communicating online can often misunderstand and not 'GET' peoples
    senses of humour or manner via simple text, that is what I going to put this
    down to.
    As I obviously thought he was being crude and rather bullyish, when it
    appears he wasn't.

    But in the end I would still say that telling someone 'DON'T in these
    circumstances, is asking form trouble.
    The appropriate response in most cases to such a statement, would be, "I Beg
    your pardon? are some sort of authority figure here?"

    Anyways My Regards to you all
     
    Player, May 31, 2004
    #12
  13. Player

    Player Guest

    "gnari" <> wrote in message
    news:c9f4v9$mqf$...
    > "Player" <> wrote in message
    > news:c9f4g2$e34$...
    > >
    > > "Paul Lalli" <> wrote in message
    > > news:...
    > > > On Mon, 31 May 2004, Player wrote:
    > > >
    > > > > Can anyone help me?
    > > > > Can I only use <CTRL>+D on a linux setup? and if so what is the

    > windows
    > > > > alternative for what I am trying to do in those lines?
    > > >
    > > > The windows equivalent of CTRL-D is CTRL-Z <enter>
    > > >
    > > > Paul Lalli

    > >
    > > No Paul <CTRL>+Z simply did the same as <CTRL>+D did, only it displayed

    > ^Z
    > > instead of ^D
    > > I don't understand this at all lol, as <CTRL>+C sends the sig term to

    quit
    > > the script ok, but the ctrl+d or ctrl+x simply print ^d and ^x

    > respectively
    > > on the command console.
    > >
    > > Anyone no what I am doing wrong here?

    >
    > are you sure the CTRL-Z is the only character in the line?
    >
    > gnari
    >
    >
    >
    >


    Yeah what it is asking is for the reader to to the ctrl+d or ctrl+z to stop
    the stdin and go onto the next line.
    But when pressing ctrl+d or ctrl+z in the windows xp command console black
    window, it simply prints either of these two characters on the command
    console window, ^z ^d

    So as yet I haven't a clue as to what I can do to make the script work.
    Regards Player
     
    Player, May 31, 2004
    #13
  14. Player

    Ben Morrow Guest

    Quoth "Player" <>:
    >
    > > > "Paul Lalli" <> wrote in message
    > > > news:...
    > > > > On Mon, 31 May 2004, Player wrote:
    > > > >
    > > > > > Can anyone help me?
    > > > > > Can I only use <CTRL>+D on a linux setup? and if so what is the

    > > windows
    > > > > > alternative for what I am trying to do in those lines?
    > > > >
    > > > > The windows equivalent of CTRL-D is CTRL-Z <enter>

    >
    > Yeah what it is asking is for the reader to to the ctrl+d or ctrl+z to stop
    > the stdin and go onto the next line.
    > But when pressing ctrl+d or ctrl+z in the windows xp command console black
    > window, it simply prints either of these two characters on the command
    > console window, ^z ^d
    >
    > So as yet I haven't a clue as to what I can do to make the script work.


    Have you tried pressing <Return> after the ^Z? It is necessary under windows.

    Ben

    --
    If I were a butterfly I'd live for a day, / I would be free, just blowing away.
    This cruel country has driven me down / Teased me and lied, teased me and lied.
    I've only sad stories to tell to this town: / My dreams have withered and died.
    (Kate Rusby)
     
    Ben Morrow, May 31, 2004
    #14
  15. Player

    Player Guest

    "Ben Morrow" <> wrote in message
    news:c9f7jm$63g$...
    >
    > Quoth "Player" <>:
    > >
    > > > > "Paul Lalli" <> wrote in message
    > > > > news:...
    > > > > > On Mon, 31 May 2004, Player wrote:
    > > > > >
    > > > > > > Can anyone help me?
    > > > > > > Can I only use <CTRL>+D on a linux setup? and if so what is the
    > > > windows
    > > > > > > alternative for what I am trying to do in those lines?
    > > > > >
    > > > > > The windows equivalent of CTRL-D is CTRL-Z <enter>

    > >
    > > Yeah what it is asking is for the reader to to the ctrl+d or ctrl+z to

    stop
    > > the stdin and go onto the next line.
    > > But when pressing ctrl+d or ctrl+z in the windows xp command console

    black
    > > window, it simply prints either of these two characters on the command
    > > console window, ^z ^d
    > >
    > > So as yet I haven't a clue as to what I can do to make the script work.

    >
    > Have you tried pressing <Return> after the ^Z? It is necessary under

    windows.
    >
    > Ben



    Yeah still no joy, it just moves onto the next line down, and stays there
    waiting for me to type something.
    What it doesnt do is what it's supposed to do, which is to print two blank
    lines via executing the

    print /n/n

    line and then print

    "Enter associated grades (press <CTRL>+Z when done"

    which is were the user of the script is suppposed to type in the numbers to
    go into the list @scores.
    It has me vexed :(
    Regards Player


    > --
    > If I were a butterfly I'd live for a day, / I would be free, just blowing

    away.
    > This cruel country has driven me down / Teased me and lied, teased me and

    lied.
    > I've only sad stories to tell to this town: / My dreams have withered and

    died.
    > (Kate

    Rusby)
     
    Player, May 31, 2004
    #15
  16. Player

    Matt Garrish Guest

    "Player" <> wrote in message
    news:c9f3vl$dk6$...
    >
    > "Gunnar Hjalmarsson" <> wrote in message
    > news:...
    > >
    > > Don't post the same question in different messages to multiple

    newsgroups!
    > >
    > >

    >
    > Its a legitimate question posted in two appropriate news groups.
    > There is nothing wrong with that what-so-ever, as I am subscribed to both
    > news groups and the news groups in questions are both there to offer help
    > and advice on perl.


    That's your own logic. It doesn't hold true for Usenet, though. If you want
    to post to multiple groups, include them all in one message. That way people
    don't have to waste time answering your question in one group when it's
    already been answered in another.

    Matt
     
    Matt Garrish, May 31, 2004
    #16
  17. Player

    Matt Garrish Guest

    "Player" <> wrote in message
    news:c9f6sv$v9g$...
    >
    > I don't take kindly to people telling me, "DON'T" one something I pay

    money
    > to gain access to, especially when those people are not in any position of
    > authority were my money heads to.
    >


    This is not a helpdesk. That you think you have a right to do whatever you
    like because you pay for nntp access is a joke and turns my stomach. What do
    you think everyone else here is doing? We're not here to answer your
    questions.

    Matt
     
    Matt Garrish, May 31, 2004
    #17
  18. Player <> wrote:
    > "Gunnar Hjalmarsson" <> wrote in message
    > news:...



    >> Don't post the same question in different messages to multiple newsgroups!



    [ snip quoted signature, you are not supposed to quote them you know ]


    > So what-ever- got up your nose, isn't worth the effort of those few lines
    > you wrote,



    That is obvious now, seeing as you are sure that you know more about
    netiquette than Gunnar does.

    But when Gunnar wrote it, it was worthwhile, as rude people get killfiled
    and if you had a better attitude you could have avoided some killfiling
    by following his advice ...


    > So take your bullying tactics else were they are not appreciated here,

    ^^^^^^^^^^^^^^^^^^^^
    ^^^^^^^^^^^^^^^^^^^^

    So you have been reading this newsgroup for a long time now and
    know what is expected and appreciated here?

    Or are you just making stuff up?


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, May 31, 2004
    #18
  19. Player

    Player Guest

    "Tad McClellan" <> wrote in message
    news:...
    > Player <> wrote:
    > > "Gunnar Hjalmarsson" <> wrote in message
    > > news:...

    >
    >
    > >> Don't post the same question in different messages to multiple

    newsgroups!
    >
    >
    > [ snip quoted signature, you are not supposed to quote them you know ]
    >
    >
    > > So what-ever- got up your nose, isn't worth the effort of those few

    lines
    > > you wrote,

    >
    >
    > That is obvious now, seeing as you are sure that you know more about
    > netiquette than Gunnar does.
    >
    > But when Gunnar wrote it, it was worthwhile, as rude people get killfiled
    > and if you had a better attitude you could have avoided some killfiling
    > by following his advice ...
    >
    >
    > > So take your bullying tactics else were they are not appreciated here,

    > ^^^^^^^^^^^^^^^^^^^^
    > ^^^^^^^^^^^^^^^^^^^^
    >
    > So you have been reading this newsgroup for a long time now and
    > know what is expected and appreciated here?
    >
    > Or are you just making stuff up?


    'Here' as in, myself.
    That was quit obvious, and what springs to mind to me, is that your simply
    making crap up yourself in order prolong this outright attack on my person
    in the hope I might rise to your baited attacks., and in so doing, entertain
    you in some way.
    It's not me who is carrying on the ranting, it's you lot.
    And yes every single you reply with obnoxious comments, I will fire them
    right back at you again, two fold.
    Player

    >
    >
    > --
    > Tad McClellan SGML consulting
    > Perl programming
    > Fort Worth, Texas
     
    Player, May 31, 2004
    #19
  20. Player <> wrote:


    > No its quit obviously not rude at all.



    If you are new to Usenet then you cannot possibly know what is
    seen as rude and what is not.

    You are making stuff up to justify your mistake.

    That is big of you.


    > I don't like being bullied, its as simple that,



    You were not being bullied.

    You took cuts in line.

    Gunnar said don't take cuts in line.

    You responded that you paid to enter the theme park and that you
    will not wait in line.

    Everybody else paid to enter too, yet you claim that you have
    some special privilege over everyone else?

    Ludicrous!



    In article <>,
    (Larry Wall) wrote: ...

    [snip] I view a programming language as a place to be
    explored, like Disneyland. You don't need to have a lot of preparation
    to explore a theme park. You do have to go along with the crowd
    control measures, though. In a sense, each ride has its own
    prerequisites--if you cut in line, you risk getting tossed out of the
    park.

    What we have here in this newsgroup is a failure in crowd control.
    Reading the FAQ is like staying in line--it's something you should
    learn in kindergarten. Usenet needs a better kindergarten.


    > and as I am new to news
    > groups in general,



    You seem to claim expertise in what is acceptable in newsgroups though.

    How do you justify such a position when you have just gotten here?


    > I am hardly going to no every single detail of what-ever
    > bunch of in-house-secret-guidelines people have made up over the years.



    If you take cuts in line people will not like you.

    If people do not like you, they are not likely to help you.

    Do you want your questions to be answered or ignored? You choose.



    The rudeness of multi-posting and full-quoting are neither secret
    nor in-house. They apply universally to all of the big-8 newsgroups.


    > But in the end I would still say that telling someone 'DON'T in these
    > circumstances, is asking form trouble.



    Sometimes we don't want to take the time to explain the reason
    why you should wait in line, so we just caution you against
    taking cuts.

    If you follow the caution, you'll get more answers.

    If you don't you won't.

    You get to choose.


    > The appropriate response in most cases to such a statement, would be, "I Beg
    > your pardon? are some sort of authority figure here?"



    I Beg your pardon? are some sort of authority figure here?

    Gunnar had been posting here for a long time.

    You just got here.

    Who is more likely to know what is socially acceptable and what is not?



    The killfile is most certainly the Right Place for you.

    So long.

    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, May 31, 2004
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim H
    Replies:
    1
    Views:
    321
    Natty Gur
    Jul 17, 2003
  2. Chung Hang Shum

    A beginner needs help!

    Chung Hang Shum, Sep 3, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    421
    Davide Vernole [MVP]
    Sep 11, 2004
  3. Peter
    Replies:
    10
    Views:
    600
    Marc Nadeau
    Feb 7, 2004
  4. Replies:
    1
    Views:
    362
    David Dorward
    Nov 16, 2005
  5. Kim Forbes
    Replies:
    5
    Views:
    132
    Kim Forbes
    Oct 18, 2004
Loading...

Share This Page