[ale] here's one for the script wizards

Geoffrey lists at serioustechnology.com
Wed Feb 10 10:44:29 EST 2010


Asher Vilensky wrote:
> I need a script that would do this:
> 
> input file (text):
> john (amy) fred (bob) julie (mike).....
> 
> output:
> john fred julie
> 
> (amy) (bob) (mike)        -  optional, with or without parenthesis.
> 
> Perl or bash would do.
> Thanks.

Probably a more elegant way:

#!/usr/bin/perl -w

use strict;

my @arr;
open(FH, "<foo");

while(<FH>) {

             @arr = split();
}
close(FH);

foreach (@arr) {

         /\(/ || print "$_ ";
}
print "\n";

foreach (@arr) {

         /\(/ && print "$_ ";
}
print "\n";

-- 
Until later, Geoffrey

"I predict future happiness for America if they can prevent
the government from wasting the labors of the people under
the pretense of taking care of them."
- Thomas Jefferson


More information about the Ale mailing list