Win8 Strawberry 5.8.9.5 (32) Thu 07/28/2022 11:22:44 C:\@Work\Perl\monks >perl use strict; use warnings; use Data::Dump qw(dd); use constant FIELDNAME => 'fieldname'; open my $fh, '<', \<; }; dd $got_header; # for debug $got_header =~ m{ \Q${ \FIELDNAME }\E \z }xms or die "no header"; my $header_line = FIELDNAME . <$fh>; # complete the line # and so on... ^Z "no valid header present\nvalue1,value2\n" no header at - line 16, <$fh> line 1.