Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What does " 1; " mean ?

Status
Not open for further replies.

bluegroper

Technical User
Dec 12, 2002
407
AU
What does 1; mean in perl ?
Amusing how its impossible to google for "1;" :smile:
Does 1; mean exit; ??
Or does 1; mean return to the calling module ?
TIA's
- BG
 
In the case you have a module or script that consists of only subroutines. 1 returns true when 'require'd or 'use'd.

M. Brooks
 
For a more detailed explanation, 1 is the return value of a require or use.

That being said, the 1; could be a hashref that could be returned from the require statement, eg.

Code:
# subs.pl - full of random subroutines
sub one {
}

sub two {
}

sub three {
}

# return a hashref
{
   name => 'subs.pl',
   description => 'Has tons of useless empty subroutines',
};

Code:
my $info = require "subs.pl";
print $info->{description}, "\n";

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top