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

Re^4: about link()

by exilepanda (Pilgrim)
on Feb 18, 2012 at 19:50 UTC ( #954792=note: print w/replies, xml ) Need Help??

in reply to Re^3: about link()
in thread about link()

However if i do the same as you. while A changed, B is still B and no change. Any trouble shoot thing I can do then ?

Replies are listed 'Best First'.
Re^5: about link()
by BrowserUk (Pope) on Feb 18, 2012 at 22:23 UTC

    I suspect that whatever you are using to "edit" the jpg, isn't editing it in-place, but rather when you save the changes you made, it deletes the original file and then write a new one with the original name and the new contents. This (by design) breaks the link.

    For reference and an authoritative description, see this forum post by the guy that implemented link on win32.

    To prove it is the editor rather than perl that is at fault, try this sequence of steps:

    c:\test\junk>dir 18/02/2012 22:09 633 a.jpg c:\test\junk>perl -E"say link 'a.jpg', 'b.jpg';" 1 c:\test\junk>dir 18/02/2012 22:09 633 a.jpg 18/02/2012 22:09 633 b.jpg c:\test\junk>md5sum a.jpg 56c800418e498e40ae9bc4c1e4023341 *a.jpg c:\test\junk>md5sum b.jpg 56c800418e498e40ae9bc4c1e4023341 *b.jpg c:\test\junk>perl -E"open I,'+<:raw','a.jpg';seek I,400,0;syswrite I,0 +xffffffff,4;close I" c:\test\junk>md5sum a.jpg 8bc46c67f8e5d8c0caf4c7c59db66779 *a.jpg c:\test\junk>md5sum b.jpg 8bc46c67f8e5d8c0caf4c7c59db66779 *b.jpg

    Of course, the jpgs aren't valid any more after the edit above, but it should convince you that editing one also edits the other.

    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.

    The start of some sanity?

      Thank you very much! This explains everything. So I tried with this code :
      open O, ">a.bin"; binmode O; print O "Hello World!"; close O; link "a.bin", "b.bin"; open L, ">b.bin"; binmode L; print L "Bye World!"; close L; open O, "a.bin"; print while ( <O> ); close O; # prints "Bye World!"
      This proved an in-place edit works in binary files as expected. It's glad to know that it's my fault!! Otherwise I don't know how to fix it. Good day! =)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://954792]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2018-02-19 09:50 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (260 votes). Check out past polls.