in reply to Re: Extracting selected fields form file record
in thread Extracting selected fields form file record

another way is filling in undef for the ignored fields

my ($first,$second,undef,$third,undef,$fourth,undef,$fifth,undef,$sixth) = split / /, $line;

please also note that split operates on regexes, so /\s+/ might be what is really wanted.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^3: Extracting selected fields form file record
by soonix (Chancellor) on Feb 06, 2022 at 19:53 UTC
    A single space character (' ') is a special case. I admit that it is a bit buried in the split documentation. Of course, only at most OP knows whether leading whitespace should be kept…
      you are right and it will also handle leading whitespace! :)

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery