On 22/02/2013 18:08, Tiago Hori wrote:
What I was wondering is: is there any way to force perl to use other line
ending characters, like MacOS C
The script below will first read the file for 1000 characters and set
the value of $/.
You can then loop through the lines in the usual way.
#!/usr/bin/perl
use strict;
use Fcntl;
my $file = "/path/to/file";
my $fh;
sysopen( $fh, $file, O_RDONLY );
sysread( $fh, $_, 1000 );
close( $fh );
$/ = /(\015\012|\015|\012)/ ? $1 : "\n";
# test the result:
for (split //, $/) {print ord};
open $fh, $file;
my $counter = 0;
while (<$fh>) {
$counter ++;
print;
last if $counter > 2;
}
# JD
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/