Perl Script to get Python version

Is there an easy way to get python version from perl script. For example. Get the equivalent version python -V

. I need this to determine if I need to run python26

or just python

on some of my linux windows.

If there is no easy way, I plan to run python -V

, then grab stdout and parse it.

+3


source to share


1 answer


You can execute any system command and write STDOUT with qx :



use warnings;
use strict;

my $v = qx(python -V);
print $v;

      

+5


source







All Articles