I have a CSV file my.csvwith this content:
abc,yyy
efg,zzz
zsc,vvv
uvw,ggg
Depending on the value in the variable, $XI need to read from this particular value to the end of the file. For instance:
If $X = efg, the output will be:
efg,zzz
zsc,vvv
uvw,ggg
For $X = zsc:
zsc,vvv
uvw,ggg
This is a created script that reads all content in a CSV file and displays it:
use strict;
use warnings;
open(my $data, '<', $file) or die "Could not open '$file' $!\n";
while (my $line = <$data>) {
chomp $line;
my @field = split "," , $line;
print "$field[0] $field[1]";
}
Please help me with the script to display the above script.
source
share