Re: removing line feeds

2006-01-21 Thread Tom Phoenix
On 1/21/06, Bowen, Bruce <[EMAIL PROTECTED]> wrote:

> I know how to get rid of the carriage returns using s/\n//g, but
> haven't had any luck in finding the way to get rid of the line feeds
> following the |fs.

Have you tried using a substitution? A line feed is often the
character "\x0A", in case that helps. Good luck with it!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: FW: removing line feeds

2006-01-21 Thread Tom Phoenix
On 1/21/06, Bowen, Bruce <[EMAIL PROTECTED]> wrote:

> 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.

Those look like DOS/Windows line-ending codes. They may be translated
into "\n" by the time that your Perl code sees them, though.

It's not hard to find out what you've really got. You can look at the
hex values of the first four characters of a string with code like
this:

print "The start of the string is: ", unpack("H8", $string), "\n";

Does this help you to find out what's going on? Good luck!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




FW: removing line feeds

2006-01-21 Thread Bowen, Bruce


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 =~ 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Swipe.msc
Description: Swipe.msc
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 


Re: removing line feeds

2006-01-21 Thread Xavier Noria

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



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




FW: removing line feeds

2006-01-21 Thread Bowen, Bruce

On Jan 21, 2006, at 17:28, Bowen, Bruce wrote:

> I have files with this format
>
> text
> text
> |fs
>
> text
> text
> text
> |fs
>
> The goal here is to make this data into a flat file of continuous  
> text (including the |fs).texttext|fstexttexttext|fs
>
> I know how to get rid of the carriage returns using s/\n//g, but  
> haven't had any luck in finding the way to get rid of the line  
> feeds following the |fs.

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.

TX,
Bruce Bowen

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: removing line feeds

2006-01-21 Thread Xavier Noria

On Jan 21, 2006, at 17:28, Bowen, Bruce wrote:


I have files with this format

text
text
|fs

text
text
text
|fs

The goal here is to make this data into a flat file of continuous  
text (including the |fs).texttext|fstexttexttext|fs


I know how to get rid of the carriage returns using s/\n//g, but  
haven't had any luck in finding the way to get rid of the line  
feeds following the |fs.


Perhaps that file has mixed newline conventions? Does

$entire_file_content =~ tr/\015\012//d;

do what you need?

-- fxn


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: removing line feeds

2006-01-21 Thread Shawn Corey

Bowen, Bruce wrote:

I know how to get rid of the carriage returns using s/\n//g,

> but haven't had any luck in finding the way to get rid
> of the line feeds following the |fs.

Sorry, \n means a line feed. Try:

  s/\n//g; # Remove line feeds
  s/\r//g; # Remove carriage returns

See:
perldoc perlre
perldoc perlretut
perldoc perlrequick


--

Just my 0.0002 million dollars worth,
   --- Shawn

"Probability is now one. Any problems that are left are your own."
   SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is available at http://perldoc.perl.org/

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




removing line feeds

2006-01-21 Thread Bowen, Bruce
I have files with this format

text
text
|fs

text
text
text
|fs

The goal here is to make this data into a flat file of continuous text 
(including the |fs).texttext|fstexttexttext|fs

I know how to get rid of the carriage returns using s/\n//g, but haven't had 
any luck in finding the way to get rid of the line feeds following the |fs.  

Thanks,
Bruce Bowen