Question

The CGI scripts and tools that comprise movabletype have the perl binary name hard-coded

#!/usr/bin/perl -w

Unless I manually replace all these instances with

#!/usr/bin/env perl
use warnings;

it seems impossible to run movabletype under my private version of perl (installed with perlbrew). Is there some way I can run movabletype under the perlbrew perl without making these changes manually?

Was it helpful?

Solution

... write a program to change them for you?

#! /usr/bin/env perl
use common::sense;
use Tie::File;

tie my @f, 'Tie::File', shift or die $!;
if ($f[0] =~ m,#! */usr/bin/perl( -w)?,) {
  $f[0] = '#! /usr/bin/env perl';
  splice @f, 1, 0, 'use warnings;' if $1
}
untie @f;

Somethin' like.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top