title: How can I get the length of the longest value in a CSV column?
body: <p>I am new to Perl. I'm stuck formatting and displaying the data. I need to read the data from CSV file and print it on screen in proper formatting. The width of each column is decided by the maximum length of the element present in the column.</p>
  <pre><code>my $file = $ARGV[0] or die; 
  open(my $data, '&lt;', $file) or die; 
  my $max = 0;
  
  while (my $line = &lt;$data&gt;)  
  { 
      chomp $line; 
  
  
  # Split the line and store it 
  # inside the words array 
  my @words = split &quot;, &quot;, $line;   
  my @C = split( &quot;,&quot;, $line);
  #$max = length $C[1];
  print (&quot;%08c&quot;, &quot;$C[2]\n&quot;);
  for (my $i = 0; $i &lt;= 2; $i++) 
  { 
      #print &quot;$words[$i] &quot;; 
  } 
  #print &quot;\n&quot;; 
  
  
  } 
  
  
  
   print &quot;maximum:max($max)\n&quot;;
  </code></pre>