# regex /.{0,3}X.{0,3}/
#
# string matched part
123X123 123X123
12X123 12X123
1X123 1X123
X123 X123
X123456 X123
####
# regex /.{3}X.{3}/
#
# string matched part
123X123 123X123
12X123 -no match-
1X123 -no match-
X123 -no match-
X123456 -no match-
####
# open my $fh, '<', $file_path or die "unable to read $file_path"
# list context: every line goes in the array
my @all_lines = <$fh>;
# scalar context: just next line goes into a scalar (<> acts as an iterator here)
my $line = <$fh>;
# so to read a file one line at time:
while (defined( my $line= <$fh>)) {