For those of you like myself, who are prone to shooting ones self in ones foot, I offer the following script that might allow you to escape the consequences of ones capricious actions! In less flowery verbiage, I recently came up with the brilliant idea of improving my development situation by pruning my perl development tree from the main perl trunk. Surely a sensible thing to do (particularly since it shouldn't have been there in the first place) or at least so I thought until I noticed that all of my shortcuts (Windows .lnk files) no longer worked. So here is a short piece of code that bailed me out and that might help fellow travelers as well.
#!/usr/bin/perl # Fixlink.pl -- script to effect global change in link collection. use strict; use warnings; use diagnostics; use Win32::Shortcut; edit_lnkpath( $_, qr/$ARGV[1]/, $ARGV[2] ) for map { glob } $ARGV[0]; sub edit_lnkpath { my ( $file, $pat1, $pat2 ) = @_; my $lnk = new Win32::Shortcut($file) or die "Couldn't create shortcut object: $!"; my $path = $lnk->{'Path'}; if ( $path =~ /$pat1/ ) { print "'$path' changed to "; $path =~ s/$pat1/$pat2/; print "'$path'\n"; $lnk->{'Path'} = $path; $lnk->Save(); } $lnk->Close(); }

--hsm

"Never try to teach a pig to sing...it wastes your time and it annoys the pig."

In reply to Fixing broken .lnk files by hsmyers

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.