http://qs321.pair.com?node_id=30151

ANKUR has asked for the wisdom of the Perl Monks concerning the following question:

HI
This is just another perl newbie here.Thanks every1 for replying to my question about merging files.
.Phew! i really do have a long way to go. Anyway i was going through some C exercises i had done previously and i came across an interesting
exercise. You have to write a program to produce
the following output
Well, um i wrote the code , but since er i just baby talk perl,
the code is very big i just know that there
is a more better and more intelligent way to do it
.I will really appreciate your help perl monks if you kindly
SHOW A BETTER WAY TO DO IT
THANKS ankur
ABCDEFGFEDCBA ABCDEF FEDCBA ABCDE EDCBA ABCD DCBA ABC CBA AB BA A A <CODE> #!/usr/bin/perl -w @store=('a'..'g'); $i=@store; $count=0; while($i>=0){ &printline($i-1,@store); &revline($i-1,$count,@store); $count++; pop(@store); } sub printline{ ($itemp,@printarray)=@_; for($j=0;$j<=$itemp;$j++){ print "$printarray[$j]"; } } sub revline{ ($it,$cou,@linarray)=@_; if ($cou==0){ for($k=$it;$k>=0;$k--){ print "$linarray[$k]"; } print '/n'; return; } $p=$cou-1; $r=2*$p + 1; for ($j=1;$j<=$r;$j++){ print " "; } for($k=@linarray-1;$k>=0;$k--){ print "$store[$k]"; if ($k==0){ print '\n' ; } } }
er i dont know formatting yet