> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:perl-
> [EMAIL PROTECTED] On Behalf Of Sisyphus
> Sent: Wednesday, September 14, 2005 05:36
> To: perl-win32-users
> Subject: Print subroutine return value without using brackets.
> 
> 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}
> 
> 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.
> 
> Any help appreciated.
> 
> Cheers,
> Rob
> 

Rob,

You were missing a ; after use warnings.
Call the foo subroutine directly in the print statement.


use warnings;
#use constant VALUE => &foo();
#print VALUE, "\n"; # print 42
print &foo, "\n"; # print 42
sub foo {return 42}


keith

-- 

Keith R. Watson                        GTRI/ISD
Systems Support Specialist III         Georgia Tech Research Institute
[EMAIL PROTECTED]           Atlanta, GA  30332-0816
404-894-0836

_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to