in reply to Read offset into other files

Yup, your problem starts right at the first line as you suspect. What you have is not Perl even though you state you "want to explore a smart perl approach". Here is a sample Perl program that demonstrates the techniques you need to implement your task:

use warnings; use strict; use Data::Dump::Streamer; my $str = <<SNIPS; Hello all, I am encountering some issue in trying to do the following +in ksh88, therefore I want to explore a smart perl approach, but my knowledge is + limited, can you help? I have 2 files, the first (indexFile1) contains lines with start offset and length for each record inside the second file, so just 2 nu +mbers separated by a space. ... SNIPS open my $recData, '<', \$str; while (<DATA>) { chomp; my ($start, $len) = split; my $segment; seek $recData, $start, 0; read $recData, $segment, $len; print "$segment\n"; } __DATA__ 16 12 80 9 315 10

Prints:

encountering therefore separated

Note, to avoid needing external files I've used a string to provide one input "file" and provided the other as data following the body of the script. Note too that I tested this under Windows so you may get different output if your OS uses different line end characters than Windows does.


Perl reduces RSI - it saves typing