On 2013-01-08 13:28, punit jain wrote:

{
test = ("test123");
test = ("test123","abc");
test = ("test123","abc","xyz");
}
{
test1 = ("passfile");
test1 = ("passfile","pasfile1");
test1 = ("passfile","pasfile1","user");
}

and so on ....

The requirement is to have the file parsing so that final output is  :-

test = ("test123","abc","xyz");
test1 = ("passfile","pasfile1","user");

So basically only pick the lines with maximum number of options for each
type.

Or just print the last long line:

echo '{
test = ("test123");
test = ("test123","abc");
test = ("test123","abc","xyz");
}
{
test1 = ("passfile");
test1 = ("passfile","pasfile1");
test1 = ("passfile","pasfile1","user");
}
' |perl -wne'$o=$n||0;$p=$_,next if($n=length)>$o;$n=3;print$p'

test = ("test123","abc","xyz");
test1 = ("passfile","pasfile1","user");


Which preserves order too. :)

--
Ruud


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to