J
J Krugman
Is there a better way to get, within a Perl script, the string
generated by "perl -V" than going through sh:
my $perl_V = do { local $/; `perl -V` };
?
My guess is that the answer is no, because
perl -MO=Deparse -V
produces one big mess (I quote it below). Unfortunately, even this
big mess includes some "hard-coded" strings (such as " Build under
linux\n"), which means that even if I wanted it, I cannot turn this
mess into a general utilities library routine.
TIA,
jill
Output of perl -MO=Deparse -V
sub myconfig {
package Config;
return $summary if $summary_expanded;
$summary =~ s/\$(\w+)/my $c = $Config{$1};
defined $c ? $c : 'undef';/eg;
$summary_expanded = 1;
$summary;
}
sub Config::config_re {
package Config;
my $re = shift @_;
my(@matches) = $config_sh =~ /^$re=.*\n/gm;
@matches ? print(@matches) : print("$re: not found\n");
}
sub config_vars {
package Config;
foreach $_ (@_) {
config_re($_), next if /\W/;
my $v = exists $Config{$_} ? $Config{$_} : 'UNKNOWN';
$v = 'undef' unless defined $v;
print "$_='$v';\n";
}
}
print myconfig();
print "\nCharacteristics of this binary (from libperl): \n", " Compile-time options: USE_LARGE_FILES\n", " Built under linux\n", " Compiled at Apr 4 2004 05:57:53\n";
$" = "\n ";
@env = map({qq[$_="$ENV{$_}"];} sort(grep({/^PERL/;} keys %ENV)));
print " %ENV:\n @env\n" if @env;
print " \@INC:\n @INC\n";
generated by "perl -V" than going through sh:
my $perl_V = do { local $/; `perl -V` };
?
My guess is that the answer is no, because
perl -MO=Deparse -V
produces one big mess (I quote it below). Unfortunately, even this
big mess includes some "hard-coded" strings (such as " Build under
linux\n"), which means that even if I wanted it, I cannot turn this
mess into a general utilities library routine.
TIA,
jill
Output of perl -MO=Deparse -V
sub myconfig {
package Config;
return $summary if $summary_expanded;
$summary =~ s/\$(\w+)/my $c = $Config{$1};
defined $c ? $c : 'undef';/eg;
$summary_expanded = 1;
$summary;
}
sub Config::config_re {
package Config;
my $re = shift @_;
my(@matches) = $config_sh =~ /^$re=.*\n/gm;
@matches ? print(@matches) : print("$re: not found\n");
}
sub config_vars {
package Config;
foreach $_ (@_) {
config_re($_), next if /\W/;
my $v = exists $Config{$_} ? $Config{$_} : 'UNKNOWN';
$v = 'undef' unless defined $v;
print "$_='$v';\n";
}
}
print myconfig();
print "\nCharacteristics of this binary (from libperl): \n", " Compile-time options: USE_LARGE_FILES\n", " Built under linux\n", " Compiled at Apr 4 2004 05:57:53\n";
$" = "\n ";
@env = map({qq[$_="$ENV{$_}"];} sort(grep({/^PERL/;} keys %ENV)));
print " %ENV:\n @env\n" if @env;
print " \@INC:\n @INC\n";