#!/usr/bin/perl -nl use strict; my @fields = split /((?:<[^>]+>|\[[^]]+])+)/; shift @fields if $fields[0] eq ''; print for @fields;