Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

A puzzle.

by BrowserUk (Patriarch)
on Aug 06, 2005 at 05:21 UTC ( [id://481440]=perlquestion: print w/replies, xml ) Need Help??

BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:

Using

perl -e"BEGIN{$/=\2**21;binmode STDIN; $n=0}" -ne"open my $fh,'>:raw', $ARGV.'.'.$n++; print $fh $_;" junk2

to split a 34,000,000 byte file, I get

19/05/2005 22:01 34,000,000 junk2 05/08/2005 10:22 2,097,152 junk2.0 05/08/2005 10:22 2,097,152 junk2.1 05/08/2005 10:22 2,097,152 junk2.10 05/08/2005 10:22 2,097,152 junk2.11 05/08/2005 10:22 2,097,152 junk2.12 05/08/2005 10:22 2,097,152 junk2.13 05/08/2005 10:22 2,097,152 junk2.14 05/08/2005 10:22 1,542,720 junk2.15 05/08/2005 10:09 1,000,000 junk2.16 05/08/2005 10:22 2,097,152 junk2.2 05/08/2005 10:22 2,097,152 junk2.3 05/08/2005 10:22 2,097,152 junk2.4 05/08/2005 10:22 2,097,152 junk2.5 05/08/2005 10:22 2,097,152 junk2.6 05/08/2005 10:22 2,097,152 junk2.7 05/08/2005 10:22 2,097,152 junk2.8 05/08/2005 10:22 2,097,152 junk2.9 05/08/2005 10:25 34,000,000 this

When I reassemble the parts (the file named 'this' above), and diff it against the original, they are identical.

My question is, why did the last two files (.15 & .16) get written with sizes 1,542,720 & 1,000,000 repectively?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

Replies are listed 'Best First'.
Re: A puzzle.
by virtualsue (Vicar) on Aug 06, 2005 at 08:47 UTC
    I tried doing the same thing on linux, and it behaved as expected. I couldn't help noticing that your last file (junk2.16) appears to have an earlier modification time than the others. Is that at all relevant?
      I couldn't help noticing that your last file (junk2.16) appears to have an earlier modification time than the others.

      I hadn't noticed that. That probably does (at least partially) explain it. The last file does appear to be a left over from an earlier run.

      I say partially, because I'm having great difficulty coming up with an explaination for how a left-over file from an earlier run could combine with a full set from a later run and recombine to reform a file that diffs equal to the original? Or how that combination of filesizes & numbers could be arrived at.

      I cannot reproduce the results, although (I'd swear) I have seen this happen at least twice.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
        I cannot reproduce the results, although (I'd swear) I have seen this happen at least twice.

        I've had days like that too. Eventually, the memory fades, and life goes on...

Re: A puzzle.
by borisz (Canon) on Aug 06, 2005 at 08:46 UTC
    Here is my result with perl 5.8.4 on OS X.
    -rw-r--r-- 1 borisz wheel 34000000 Aug 6 10:14 this -rw-r--r-- 1 borisz wheel 2097152 Aug 6 10:45 this.0 -rw-r--r-- 1 borisz wheel 2097152 Aug 6 10:45 this.1 -rw-r--r-- 1 borisz wheel 2097152 Aug 6 10:45 this.10 -rw-r--r-- 1 borisz wheel 2097152 Aug 6 10:45 this.11 -rw-r--r-- 1 borisz wheel 2097152 Aug 6 10:45 this.12 -rw-r--r-- 1 borisz wheel 2097152 Aug 6 10:45 this.13 -rw-r--r-- 1 borisz wheel 2097152 Aug 6 10:45 this.14 -rw-r--r-- 1 borisz wheel 2097152 Aug 6 10:45 this.15 -rw-r--r-- 1 borisz wheel 445568 Aug 6 10:45 this.16 -rw-r--r-- 1 borisz wheel 2097152 Aug 6 10:45 this.2 -rw-r--r-- 1 borisz wheel 2097152 Aug 6 10:45 this.3 -rw-r--r-- 1 borisz wheel 2097152 Aug 6 10:45 this.4 -rw-r--r-- 1 borisz wheel 2097152 Aug 6 10:45 this.5 -rw-r--r-- 1 borisz wheel 2097152 Aug 6 10:45 this.6 -rw-r--r-- 1 borisz wheel 2097152 Aug 6 10:45 this.7 -rw-r--r-- 1 borisz wheel 2097152 Aug 6 10:45 this.8 -rw-r--r-- 1 borisz wheel 2097152 Aug 6 10:45 this.9
    Boris
Re: A puzzle.
by NateTut (Deacon) on Aug 06, 2005 at 11:55 UTC
    While I agree that it is odd that junk2.16 has an earlier timestamp, the sizes don't add up without it:

    2,097,152 ----- 2,097,152
    2,097,152 ----- 2,097,152
    2,097,152 ----- 2,097,152
    2,097,152 ----- 2,097,152
    2,097,152 ----- 2,097,152
    2,097,152 ----- 2,097,152
    2,097,152 ----- 2,097,152
    1,542,720 ----- 1,542,720
    1,000,000 ----- 2,097,152
    2,097,152 ----- 2,097,152
    2,097,152 ----- 2,097,152
    2,097,152 ----- 2,097,152
    2,097,152 ----- 2,097,152
    2,097,152 ----- 2,097,152
    2,097,152 ----- 2,097,152
    2,097,152 ----- 2,097,152
    2,097,152

    34,000,000 ---- 33,000,000
    W/ Junk2.16 --- W/O Junk2.16

    There needs to be another explanation...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://481440]
Approved by sk
Front-paged by sk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (8)
As of 2024-04-24 09:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found