Re: use Win2000; and alike
by jryan (Vicar) on Jun 06, 2002 at 08:12 UTC
|
Or, as an simpler API for your suggestion:
use OS qw(Win2000);
or
use OS qw(Debian-Woody);
As to what you want these modules to do, however, I am completely clueless :)
| [reply] [d/l] [select] |
|
|
While this is cleaner and better than having tons of separate modules it's not really that helpfull. I mean, most usualy you do not want to blow up if you detect a certain OS. You merely want to load a bit different modules, implement something a little different, set a variable accordingly ...
So IMHO we'de need somethig less "cool". Maybe something like
use SysInfo qw(RunUnder);
if (RunUnder 'Win32') {
if (RunUnder 'Win2000+') {
print "Running under Win2000 or WinXP\n";
} else {
print "Running under some older or more stripped down Windows\n";
} elsif (RunUnder 'Unix') {
if (RunUnder 'BSD') {
print "Runnind under BDS Unix\n";
} else {
print "Running under some other Unix\n"
}
} else {
print "GOK what are you using\n";
}
It would be cool if perl could optimize out the code that will not be used when compiling the code, but I don't think that matters much. You do not test for the OS you are running under in tight loops.
Jenda@Krynicky.cz | [reply] [d/l] |
Re: use Win2000; and alike
by Juerd (Abbot) on Jun 06, 2002 at 08:36 UTC
|
BEGIN { die "This program needs Windows" unless $^O eq 'Win32' }
- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.
| [reply] [d/l] |
|
|
Argh! No! Please please dont do this!
$^O eq 'Win32'
Code like this is pervasive and wrong. And not only that but holds back implementing proper Win32 OS identification in future versions of perl. Currently the only real way to determine if you are on a W2k box is code like Determine Windows Type or Version. The fact is that this should _not_ be necessary. Instead Perl should know and return the correct value in $^O. But so many people have _hardcoded_ tests like you (and tadman) do in this example and in the perl distribution that loads of tests will fail if it is ever changed and we (Win32 users) all get stuck with b0rked OS reporting. (Yes I started working on getting $^O to return the correct value and decided it wasnt worth the effort changing all those tests. Shudder. They are everywhere.)
At very minimum it makes sense to change the above to the much more flexible and forward compatible
$^O =~/Win32/
to determine that you are on a Win32 box. But even still this test will _not_ tell you if you are on an XP box or a W98 box or....
Yves / DeMerphq
---
Writing a good benchmark isnt as easy as it might look. | [reply] [d/l] [select] |
|
|
You are probably right. I have no way of testing this, but I'll start changing die if $^O eq 'Win32' to die if $^O =~ /win32|dos/i in my scripts ;) (Come to think of it, Windows.pm would allow for a nice no Windows :)
On $^O knowing the type of Windows: if I recall correctly, $^O is hardcoded into perl, and Windows 95 programs can run under Windows 2000. I may be wrong, though.
- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.
| [reply] [d/l] [select] |
|
|
|
|
|
|
|
|
| [reply] |
|
|
|
|
|
|
Well, as the original author mentions, it would be nicely consistent with use 5.6.0 for Perl-versions... and anyway, TIMTOWTDI!
BrotherAde
| [reply] [d/l] |
|
|
Come on, you can figure it out.
package Windows;
use Carp;
sub import
{
croak "This program needs Windows" unless ($^O eq 'Win32');
}
sub unimport
{
croak "This program refuses to use Windows" if ($^O eq 'Win32');
}
1;
| [reply] [d/l] |
Re: use Win2000; and alike
by Steve_p (Priest) on Jun 06, 2002 at 12:31 UTC
|
Eeek! I don't want to sound rude, but that is one of the worst ideas I've ever heard. One of the big advantages of using Perl is that it is cross-platform. If I feel like developing a script to read from Oracle, I can write and test it on my Windows machine first, and then move it to UNIX when I really want it to run. And the UNIX I use depends on the project I'm woking on. With Perl, I depend on the fact that what runs on one platform will work on another. An idea like this would turn Perl into the next VB. | [reply] |
|
|
That's true, however, there are cases where the cross-platformness (or is thet cross-platformity? platformitude??) of Perl break down. Try perlport for a couple of examples. I've been bitten myself because alarm() doesn't exist on Win32 platforms...
BrotherAde
| [reply] [d/l] |
|
|
So are you suggesting having
use PosixCompliant;
| [reply] [d/l] |
|
|
| [reply] |
|
|
| [reply] |
|
|
Didn't you ever heard that sometimes perl can be used
for administrative programming, and WMI managing is an example, and this will work for Win2000 and will not for WinNT (there are no such COM objects there) ?
In this case I can suggest you to read some materials to become a bit more knowledgable person.
If you don't know about a possibility this does not mean such possibility does not exists.
Courage, the Cowardly Dog.
PS. I knew I not gonna like this
| [reply] |