I would like to print specific data after matching a pattern or line. I have a file like this:
#****************************** List : car Design: S
Here's another option:
use strict; use warnings; print "Car Type\tNo.\n"; while (<>) { if (/#-{32}/) { print "$1\t$2\n" if <> =~ /(\S+)\s+(\S+)/; <>; } }
Output:
Car Type No. N17 bg099 A57 ft2233 L45 nh669
Usage: perl script.pl inFile [>outFile]
perl script.pl inFile [>outFile]
Edit: Simplified