Hello,
Can someone help me with some direction? I'm trying to write a Perl script that will read each line and if the "Car" string matches the next line string "Car" it will assign "Black" to a variable and then do the same for string "Car" Yellow as a different variable and so forth.
Sample Data:
Car Red 100
Car Black 100
Car Yellow 100
Bus Green 400
Truck Blue 300
open (FILE, 'test.txt') or die "$!\n";
my @line = <FILE>;
foreach my $line (@line) {
chomp $line;
my($car, $color, $amount) = split(/ /, $line);
print "$car $color $amount\n";
}
Thanks!