opendir( DIR, '.' );
    my @files = readdir(DIR);
closedir( DIR );
my $findbin = q#BEGIN {
    use FindBin qw ($RealBin $RealScript);
    my ($binpath) = $FindBin::RealBin =~ /^(.*)$/;
    chdir $binpath;
}
#;
foreach my $file ( @files ) {
    next if $file !~ /\.pl$/;
    local $/;
    open( INF, $file );
        my $contents = <INF>;
    close( INF );
    $contents =~ s/^(.*?\n)/$1$findbin/;
    open( OUTF, ">$file" );
        print OUTF $contents;
    close( OUTF );
    print "Updated $file\n";
}
print "Complete";
my $read = <STDIN>;

Save and execute with Perl in the foswiki/bin folder.

-- CosmicNet - 16 May 2011
Topic revision: r1 - 16 May 2011, CosmicNet - This page was cached on 06 Dec 2018 - 12:17.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy