in reply to I need to know if 32-bit or 64-bit perl is running my script.

AM,

I may be missing your point, but if you want to see if it's 32/64 bit Perl on AIX, try this:

[path/]perl -V | grep 32 # or 64
and you will get something like this:
. . . -maix32 # or 64
This gives you the C compiler info for the Perl executable.

Regards...Ed

"Well done is better than well said." - Benjamin Franklin

Replies are listed 'Best First'.
Re^2: I need to know if 32-bit or 64-bit perl is running my script.
by Tux (Canon) on Sep 16, 2013 at 06:51 UTC

    Why use external commands when everything and more is already available?

    $ perl -V:ptrsize ptrsize='8'; $ perl -MConfig -wE'say $Config{ptrsize}' 8 $ perl -MData::Peek -MConfig::Perl::V -we'DDumper (Config::Perl::V::my +config ()->{config})'

    Enjoy, Have FUN! H.Merijn

      Tux,

      Very Nice!

      but... something to keep in mind:

      • You may not be able in install CPAN modules in a production system.

      I tested the performance on a test system:

      # *Your method* after installing 2 CPAN modules real 0m0.84s user 0m0.76s sys 0m0.008s # *My method* calling Perl from the command line real 0m0.028s user 0m0.032s # Note: I did this 3 times and 'user' > 'real' +was every time??? sys 0m0.004s

      Granted your routines providing a lot of information, but doing a 'system' call to get some specific information may not be that bad of a hit.

      I'm still going to add this to my bag of tricks. Good job!

      Regards...Ed

      "Well done is better than well said." - Benjamin Franklin

        The first two are CORE capabilities since perl5.003_07. Sorry to sound harsh, but whining that you cannot install from CPAN is bullshit, that is repeated over and over and over again with all possible workarounds here on PM.

        Nagging about startup time might be true for Config::Perl::V, which does quite a bit more than we'd love to just to be able to get the info (not true anymore on perl-5.18, where that info is available directly from CORE, as is Config::Perl::V). The extra time you see is the dumper time, which was just used to show you the content. Try again with just accessing the data required and you will see a considerable speedup. IMHO all those speeds are just noise in the complete picture, but I do not want to compare apples and pears.

        Nagging about Config is just trying to find sand to throw into the engine. You have no idea how many modules use Config, so it will be loaded anyway sooner or later.

        $ find 5.18.0 -name \*.pm | xargs grep -wl 'use Config' | wc -l 57 $ find site_perl/5.18.0 -name \*.pm | xargs grep -wl 'use Config' | wc + -l 107 $ corelist Config Config::Perl::V Data for 2013-08-20 Config was first released with perl 5.00307 Data for 2013-08-20 Config::Perl::V was first released with perl v5.17.9 $ time perl -V:ptrsize ptrsize='4'; 0.005u 0.003s 0:00.00 0.0% 0+0k 0+0io 0pf+0w $ time perl -MConfig -wE'say $Config{ptrsize}' 4 0.001u 0.005s 0:00.00 0.0% 0+0k 0+0io 0pf+0w $ time perl -MConfig::Perl::V -wE'say Config::Perl::V::myconfig ()->{c +onfig}{ptrsize}' 4 0.007u 0.002s 0:00.00 0.0% 0+0k 0+0io 0pf+0w

        Enjoy, Have FUN! H.Merijn