Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^7: Offset Reading - two files

by BrowserUk (Patriarch)
on Dec 14, 2012 at 16:04 UTC ( [id://1008865]=note: print w/replies, xml ) Need Help??


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

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

Replies are listed 'Best First'.
Re^8: Offset Reading - two files
by gio001 (Acolyte) on Dec 14, 2012 at 16:14 UTC
    I will try to work this out, the difference I see is that my input BIG file is a 'single' record, there are no record separator in it, each 'record' is identified by offset and length from the index file, somewhat different from what you illustrated. Is the seek command behaving differently in my case? I even tried:

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

    with the same error . Thanks

      You are still trying to use the readonly variables $1 & $2, hence the error message.

      I suggest that you learn simple Perl, before you try to do complicated things with it. If you do not have enough time to learn, employ someone to do it for you.


      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

        Thanks so much. I got this to work. <p>perl -sple 'BEGIN{open BIG};($offse,$recl)=split;seek(BIG,$offse,0);read(BIG,$_,$recl)' -- -BIG=datain index.dat >out </p> Thanks for the support. I promise I will put more time in learning the basics before bothering you again. Bye
Re^8: Offset Reading - two files
by gio001 (Acolyte) on Dec 14, 2012 at 17:22 UTC
    Thanks so much. I got this to work. <p>perl -sple 'BEGIN{open BIG};($offse,$recl)=split;seek(BIG,$offse,0);read(BIG,$_,$recl)' -- -BIG=datain index.dat >out </p> Thanks for the support. I promise I will put more time in learning the basics before bothering you again. Bye

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1008865]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-04-25 08:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found