For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > January 2006 > FW: removing line feeds









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author FW: removing line feeds
Bruce Bowen

2006-01-21, 6:56 pm



On Jan 21, 2006, at 21:43, Bowen, Bruce wrote:

> Perhaps that file has mixed newline conventions? Does
>
> $entire_file_content =~ tr/\015\012//d;
>
> do what you need?
>
> -- fxn
>
> That did not work. I've looked into the file with a hex editor it
> that's telling me there's a
> hex 0D 0A 0D 0A after each |FS. I've tried all of the combinations
> I can think of, none of which had any effect. The process seems to
> work up to the first time it gets to that hex data.


Looks like you've got a bug or some wrong assumption, would you
please send the code?

-- fxn

use warnings;

# Root directory...
my $rootdir = "C:\\diebold\\ddc2005\\";

# Get all the arguments and determine the number of arguments...
my @args = @ARGV;
my $args = @args;

my $source = $args[0];

$/ = "";

opendir DH, "C:\\diebold\\ddc2005\\hooks\\";

open SCREEN, "C:\\diebold\\ddc2005\\hooks\\".$source;
$SCREEN = <SCREEN>;

$SCREEN =~ s/\n//g;
$SCREEN =~ s/\r//g;

my $ds_in = index($SCREEN, "\|DS");
$SCREEN = substr($SCREEN, $ds_in+3);

@screens = split/\|FS/, $SCREEN;
my $count = @screens;

for ($i = 0; $i < $count; $i++)
{
my $SCR = substr($screens[$i], 0, 3);
my $DIR = substr($screens[$i], 7, 3);
#print "DIR = ", $DIR, "\n", "SCR = ", $SCR, "\n";

my $text = substr($screens[$i], 4);
open FILE, "> C:\\diebold\\ddc2005\\Lang".$DIR."\\SCR".$SCR.".TXT" or die;
#print "scr = ", $SCR, "\n", $screens[$i], "\n", "I = ", $i, "\n";
print (FILE $text);
}
close DH;
exit;

Code and file.

Bruce

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com