Hi Bruce,

Hex 0D 0A (Carriage Return Line Feed pair) is commonly used in Windows
to signify the end of a line of text. "\n" is supposed to generate an
end of line appropriate for the machine on which Perl is run. On
Windows, 0D 0A is ideal, but 0A often works the same. Hex 0A is also the
standard end of line marker for Unix systems, so a Unix "\n" can appear
to work with Windows data in many cases.

Depending upon the OS your Perl script is running under, 

$a = index($state, "/\n");

will match Hex 2F 0A or Hex 2F 0D 0A.

David Luke, Systems Project Analyst
DMS Enterprise Information Technology Services
Building 4030, Suite 115
4050 Esplanade Way
Tallahassee, Florida 32399-0950
 
(850) 922-7587

-----Original Message-----
From: Bowen, Bruce [mailto:[EMAIL PROTECTED] 
Sent: Monday, February 20, 2006 10:38 PM
To: beginners@perl.org
Subject: bug or am I not understanding?

I have posted question related to this before and have received many
suggestions.

I have a file of varying number of records of varying lengths, delimited
by comas.

022,D,092,000,004,034,000,001,000,000
023,D,031,000,000,000,000,002,000,000
024,@D
,025,000,001,900,900,093,093,900,255,065,000,279,001,028,130,161,037,106
,016,410,017,410,255,255,255,255
026,>,255,255,255,255,255,255,255,255
027,E,034,093,106,396,396,396,396,007

According to the hex editor each line ends in a hex 0D 0A.

My question to the group is why would this line recognize that carriage
return.

open STATE, "STATEFILE.txt" or die;
@lines = split /\n/, <STATE>;


and this not recognize the same character;

open STATE, "STATEFILE.txt" or die;
$state = <STATE>;

$a = index($state, "/\n");

Thanks
Bruce Bowen



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to