in reply to Re^3: Offset Reading - two files
in thread Offset Reading - two files

Hello, I have tried this, with no success:

perl -sple"BEGIN{open BIG};($1,$2)=split;seek(BIG,$1,$2);read(BIG,$_,$2)" -- -BIG=bigfile.dat index.dat >outfile.dat

What I asked '20 months' ago was not related to the change that occurred recently. Thanks

Replies are listed 'Best First'.
Re^5: Offset Reading - two files
by BrowserUk (Patriarch) on Dec 14, 2012 at 15:10 UTC

    seek does not take a length ($2 as its third parameter. If you changed that to:

    perl -sple"BEGIN{open BIG};($1,$2)=split;seek(BIG,$1,$2);read(BIG,$_,0 +)" -- -BIG=bigfile.dat index.dat >outfile.dat

    It might work.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    RIP Neil Armstrong

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      I have tried:

      perl -sple 'BEGIN{open BIG};($1,$2)=split;seek(BIG,$1,0);read(BIG,$_,$2)' -- -BIG=bigfile.dat index.dat >outfile.dat

      and I received the following:

      Modification of a read-only value attempted at -e line 1, <> line 1

      Thanks,

        This seems to work:

        C:\test>type junk.dat a_12_3_5- k_3_4_6-a_12_3_5- q_1_5_7_9- q_1_5_7_9- a_9_4_5-c_3_4_6- c_3_4_6-r_4_5_7- b_1_1_3- v_1_5_7- d_12_4_5-e_4_5_6- g_5_6_7-d_6_8_6- b_1_1_7-f_3_8_7_8-d_4_1_4- d_4_1_5-b_1_1_7-f_3_8_3 b_1_1_7-f_3_8_7_8-d_4_1_4- e_3_3_1-f_3_8_7-f_21_3_1-b_1_1_7-a_1_1_1- C:\test>perl -swple"BEGIN{open BIG};($o,$s)=split;seek(BIG,$o,0);read( +BIG,$_,$s)" -- -BIG=junk.dat con >junk2.dat 1 10 20 10 5 10 30 20 ^Z C:\test>type junk2.dat _12_3_5- k 12_3_5- q_ 3_5- k_3_4 _1_5_7_9- q_1_5_7_9-

        I leave it to you to work out why yours doesn't.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        RIP Neil Armstrong

        You are trying to assign to $1 and $2 but these are special variables that are only set by successful regular expression match captures and are read-only otherwise (see Extracting matches). Use normal scalar variables with names that are something meaningful, like $offset and $reclen perhaps.

        I hope this is helpful.

        Cheers,

        JohnGG

        use splain or diagnostics to get more verbose error message

        Read about the variable you're using with perldoc -v '$1' and stop that :)