[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] here's one for the script wizards
- Subject: [ale] here's one for the script wizards
- From: lists at serioustechnology.com (Geoffrey)
- Date: Wed, 10 Feb 2010 10:44:29 -0500
- In-reply-to: <[email protected]>
- References: <[email protected]>
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