There are three resources in the clipping I got from Safari: TEXT, url, and drag. TEXT and url are the same, and TEXT doesn't seem to do anything. Neither does drag, so I just put in the url resource, which seems to work just fine. If more is needed, it can be added. (Note: you can use DeRez to see what is in a resource file, in
So anyway, this little bit of code works for me, share and enjoy. Mac::Carbon required.
use Mac::Errors '$MacError';
my $url = new Handle "http://projects.pudge.net/";
my $file = catfile(FindFolder(kUserDomain, kDesktopFolderType), "projects.webloc");
FSpCreateResFile($file, 'MACS', 'ilht', 0) or die $MacError;
my $RF = FSpOpenResFile($file, 0) or die $MacError;
AddResource($url, 'url ', 256, '');