Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert Form Feed to new line

Status
Not open for further replies.

Bluejay07

Programmer
Mar 9, 2007
780
CA
Hello,

I have never used Perl although I'm trying to modify some code.

From a unix system, a line of text might end with \f\n.
Is it possible to convert \f to \n so that the line would end with \n\n?

I have found the following although it doesn't appear to work.
Code:
$temp=~s/\f/\n/g;

I could also remove the \n and then \f
Code:
    if ($temp=~/\n/) {
      chop($temp);
      }
    if ($temp=~/\f/) {
      chop($temp);
      }
Do this, I would like to add a \n although I'm not sure how.
I've tried a few things, such as
Code:
$temp=$temp."\n";

I don't know if I'm even using proper syntax or not.

Any help would be appreciated.

Thanks.

If at first you don't succeed, then sky diving wasn't meant for you!
 
There is no [tt]\f[/tt] char in Windows systems output strings, [tt]\r[/tt] might be used instead.
With Perl you simply use [tt]\n[/tt] that is converted, when sent to an output device, to the proper sequence depending on operating system.
If you want an additional new line in your string, just append a newline char: [tt]$temp.="\n";[/tt]

: Online engineering calculations
: Magnetic brakes for fun rides
: Air bearing pads
 
Hi prex1,

Thanks for the reply.
The file is being created on a unix system, processed through a program to convert it to a pdf file then viewed on a windows system.
I'm not entirely certain although I'm relatively confident that the file does have a \f.

I'll try your suggestion for appending a newline character.

Thank you.

If at first you don't succeed, then sky diving wasn't meant for you!
 
the unix shell command tr (translate) is often used to accomplish that conversion

==================================
advanced cognitive capabilities and other marketing buzzwords explained with sarcastic simplicity


 
@johnherman,

Thanks for the reply and the information.
Good to know!

If at first you don't succeed, then sky diving wasn't meant for you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top