in reply to Re: An efficient way to gather a common portion of several strings' beginnings
in thread An efficient way to gather a common portion of several strings' beginnings

The  m[(^\0+)] match results in an undefined value for  $mask when there is no common base substring at all, which then hiccups a "Use of uninitialized..." warning in the substr expression (if warnings are enabled). Happily, this is easily fixed by using  m[(^\0*)] instead!


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^3: An efficient way to gather a common portion of several strings' beginnings
by BrowserUk (Patriarch) on Nov 15, 2015 at 17:38 UTC

    Good catch and nice solution; but if the OP is expecting there to be a common prefix to his lines, then that warning might be a godsend in the event of a dataset where that is not the case.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.