Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Perl to parse a CSV file from a particular row to the end of the file
    text
    copied!<p>am very new to Perl and need your help</p> <p>I have a CSV file <code>xyz.csv</code> with contents:</p> <p><strong>here level1 and er values are strings names...not numbers...</strong></p> <pre><code>level1,er level2,er2 level3,er3 level4,er4 </code></pre> <p>I parse this CSV file using the script below and pass the fields to an array in the first run</p> <pre><code>open(my $d, '&lt;', $file) or die "Could not open '$file' $!\n"; while (my $line = &lt;$d&gt;) { chomp $line; my @data = split "," , $line; @XYX = ( [ "$data[0]", "$data[1]" ], ); } </code></pre> <p>For the second run I take an input from a command prompt and store in variable <code>$val</code>. My program should parse the CSV file from the value stored in variable until it reaches the end of the file</p> <p>For example </p> <p>I input <code>level2</code> so I need a script to parse from the second line to the end of the CSV file, ignoring the values before <code>level2</code> in the file, and pass these values (<code>level2</code> to <code>level4</code>) to the <code>@XYX = (["$data[1]","$data[1]"],);}</code></p> <pre><code>level2,er2 level3,er3 level4,er4 </code></pre> <p>I input <code>level3</code> so I need a script to parse from the third line to the end of the CSV file, ignoring the values before <code>level3</code> in the file, and pass these values (<code>level3</code> and <code>level4</code>) to the <code>@XYX = (["$data[0]","$data[1]"],);}</code></p> <pre><code>level3,er3 level4,er4 </code></pre> <p>How do I achieve that? Please do give your valuable suggestions. I appreciate your help</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload