in reply to Re: nth field extraction
in thread nth field extraction

Thanks for the (probably obvious) pointer into using a variable in the split command. If I was writing this today, I'd probably have checked to see if that was a possibility. I have a vague memory from back when I wrote the function (15+/- years ago), and couldn't get that construct working.

I was just thinking about that, and remembered that the reason I wrote this was to deal with migrating data from a PICK system to a *nix system, back in the 90's -- so it is a tad older than 15 years... :O

Thanks for the help!

Lee Crites
lee@critesclan.com

Replies are listed 'Best First'.
Re^3: nth field extraction
by AnomalousMonk (Archbishop) on Jul 29, 2018 at 18:43 UTC
Re^3: nth field extraction
by Marshall (Canon) on Jul 29, 2018 at 18:18 UTC
    Thanks for the (probably obvious) pointer into using a variable in the split command. If I was writing this today, I'd probably have checked to see if that was a possibility. I have a vague memory from back when I wrote the function (15+/- years ago), and couldn't get that construct working.

    You might have not recognized the significance of \Q in return (split /\Q$sep/, $source)[ $field-1 ]); The \Q says to ignore any characters in $sep that would otherwise mean something to the regex engine. I often use a \Q...\E pair for this just to highlight this situation. Anyway without \Q, if $sep contains something that matters to the regex engine, you will get confusing results.