I have a CSV file my.csv
with this content:
abc,yyy
efg,zzz
zsc,vvv
uvw,ggg
Depending upon the value in variable $X
I need to read from that particular value until the end of the file. For example:
If $X = efg
, the output would be:
efg,zzz
zsc,vvv
uvw,ggg
For $X = zsc
:
zsc,vvv
uvw,ggg
This is the script I developed, which reads in a CSV file's whole content 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 a script to display the above mentioned scenario.