newbie question 
Author Message
 newbie question

This is a newbie question:  The following program is supposed to print
"Input names", take user input lines giving first names, print "Last names
follow", and print out the corresponding last names.  When I give it input
by redirection (<) from a file of first names, it works correctly. but when
I give it input from the keyboard, terminated by ctrl-Z, it fails to print
the "Last names follow" line.  I am running Windows 98, 2nd edition, from
the DOS prompt.  Can you tell me what I am doing wrong?

Many thanks

----------------------

#!perl -w
use diagnostics;
use strict;

my %hash = ("fred" => "flintstone", "barney" => "rubble", "wilma" =>
"flintstone",);

print "Input names:\n";


print "Last names follow\n";


{
   print "$hash{$first} \n";

Quote:
}



Thu, 05 Aug 2004 01:43:10 GMT  
 newbie question

Quote:

> #!perl -w
> use diagnostics;
> use strict;

> my %hash = ("fred" => "flintstone", "barney" => "rubble", "wilma" =>
> "flintstone",);

# A little bit easier on the eyes and brain!
my %hash = ( "fred"   => "flintstone",
             "barney" => "rubble",
             "wilma"  => "flintstone",
             );

Quote:

> print "Input names:\n";



my $debug = 1;

Quote:
> print "Last names follow\n";


> {
>    print "$hash{$first} \n";
> }

Did you type a CR before the C-z?

Was the "Last names follow" the only missing line, or were
you missing the rest of the output, too?

See also, some suggestions above.

--
Michael R. Wolf
    All mammals learn by playing!



Fri, 06 Aug 2004 02:41:23 GMT  
 newbie question

Quote:

> This is a newbie question:  The following program is supposed to print
> "Input names", take user input lines giving first names, print "Last names
> follow", and print out the corresponding last names.  When I give it input
> by redirection (<) from a file of first names, it works correctly. but when
> I give it input from the keyboard, terminated by ctrl-Z, it fails to print
> the "Last names follow" line.  I am running Windows 98, 2nd edition, from
> the DOS prompt.  Can you tell me what I am doing wrong?

I don't think you are doing anything wrong. I could be a very subtle bug
as I have noticed something very strange. If you change the line

    print "Last names follow\n";

to

    print "\nLast names follow\n";

the line is printed, but without the first newline. I don't know why,
but it looks like anything upto the first newline is being eating. I
have also tried to insert the line:

    <STDIN>

just before your original print statement. I then have to press the
Enter key after pressing Ctrl-Z, but now the line is printed. This is
very strange indeed.

Michael R. Wolf asked: Did you type a CR before the C-z?
The answer is: it doesn't matter.

Using Win95, ActiveState Perl 5.6.1, build 630

Regards, Ren
--
Using Virtual Access
http://www.vamail.com



Sat, 07 Aug 2004 17:49:12 GMT  
 newbie question
Quote:

> This is a newbie question:  The following program is supposed to print
> "Input names", take user input lines giving first names, print "Last names
> follow", and print out the corresponding last names.  When I give it input
> by redirection (<) from a file of first names, it works correctly. but when
> I give it input from the keyboard, terminated by ctrl-Z, it fails to print
> the "Last names follow" line.  I am running Windows 98, 2nd edition, from
> the DOS prompt.  Can you tell me what I am doing wrong?

[code snipped]

This is a Win95/98 thing, apparently having to do with how ^Z works in
the "DOS Prompt," because it works as you describe here but works
correctly in WinNT (after [1] you take the extra comma out of the end of
your hash definition, and [2] you not only hit ^Z, but you have to hit
return to get command.com to accept the end-of-input command in WinNT).
It is an old behavior, since the Gecko (from which it looks like you
adopted your example) was written back in the days of 5.003/5.004 and I
remember this behavior when I was learning. BTW, if you work things
around to use an array instead of a hash for output, it works as
intended.

Cameron

--
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938



Sun, 08 Aug 2004 00:07:30 GMT  
 newbie question
[ snip ]
Quote:
> it works correctly. but when
> I give it input from the keyboard, terminated by ctrl-Z, it fails to print
> the "Last names follow" line.

[ snip ]

Control-Z?  What OS are you running? If you are running almost
any flavor of Linux/Unix, and you have not changed your default
stty settings, contorl-Z suspends the current process.

Control-D, on the other hand, is the default end-of-file for
the TTY device.  If you have been doing a lot of control-Z's,
I suggest doing a "jobs" command to see just how many hundreds
of suspended processes you have{*filter*} around.

  Peter Rowell

"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of mind-
boggling amounts of excrement when you least expect it."
                       -- Gene "spaf" Spafford (1992)



Sun, 08 Aug 2004 00:42:35 GMT  
 newbie question
Quote:


>[ snip ]
>> it works correctly. but when
>> I give it input from the keyboard, terminated by ctrl-Z, it fails to print
>> the "Last names follow" line.
>[ snip ]

   ^^^^
   ^^^^ snipped too much, and unread at that?

Quote:
>Control-Z?  What OS are you running?

<unsnip>
Quote:
>>>I am running Windows 98, 2nd edition, from the DOS prompt.

</unsnip>

So my guess is he's using Windows 98.

 :-)

--
    Tad McClellan                          SGML consulting

    Fort Worth, Texas



Sun, 08 Aug 2004 08:00:46 GMT  
 newbie question

Quote:


>[ snip ]
>> it works correctly. but when
>> I give it input from the keyboard, terminated by ctrl-Z, it fails to
print
>> the "Last names follow" line.
>[ snip ]
>Control-Z?  What OS are you running? If you are running almost
>any flavor of Linux/Unix, and you have not changed your default
>stty settings, contorl-Z suspends the current process.
>Control-D, on the other hand, is the default end-of-file for
>the TTY device.  If you have been doing a lot of control-Z's,
>I suggest doing a "jobs" command to see just how many hundreds
>of suspended processes you have{*filter*} around.

  >Peter Rowell

Quote:
>"Usenet is like a herd of performing elephants with diarrhea -- massive,
>difficult to redirect, awe-inspiring, entertaining, and a source of mind-
>boggling amounts of excrement when you least expect it."

 >                      -- Gene "spaf" Spafford (1992)

Suggest you read the OP again!

*snip*

Quote:
>>This is a newbie question:  The following program is supposed to print
>>"Input names", take user input lines giving first names, print "Last names
>>follow", and print out the corresponding last names.  When I give it input
>>by redirection (<) from a file of first names, it works correctly. but
when
>>I give it input from the keyboard, terminated by ctrl-Z, it fails to print
>>the "Last names follow" line.  I am running Windows 98, 2nd edition, from

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quote:
>>the DOS prompt.  Can you tell me what I am doing wrong?

*snip*

Otherwise you become "a source of mind-boggling amounts of excrement".
FYI Ctrl-Z is correct for Windoze in this sense.

Regards, Ron Rhodes.



Sun, 08 Aug 2004 03:49:37 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. DOS Trumpet TCP/IP and Pascal 7.0:

2. Newbie Newbie Question

3. Perl and Apache question. (A newbie question)

4. Question : forms processing in perl - newbie question

5. Newbie question (very stupid question I suppose)

6. Newbie question about SendMail (I think that is what my question is about :)

7. Help: Turbo Pascal Lex & Yacc by Albert Graef

8. Error "Non-blob column in table required to perform operation"

9. Q:RowChange in a DBGrid

10. Software Programmer's Online Toolbox

11. Help with Printing in a specific font

12. Have I found a bug in DBGrid?

 

 
Powered by phpBB® Forum Software