$_ = 'FDR [62.10060.051-F] [62.10051.381] [this includes spaces!] 0 1 0'; @parts = /\[.*?\]|[^\[\]\ ]+/g; $\ = "\n"; print for @parts;