in reply to basic question:how to print a reversed array from STDIN

You also may try the following funny onliner script

perl -pe '$\=$_.$\}{'

Yes, it prints reversed array of lines from STDIN