I would like to print specific data after matching a pattern or line. I have a file like this:
#******************************
List : car
Design: S
I got your code to work with a couple small tweaks. It's still not perfect but it works.
Code:
$file_to_get = "input_file.txt";
open (FILE, $file_to_get) or die $!;
my @array;
while (@array = ) {
$i = 0;
foreach my $line (@array) {
if ($line =~ m/(Car)((.*))/) {
my $a = $array[$i+2];
push (@array, $a);
print $a;
}
$i++;
}
}
close(FILE);