develooper Front page | perl.perl5.porters | Postings from May 2003

Re: windows, shortcuts, and 'use lib'

Thread Previous | Thread Next
Jan Dubois
May 14, 2003 12:35
Re: windows, shortcuts, and 'use lib'
Message ID:
On Wed, 14 May 2003 11:58:10 -0700, Edward Peschko
<> wrote:


>Believe me, the first thing that I tried to do was use the 'link' interface in perl. You
>say that it works, my windows XP and windows 2000 box says that it doesn't. Or it 'works'
>in a weird, microsoftish way that only microsoft folks find in any way useful. Try:
>where 'file' is 5000 bytes long. Edit 'file2' - add a byte. Do 'dir file*' and you will 
>05/14/2003   11:05             5000 file
>05/14/2003   11:05             5001 file2

It depends on how you "edit" the file.  If you delete and recreate it,
then the link is obviously destroyed.  Note that you cannot rely on "dir"
to display the correct information.  It sometimes takes NTFS a little
while to update the directory entries of linked files.  Check the content
of the files instead.

The following snippet shows that you can update a hardlinked file without
severing the link:

  use strict;
  open A, '>A' or die;
  print A "AA";
  close A;

  unlink "B";
  link qw(A B) or die;
  open B, ">>B" or die;
  print B "BB";
  close B;

>I was wrong - it doesn't make a copy. It makes a fragile link, one which is broken any
>time you edit the file. Doing a directory link simply doesn't work.

I disagree about the "fragile" part, except for the annoying delayed
update of directory entries.  You are correct in that you cannot hardlink
directories on NTFS.

>Anyways, I'm getting sick of trying to make hard links work, and even if did get them
>to work, they aren't going to be a full solution - as someone said, anything with FAT32 
>is excluded. I'm going to write a module for shortcuts. However, I'd like to make it 
>*truly* integrated into perl, and to do that, I'd hope that:
>	1) `` could be overloaded

Sounds good to me.

>	2) perl <shortcut> would follow the shortcut and run the file behind the shortcut.

You can easily do this with a module that will modify @ARGV for you:

  perl -MLinks shortcut.lnk

and then put "-MLinks" into PERL5OPT.


>#1 I think would be a given nice to have, I'd hope that #2 would be accepted.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About