 <p>The data you have published is not the same as you used in your test.</p> <p>This program checks <em>both</em> of the regex patterns against the data copied directly from an edit of your original post. Neither pattern matches any of the lines in your data</p> <pre><code>use strict; use warnings; use 5.010; my (%STA_DATA, $file, $path); while ( &lt;DATA&gt; ) { if ( /^-?\s{1,2}Arrival\sTime/ ) { say 'match1'; $STA_DATA{$file}{$path}{Arrival_Time} = m/\sArrival\sTime\s+(.*)\s+$/ } if ( /^-\sArrival\sTime/ or m/^\s{1,2}Arrival\sTime/ ) { say 'match2'; $STA_DATA{$file}{$path}{Arrival_Time} = m/\sArrival\sTime\s+(.*)\s+$/ } } __DATA__ Arrival Time 3373.000 - Arrival Time 638.700 | 100.404 Arrival Time Report </code></pre>