Re: Read file symbol by symbol?
Jonathan E. Paton wrote: You don't want to, reading one character at a time is VERY slow. At worst, the operating system will cut short your time slot whilst it waits for the file access - perhaps limiting you to a few dozen characters per second... if you care much for that approach, have a look at sysopen/sysread. A better approach is to read a line at a time, and split it down into symbols. However, it's unlikely you actually need to do this in Perl. This works: my @chars = split //, $string; The best approach, is to read fixed sized blocks with sysread and then split into symbols. NB: I said you rarely need to split into symbols, why? Because Perl has one of the most expressive regular expression engine in existance, that does almost all the text manipulation you could ever require. If it's not text manip, I'd like to know what happens to these symbols :) Take care, Jonathan Paton I want to translate text files on Russian koi-8r under Linux into Microsoft Windows-1251 keytables. So why I need read ALL symbols (also CR and LF). And, anymore, I want to change the lenght of the lines during this recoding. I am trying this: $char=getc TXT; -- ---! My blessing! Ramis. ! ---! http://www.samtan.fromru.com mailto: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Read file symbol by symbol?
Friends, how read a file one by one symbols, not a whole string once at time? Thanks. -- ---! My blessing! Ramis. ! ---! http://www.samtan.fromru.com mailto: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Read file symbol by symbol?
Here is one script I used to inspect files use strict; my $fn; printEnter the name of a file you want to examine ; while () { $fn = $_; last if $fn; } print Opening $fn\n; open TF, $fn or die Cannot open $fn:$!\n; my @ov; my $ov; while (TF) { @ov = unpack('U*',$_); print; print\t\t; foreach $ov (@ov) { print-$ov-; } print \n; } close TF; HTH Ramis [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Friends, how read a file one by one symbols, not a whole string once at time? Thanks. -- ---! My blessing! Ramis. ! ---! http://www.samtan.fromru.com mailto: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Read file symbol by symbol?
how read a file one by one symbols, not a whole string once at time? You don't want to, reading one character at a time is VERY slow. At worst, the operating system will cut short your time slot whilst it waits for the file access - perhaps limiting you to a few dozen characters per second... if you care much for that approach, have a look at sysopen/sysread. A better approach is to read a line at a time, and split it down into symbols. However, it's unlikely you actually need to do this in Perl. This works: my @chars = split //, $string; The best approach, is to read fixed sized blocks with sysread and then split into symbols. NB: I said you rarely need to split into symbols, why? Because Perl has one of the most expressive regular expression engine in existance, that does almost all the text manipulation you could ever require. If it's not text manip, I'd like to know what happens to these symbols :) Take care, Jonathan Paton __ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]