#!/usr/bin/perl -wl use strict; print for map { y/[]//d; join " ", reverse split } ; __DATA__ w1 w2 w3 [t4 w4] w5