HP3000-L Archives

January 2002, Week 5

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Danny van Delft <[log in to unmask]>
Reply To:
Danny van Delft <[log in to unmask]>
Date:
Wed, 30 Jan 2002 03:46:53 -0600
Content-Type:
text/plain
Parts/Attachments:
text/plain (36 lines)
In article <[log in to unmask]>, "Gregory.Stigers"
<[log in to unmask]> wrote:

> Unfortunately, I am getting a file that needs to be manipulated before
> printing, and perl is the hammer that I have available, so this problem
> looks all the more like a nail. One of the shortcomings of this file is
> that on our system, at one point on the page, lines are printing one
> line higher than they should. What is unique between the good line and
> the bad line is that the line ends with some spaces and the numeral 2,
> and is followed by four new lines. There is another line that ends with
> spaces and 2, followed by two new lines, and other lines than end with 2
> as part of a date, followed by new lines. I thought it would be a simple
> matter to find space 2\n\n\n, and replace with space 2\n\n\n\n: perl -pi
> -e 's/  2\n\n\n/  2\n\n\n\n/' FILENAME
>
> And it's not working. And I am not sure why it is not working. Can
> someone tell me why not, and what would work, instead?
>

As already said, the -p flag reads by default per line. But, you can
define what a "line" ends with is by setting the $/ variable.
Try something like:

perl -pi -e 'BEGIN{$/=" 2\n\n\n\n";} {s/ 2\n\n\n([^\n])/ 2\n\n\n\n$1/g;}'

This will read the file in chunks with the correct ending,
intermediate incorrect endings get substituted.

<snip>

HTH,
Danny

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2