Beginner needs help with script :)

P

Player

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
 
G

gnari

Player said:
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
 
P

Paul Lalli

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
 
P

Player

Gunnar Hjalmarsson said:
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.
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
 
P

Player

Paul Lalli said:
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
 
P

Paul Lalli

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.
 
G

gnari

Player said:
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
 
G

Gunnar Hjalmarsson

Player said:
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>
 
P

Player

Paul Lalli said:
No one's claiming it's not.


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.




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
 
P

Player

gnari said:
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
 
B

Ben Morrow

Quoth "Player said:
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
 
P

Player

Ben Morrow said:
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.
(e-mail address removed) (Kate
Rusby)
 
M

Matt Garrish

Player said:
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
 
M

Matt Garrish

Player said:
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
 
T

Tad McClellan

[ 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?
 
P

Player

Tad McClellan said:
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
 
T

Tad McClellan

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!



[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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top