S
Shmuel (Seymour J.) Metz
I've been modifying a Perl Program to support OS/2, and I've run into
a bizare anomaly with the ternary operator. I was getting an error
message on the statement
my $etc = $ENV{ETC} or ($^O eq 'os2') ? OS2::Bootdrive() :
'/etc';
So I decided to try testing it a bit at a time. Each of the following
produces the expected output:
print '$ENV{ETC}=',$ENV{ETC},"\n";
print "OS=$^O\n";
print '$^O eq os2=',($^O eq 'os2'),"\n";
print 'BootDrive=',OS2::BootDrive(),"\n";
print "($^O eq 'os2') ? OS2::Bootdrive() : '/etc'=";
print $^O eq 'os2' ? 'true' : 'false',"\n";
[H:\]bwwhois 200.204.145.122
$ENV{ETC}=G:\MPTN\ETC
OS=os2
$^O eq os2=1
BootDrive=g
(os2 eq 'os2') ? OS2::Bootdrive() : '/etc'=true
However,
print $^O eq 'os2' ? OS2::Bootdrive() : '/etc',"\n";
gives me
Undefined subroutine &OS2::Bootdrive called at H:\UTILITY/BWwhois.cmd
line 61.
Note that the spelling is identical to the one that worked, so I
assume that the problem has something to do with the context of a
ternary operator. Any assistance will be appreciated.
The relevant code in context is:
require 5.006_00; # must use a modern perl
use strict;
use IO::File;
use IO::Socket;
use Getopt::Long;
use Fcntl ':flock';
my $VERSION = "3.4";
# Changes in support of OS/2
print '$ENV{ETC}=',$ENV{ETC},"\n";
print "OS=$^O\n";
print '$^O eq os2=',($^O eq 'os2'),"\n";
print 'BootDrive=',OS2::BootDrive(),"\n";
print "($^O eq 'os2') ? OS2::Bootdrive() : '/etc'=";
print $^O eq 'os2' ? 'true' : 'false',"\n";
print $^O eq 'os2' ? OS2::Bootdrive() : '/etc',"\n";
exit;
my $etc = $ENV{ETC};
#my $etc = $ENV{ETC} or ($^O eq 'os2') ? OS2::Bootdrive() : '/etc';
my $whois = File::Spec->catdir($etc,'whois');
# print '$etc=',$etc,"\n";
# print '$whois=',$whois,"\n";
--
Shmuel (Seymour J.) Metz, SysProg and JOAT <http://patriot.net/~shmuel>
Unsolicited bulk E-mail subject to legal action. I reserve the
right to publicly post or ridicule any abusive E-mail. Reply to
domain Patriot dot net user shmuel+news to contact me. Do not
reply to (e-mail address removed)
a bizare anomaly with the ternary operator. I was getting an error
message on the statement
my $etc = $ENV{ETC} or ($^O eq 'os2') ? OS2::Bootdrive() :
'/etc';
So I decided to try testing it a bit at a time. Each of the following
produces the expected output:
print '$ENV{ETC}=',$ENV{ETC},"\n";
print "OS=$^O\n";
print '$^O eq os2=',($^O eq 'os2'),"\n";
print 'BootDrive=',OS2::BootDrive(),"\n";
print "($^O eq 'os2') ? OS2::Bootdrive() : '/etc'=";
print $^O eq 'os2' ? 'true' : 'false',"\n";
[H:\]bwwhois 200.204.145.122
$ENV{ETC}=G:\MPTN\ETC
OS=os2
$^O eq os2=1
BootDrive=g
(os2 eq 'os2') ? OS2::Bootdrive() : '/etc'=true
However,
print $^O eq 'os2' ? OS2::Bootdrive() : '/etc',"\n";
gives me
Undefined subroutine &OS2::Bootdrive called at H:\UTILITY/BWwhois.cmd
line 61.
Note that the spelling is identical to the one that worked, so I
assume that the problem has something to do with the context of a
ternary operator. Any assistance will be appreciated.
The relevant code in context is:
require 5.006_00; # must use a modern perl
use strict;
use IO::File;
use IO::Socket;
use Getopt::Long;
use Fcntl ':flock';
my $VERSION = "3.4";
# Changes in support of OS/2
print '$ENV{ETC}=',$ENV{ETC},"\n";
print "OS=$^O\n";
print '$^O eq os2=',($^O eq 'os2'),"\n";
print 'BootDrive=',OS2::BootDrive(),"\n";
print "($^O eq 'os2') ? OS2::Bootdrive() : '/etc'=";
print $^O eq 'os2' ? 'true' : 'false',"\n";
print $^O eq 'os2' ? OS2::Bootdrive() : '/etc',"\n";
exit;
my $etc = $ENV{ETC};
#my $etc = $ENV{ETC} or ($^O eq 'os2') ? OS2::Bootdrive() : '/etc';
my $whois = File::Spec->catdir($etc,'whois');
# print '$etc=',$etc,"\n";
# print '$whois=',$whois,"\n";
--
Shmuel (Seymour J.) Metz, SysProg and JOAT <http://patriot.net/~shmuel>
Unsolicited bulk E-mail subject to legal action. I reserve the
right to publicly post or ridicule any abusive E-mail. Reply to
domain Patriot dot net user shmuel+news to contact me. Do not
reply to (e-mail address removed)