#!/usr/bin/env perl use strict; use File::Spec::Functions; $| = 1; my $iDir = $ARGV[0] or usage("No input directory specified..."); my $iCopied = $ARGV[1] or usage("No input copy file specified..."); my $oFile = $ARGV[2] or usage("No output file specified..."); openFoafList($oFile); getFoafList($iDir); copyList($iCopied); closeFoafList(); sub copyList { my $fn = shift; open COPY,"<$fn" or die "Cannot open $fn $!\n"; print "Copying external foaf locations from $fn\n"; while(){ if (m/$foafListFn") or die "Unable to open '$foafListFn' for". " writing.\n$!"; print OUT < EOT } sub writeFoafEntry { # N.B. It seems that xsltproc on Windows ignores any entries containing "\" # Also, file: locations must start with file:///[drive:]/ or file:///.. # my $file_pfx='file://'; # default prefix - but should this also be file:/// ? if ($^O =~ /^MSWin32/){ $file_pfx='file:///'; # Use corrected file prefix } my $u=shift; if ($^O =~ /^MSWin32/){ $u =~ s!\\!/!g; # convert \ to / } print OUT " $file_pfx$u\n"; } sub closeFoafList { print OUT "\n"; close OUT; # Done with the file } sub usage { my $msg = shift; print < Error: EOF die "$msg\n"; }