#!/usr/bin/env perl use strict; use warnings; my @code_file; my @var_file; my $label_line; while () { if (/\s+EQU\s+\*/) { $label_line = $_; next; } next if ! $label_line; push @{/\A\s*DC/ ? \@var_file : \@code_file}, "$label_line$_"; $label_line = ''; } print join "\n", "CODE_FILE:", @code_file, "VARIABLE_FILE:", @var_file; __DATA__ LABEL#1 EQU * $MAC ABORT LABEL#2 EQU * $NOT UPDATE,STOP T#TAB1 EQU * DC AL4(-1)