in reply to Re^2: How do I display only matches
in thread (SOLVED) How do I display only matches
No need to chomp if you are just going to add the line ending back in. Forcing at least one space at the beginning of the line narrows things down a lot. Putting in "Directory of" makes it very easy to understand what line of this file you are actually looking for. Please correct me if your dataset if more complicated than you've shown.while (my $line = <$fh>) { print "$line" if $line =~ /^\s+Directory of/; }
I would also add that in my work, keying a regex to a particular column number is usually a bad idea because counting the columns can be error prone and there can be some variance if the file could have been generated with "cut-n-paste". YMMV
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How do I display only matches
by tem2 (Novice) on Sep 24, 2019 at 07:04 UTC |