----- Original Message ----- From: "Chris Wagner" <[EMAIL PROTECTED]> To: "perl-win32-users" <perl-win32-users@listserv.ActiveState.com> Sent: Thursday, September 15, 2005 12:04 AM Subject: Re: Print subroutine return value without using brackets.
> Start it with use subs foo; U need to predeclare a subroutine to use it as > a "builtin". See perldoc subs. > I've ended up doing that. Thanks for the pointer. In actual fact foo() is an XSUB in a module I'm writing - and because it's an XSUB I'm having a lot of trouble with 'use constant VALUE => foo();'. I haven't found a way of doing it - and I wonder if it can in fact be done. I even built a source distro (reproduced below my sig) which I used to test things out. With those four files, you can succssfully run 'perl Makefile.PL' and 'dmake' (or 'nmake' ... or whatever flavor of make you happen to be using). But when it comes to make test: D:\test>dmake test D:\perl58_M\5.8.7\bin\perl.exe "-Iblib\lib" "-Iblib\arch" test.pl Undefined subroutine &Foo::foo called at blib\lib/Foo.pm line 8. BEGIN failed--compilation aborted at blib\lib/Foo.pm line 8. Compilation failed in require at test.pl line 3. BEGIN failed--compilation aborted at test.pl line 3. dmake: Error code 255, while making 'test_dynamic' If someone likes to play around with that and get it working (or confirm that it can't work), then I'd find that most interesting. However, now that I've switched to 'use subs' I don't actually *need* the 'use constant' construct ... so it's really just an academic exercise as far as I'm concerned. Thanks for all the help, guys. Cheers, Rob D:\test>type Foo.pm package Foo; use strict; use warnings; require Exporter; require DynaLoader; use constant VALUE => foo(); @Foo::ISA = qw(Exporter DynaLoader); @Foo::EXPORT_OK = qw(VALUE); $Foo::VERSION = '0.01'; bootstrap Foo $Foo::VERSION; 1; D:\test>type Foo.xs #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #define VALUE 42 SV * foo() { return newSViv(VALUE); } MODULE = Foo PACKAGE = Foo PROTOTYPES: DISABLE SV * foo () D:\test>type Makefile.PL use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Foo', VERSION_FROM => 'Foo.pm' ); D:\test>type test.pl use warnings; use strict; use Foo; if(VALUE == 42) {print "ok 1\n"} else {print "not ok 1\n"} D:\test> _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs