openoffice question

Madison Kelly linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org
Tue Sep 30 22:08:35 UTC 2008


phiscock-g851W1bGYuGnS0EtXVNi6w at public.gmane.org wrote:
> Could you use a SED script to place a dash at the begging of each line?
> 
> Peter

Meh, it's not the solution I was thinking of, but it wasn't hard to 
implement. I wanted a little more advanced options though (mainly in 
deciding what lines for a hyphen and how deep in) so I whacked out a 
perl script. I just had it read from the file and print to STDOUT, which 
I redirected to a new file when I was happy.

In case it saves anyone some time (ha!), here it is for glorious benefit 
of great public domain.

Thanks for the train of thought I missed!

madi

-=-=-=-=-=-=-=-
#!/usr/bin/perl

use strict;
use warnings;
use IO::Handle;

my $file="./to_hyphen";
my $read=IO::Handle->new();
open ($read, "< $file") or die "Couldn't read: [$file], error was: $!\n";
while (<$read>)
{
	chomp;
	my $line=$_;
	if (( $line ne "" ) && ( $line !~ /^\w\w\w. \d/ ) && ( $line !~ /\w+; 
\d/ ))
	{
		if ( $line =~ /\t/ )
		{
			$line="  - ".$line;
		}
		else
		{
			$line="- ".$line;
		}
	}
	print "$line\n";
}
$read->close();
-=-=-=-=-=-=-=-
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list