Ms-Dos and perl

S

Sverre Furberg

Probably OT but...
The output of the script below isn't
what I expect.
Tested it on a computer
with ActivPerl 5.8.6 on MS Win98 SE.
---
#/usr/bin/perl

use warnings;
use strict;

my @lines;

while (<>) {
push @lines, $_;
}

print reverse @lines[-5 .. -1];
---

When I run the script with:
C:\Temp>d_test.plx
one
two
three
four
five
<CTRL>-z

the output is:

four
three
two
one

without printing 'five' first.

Is this a Ms-Dos issue or
am I doing something wrong?

TIA
Sverre
 
B

Brian Wakem

Sverre said:
Probably OT but...
The output of the script below isn't
what I expect.
Tested it on a computer
with ActivPerl 5.8.6 on MS Win98 SE.
---
#/usr/bin/perl

use warnings;
use strict;

my @lines;

while (<>) {
push @lines, $_;
}

print reverse @lines[-5 .. -1];
---

When I run the script with:
C:\Temp>d_test.plx
one
two
three
four
five
<CTRL>-z

the output is:

four
three
two
one

without printing 'five' first.

Is this a Ms-Dos issue or
am I doing something wrong?


Perhaps 'five' is followed by CR but not LF, so 'four' overwrites it?
 
S

Sverre Furberg

Brian Wakem skrev:
Sverre Furberg wrote:

Probably OT but...
The output of the script below isn't
what I expect.
Tested it on a computer
with ActivPerl 5.8.6 on MS Win98 SE.
---
#/usr/bin/perl

use warnings;
use strict;

my @lines;

while (<>) {
push @lines, $_;
}
print "\n";
print reverse @lines[-5 .. -1];
---
Perhaps 'five' is followed by CR but not LF, so 'four' overwrites it?
Putting in a: print "\n"; did the trick so I guess you were right.
Thanks
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top