perlmovabletypeperlbrew

Running movabletype 5.2+ with perlbrew perl and starman


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?


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.