Jose Alves de Castro wrote:
To make it short: I have a small filter that I'd like to keep as compact
 as possible, while not losing efficiency.

How it works:

1) ignore the first line (it's a header line)
2) if a line ends in a tab, remove that character
3) replace all tabs with pipes
4) if the line now ends in a pipe, add a space at the end

This all looks pretty easy, right?

Change that to three steps:

1) ignore the first line (it's a header line)
2) replace all tabs with pipes
3) if a line ends in a pipe, change it to a space.

Even easier.


So, here's an attempt:

#!/usr/bin/perl -lwn
use strict;

$. - 1 || next;
s/\t$//;
y/\t/|/;
s/\|$/ /;
print;

#!/usr/bin/perl -lwp use strict;

$. - 1 || next;
y/\t/|/;
s/\|$/ /;



John
--
use Perl;
program
fulfillment

Reply via email to