gbarr / Scalar-List-Utils

Scalar::Util and List::Util perl modules

This URL has Read+Write access

Graham Barr (author)
Wed May 13 14:51:19 -0700 2009
Scalar-List-Utils / xs_version.PL
100644 25 lines (24 sloc) 0.612 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!perl
use strict;
use warnings;
use File::Spec;
use Scalar::Util;
my $has_xs = eval { Scalar::Util->import('dualvar'); 1 };
my $xs_pm = File::Spec->catfile(qw(blib lib List Util XS.pm));
open(FH,$xs_pm) or die "Cannot open $xs_pm: $!\n";
my @file = <FH>;
foreach my $line (@file) {
  next unless $line =~ /# FIXUP/;
  if ($has_xs) {
    $line =~ s/^sub VERSION/sub _VERSION/;
    $line =~ s/^# VERSION/\$VERSION/;
  }
  else {
    $line =~ s/^sub _VERSION/sub VERSION/;
    $line =~ s/^\$VERSION/# VERSION/;
  }
}
unlink($xs_pm);
open(FH,">$xs_pm") or die "Cannot open $xs_pm: $!\n";
print FH @file;
close(FH);