#! /usr/bin/perl -l use strict; use warnings; while ( ) { if ( $_ =~ m/^X(<.+>(?: X<.+?>){0,4})/ ) { my @matches = map { s/^<+\s*|\s*>+$//g; $_ } split m/\s+X/, $1; print join "--", @matches; } else { print STDERR "no matches."; } } __DATA__ X<$!> X<$ERRNO> X<$OS_ERROR> X<< $< >> X<$UID> X<$REAL_USER_ID> X<$;> X<$SUBSEP> X