Sisyphus wrote: > Hi, > Basically, I want to be able to write in a perl script: > > print VALUE, "\n"; > > and have it print out the value returned by a subroutine. Something like > (which won't compile): > > use warnings > use constant VALUE => foo(); > print VALUE, "\n"; # print 42 > sub foo {return 42}
Try defining the sub foo two lines earlier so it's not a forward reference. use warnings; sub foo { return 42; } use constant VALUE => foo(); print VALUE, "\n"; > But all that produces is (as is to be expected): > Undefined subroutine &main::foo called at try.pl line 2. > BEGIN failed--compilation aborted at try.pl line 2. > > I could do: > > use warnings; > print VALUE(),"\n"; > sub VALUE {return 42} > > but I want to write it as: > print VALUE, "\n"; > not : > print VALUE(), "\n"; > > That is - all I'm really wanting to do is avoid the brackets ... but I don't > know how to achieve that. -- ,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED] (_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED] / ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/ -/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff) _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs