in reply to How is outputting to an array different from outputting to a file

You aren't really treating them the same by localizing the input record separator:

my $data = do { local $/; <RI> }; # or however you load it.

Instead try this:

@data = <RI>; chomp(@data);

or

while ($line = <RI>) { chomp $line; ... }

Then cycle through the data list. This is what you do in your array example.

I suppose that answer is a bit backwards, however. Once you get the data in list format, you no longer need the split that you were using due to having overridden the input record separator:

for ( split /\n(?=\S)/, $line )

Instead just use:

for my $line (@lines) {
Matt