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 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 =20
> text (including the |fs). texttext|fstexttexttext|fs
>
> I know how to get rid of the carriage returns using s/\n//g, but =20
> haven't had any luck in finding the way to get rid of the line =20
> feeds following the |fs.
Perhaps that file has mixed newline conventions? Does
$entire_file_content =3D~ 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=20
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
--=20
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>
| |
| Tom Phoenix 2006-01-21, 9:55 pm |
| On 1/21/06, Bowen, Bruce <Bowenb@diebold.com> 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
|
|
|
|
|