B
Bob Walton
In this program:
#!/usr/local/bin/perl --
use strict;
use warnings;
while(<DATA>){
chomp;
print "read >>$_<<\n";
`rem`; #for Win32 -- just a do-nothing command
}
__END__
Line one
Line two
Line three
I note the output is:
D:\junk>perl junk473.pl
read >>Line one<<
read >><<
read >>Line two<<
read >><<
read >>Line three<<
D:\junk>
An extra pass through the while loop is being taken when the ``'s are
present. If the `rem`; line is commented, the output is as expected:
D:\junk>perl junk473.pl
read >>Line one<<
read >>Line two<<
read >>Line three<<
D:\junk>
Replacing the `rem`; line with system('rem'); results in the same
behavior. The command passed doesn't matter -- valid or invalid.
Without the chomp; line, $_ consists of a newline on the extra passes
through the while loop.
D:\junk>perl -v
This is perl, v5.8.4 built for MSWin32-x86-multi-thread
(with 3 registered patches, see perl -V for more detail)
Copyright 1987-2004, Larry Wall
Binary build 810 provided by ActiveState Corp. http://www.ActiveState.com
ActiveState is a division of Sophos.
Built Jun 1 2004 11:52:21
D:\junk>ver
Windows 98 [Version 4.10.2222]
Does this plague Perl versions other than 5.8.4, or other Windows
versions or other OS's? Thanks.
#!/usr/local/bin/perl --
use strict;
use warnings;
while(<DATA>){
chomp;
print "read >>$_<<\n";
`rem`; #for Win32 -- just a do-nothing command
}
__END__
Line one
Line two
Line three
I note the output is:
D:\junk>perl junk473.pl
read >>Line one<<
read >><<
read >>Line two<<
read >><<
read >>Line three<<
D:\junk>
An extra pass through the while loop is being taken when the ``'s are
present. If the `rem`; line is commented, the output is as expected:
D:\junk>perl junk473.pl
read >>Line one<<
read >>Line two<<
read >>Line three<<
D:\junk>
Replacing the `rem`; line with system('rem'); results in the same
behavior. The command passed doesn't matter -- valid or invalid.
Without the chomp; line, $_ consists of a newline on the extra passes
through the while loop.
D:\junk>perl -v
This is perl, v5.8.4 built for MSWin32-x86-multi-thread
(with 3 registered patches, see perl -V for more detail)
Copyright 1987-2004, Larry Wall
Binary build 810 provided by ActiveState Corp. http://www.ActiveState.com
ActiveState is a division of Sophos.
Built Jun 1 2004 11:52:21
D:\junk>ver
Windows 98 [Version 4.10.2222]
Does this plague Perl versions other than 5.8.4, or other Windows
versions or other OS's? Thanks.