All pastes #459377 Raw Edit

Someone

public text v1 · immutable
#459377 ·published 2007-04-26 12:39 UTC
rendered paste body
"use" not allowed in expression at /usr/src/tmp/openwebmail-buildroot/var/www/c                                                                                                   bmail/misc/tools/rc/replacestr.pl line 9, at end of line
syntax error at /usr/src/tmp/openwebmail-buildroot/var/www/cgi-bin/openwebmail/                                                                                                   /replacestr.pl line 9, near "use strict"
BEGIN not safe after errors--compilation aborted at /usr/src/tmp/openwebmail-bu                                                                                                   ww/cgi-bin/openwebmail/misc/tools/rc/replacestr.pl line 10.
# /usr/src/tmp/openwebmail-buildroot/var/www/cgi-bin/openwebmail/misc/tools/rc/                                                                                                   : deparse failed. isPerl=0.042833607907743.
error: /bin/sh failed
error: Failed to find Requires


$ cat replacestr.pl

use strict;
use File::Find;

my @dirs                = ('/var/home');
my $filepattern         = "\/\.openwebmail\/openwebmailrc\$";
my $replacepattern      = "iconset=Cool3D.German";
my $replacestring       = "iconset=Cool3D.Deutsch";

&find({wanted => \&FileFindWanted,
       follow => 1},
      @dirs);

print "done.\n\n";


sub FileFindWanted {

  my $line;

  my $file = $File::Find::name;

  if ($file =~ m#$filepattern#) {
    print "working on file ".$file." ...\n";
    my ($dev, $inode, $mode, $nlink, $uid, $gid) = lstat($file);
    my $tfile = $file."~";
    open(FD1, $file) || die "Can't open input file $file\n";
    open(FD2, ">".$tfile) || die "Can't open output file $tfile\n";
    while ($line = <FD1>) {
      $line =~ s#$replacepattern#$replacestring#;
      print FD2 $line;
    }
    close(FD2);
    close(FD1);
    unlink($file);
    rename($tfile, $file);
    chmod($mode, $file);
    chown($uid, $gid, $file);
  }
}