Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > what's wrong with <DATA>

Reply
Thread Tools

what's wrong with <DATA>

 
 
Dr.Ruud
Guest
Posts: n/a
 
      04-04-2006
Ch Lamprecht schreef:


> [backticks change the behaviour of <DATA>]
> On WinXP, -in case the file has CRLF EOLs- this prints:
>
> 1 123.txt
> 2
> 3 456.txt
> 4
> 5 789.txt


Looks like an implicit (lexical/local?) 'binmode' is performed, if
backticks.

--
Affijn, Ruud

"Gewoon is een tijger."

 
Reply With Quote
 
 
 
 
Josef Moellers
Guest
Posts: n/a
 
      04-04-2006
cyl wrote:
> My script is written in Windows so it has CRLF in the end of a line. I
> tested it again in both Windows and Linux and only got this problem in
> Windows. If I convert the CRLF to LF, the problem disappears. Another
> interesting thing to me is that if I comment the system call, the
> problem won't happen either even with CRLF in the end. Like this
>
> $i=1;
> while(<DATA>){
> #$x=`dir $_`;
> print $i++.". $_";
> }
> __DATA__
> 123.txt
> 456.txt
> 789.txt
>
> output is
> 1. 123.txt
> 2. 456.txt
> 3. 789.txt
>
> so there might be something during the system call that affect the file
> handle DATA?
>


What happens if you leave out the "print", or redirect it into another
file (print STDERR ..., then redirect stderr into another file)?

--
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett

 
Reply With Quote
 
 
 
 
Dr.Ruud
Guest
Posts: n/a
 
      04-04-2006
Ch Lamprecht schreef:

> ` `;


Backticks in a void context, could be another special case as well.

--
Affijn, Ruud

"Gewoon is een tijger."
 
Reply With Quote
 
Ch Lamprecht
Guest
Posts: n/a
 
      04-04-2006
Dr.Ruud wrote:
> Ch Lamprecht schreef:
>
>
>
>>[backticks change the behaviour of <DATA>]
>>On WinXP, -in case the file has CRLF EOLs- this prints:
>>
>>1 123.txt
>>2
>>3 456.txt
>>4
>>5 789.txt

>
>
> Looks like an implicit (lexical/local?) 'binmode' is performed, if
> backticks.
>

It does not seem to be a matter of scope- this one still shows the same
output:

use warnings;
use strict;
while(<DATA>){
b_t();
print "$. $_";
}
sub b_t{
` `;
#system ('echo test');
}
__DATA__
123.txt
456.txt
789.txt

You can as well replace the backticks with a system call - that won't
change anything ether.

Christoph
--

perl -e "print scalar reverse q/(E-Mail Removed)/"
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Have I bought wrong product? enquirer Wireless Networking 2 06-10-2005 10:59 PM
Zero Config keeps connecting to the wrong AP =?Utf-8?B?ZGdyaWZmaXRo?= Wireless Networking 2 03-04-2005 05:52 PM
Is XML Doc wrong or is Schema wrong? (or both) Matthew XML 7 01-07-2005 10:05 PM
wrong connection status Peter Welk Wireless Networking 0 12-22-2004 03:26 PM
XP SP2 Wrong IP on connection D Wells Wireless Networking 3 12-09-2004 03:35 AM



Advertisments