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

In order to make the second case work like the first one, you need to have the back-tick command assign its value to a scalar, rather than to an array:
my $data =`lpstat -o -v -d -p -l -D`;.
In other words, if your first example (reading from the file) actually works, then all you need to do is replace these lines:
system("lpstat -v -d -p -l -D >junk.txt"); open RI,"<junk.txt" || die "Can't open junk.txt for reading:$!\n"; my $data = do { local $/; <RI> };
with the one back-tick line I showed above, and everything else should stay the same and still work.