On Tue, 2 Nov 2004, Murphy, Ged (Bolton) wrote: > Ramprasad A Padmanabhan wrote: > > In a particular script , that is used on multiple unix platforms, I > > need to know if my perl script is being run on a 32 bit machine or a > > 64 bit machine > > > > Is there any way I can find this portably > > Can you not just run uname? > > $SystInfo = `uname -a`
And then what? I'm writing this mail on a Powermac G5 -- nominally a 64-bit machine. $ uname -a Darwin cesar 7.5.0 Darwin Kernel Version 7.5.0: Thu Aug 5 19:26:16 PDT 2004; root:xnu/xnu-517.7.21.obj~3/RELEASE_PPC Power Macintosh powerpc I don't see anything in there that gives away the fact that I'm on a 64-bit machine; for that matter, I don't see anything about the CPU. For comparison, here's the same command on a G4: $ uname -a Darwin bart 7.5.0 Darwin Kernel Version 7.5.0: Thu Aug 5 19:26:16 PDT 2004; root:xnu/xnu-517.7.21.obj~3/RELEASE_PPC Power Macintosh powerpc Aside from the hostname, the output is identical. `uname` seems to be a dead end for this question. Out of curiosity, why does it matter whether the machine is 32 or 64 bit? Part of the point of using a high level language like Perl is that, if everything is going smoothly, you don't really have to know what hardware you're running on, as things Just Work. (That "write once, run anywhere" thing that the Java people like so much applies to just about any scripting language, Perl included; it's not really a big deal now.) So -- are you doing something that will only work on 64 bit hardware? If so, what might that be? If you just want to see if a given program will run on a given platform, why not just try to run it in an eval statement so that if it fails you can trap the error and report back to the user? Writing it that way should solve all kinds of portability issues... -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>