Mystery message: Undefined subroutine &OS2::Bootdrive

  • Thread starter Shmuel (Seymour J.) Metz
  • Start date
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)
 
D

Darin McBride

Shmuel said:
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.

I would actually assume it's the comma ... try putting some extra
parens in there to keep your meaning clear:

print ($^O eq 'os2' ? OS2::Bootdrive() : '/etc'),"\n";
 
P

Polleke

on Wednesday 22 September 2004 21:12, Shmuel (Seymour J.) Metz wrote:

[snip]
print 'BootDrive=',OS2::BootDrive(),"\n"; ^
print "($^O eq 'os2') ? OS2::Bootdrive() : '/etc'="; ^
[snip]

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,

No it isn't; BootDrive() works, but Bootdrive() doesn't exist. Function
names are always case sensitive!

Paul
 
S

Shmuel (Seymour J.) Metz

In <Vgm4d.75406$%S.49494@pd7tw2no>, on 09/22/2004
I would actually assume it's the comma ...

Thanks, although that turned out to not be the problem. My Mark II
eyeball failed to note the difference in case between Bootdrive and
BootDrive. I should have looked for something simple before looking
for a subtle explanation :-(

--
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top