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

In reply to Re: Read offset into other files by GrandFather
in thread Read offset into other files by gio001

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.