CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced: Re: [rfransix] Matching Unique Field with Action: Edit Log



Karazam
User

Mar 8, 2011, 11:30 AM


Views: 5483
Re: [rfransix] Matching Unique Field with Action

Ok, this comes to mind, but is starts to be perhaps a little too much to cram into a oneliner:


Code
perl -ane "for $i (0 .. $#F) { print qq($F[$i] ) unless $i == 1 and /\./; } print qq(\n);" in.file


Personally, I'd prefer a script at this point:


Code
#!/usr/bin/perl 
use warnings;
use strict;

while (<>) {
my @a = split;
for my $i ( 0 .. $#a ) {
print "$a[$i] " unless $i == 1 and $a[$i] =~ /\./;
}
print "\n";
}



(This post was edited by Karazam on Mar 8, 2011, 11:37 AM)


Edit Log:
Post edited by Karazam (User) on Mar 8, 2011, 11:37 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives