Thanks for the tip, BrowserUk. Always fun to learn a new trick.

I've generalized your code to match any column, where i is the column:

perl -F, -anE '$m<($x=length $F[i]) and $m=$x}{say $m' file.csv

I'd still use yours if I'm only looking in the first column. I wonder if there's a way to continue on that same idea (using index) and count delimiters out to a particular column and then save the distance between the most recent delimiters. Probably wouldn't be a one-liner at that point.

Also, curious about your use of $1. Is it a shell variable? Executing your command as written (in bash) doesn't give me any output, I have to switch the single and double quotes. Then I have to use a different variable, Perl won't let me assign to $1.

Strange things are afoot at the Circle-K.

In reply to Re^2: Delimited File Analysis One-Liner? by temporal
in thread Delimited File Analysis One-Liner? by temporal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.