Home : General : Perl Programming :

General: Perl Programming: Re: [Michael_Bray] Auto Backup script..: Edit Log

Here is the list of edits for this post
Re: [Michael_Bray] Auto Backup script..
Code:
I thought


--------------------------------------------------------------------------------
Code
--------------------------------------------------------------------------------


sub() { something; }

--------------------------------------------------------------------------------



and


--------------------------------------------------------------------------------
Code
--------------------------------------------------------------------------------


sub { something; }

--------------------------------------------------------------------------------



were the same. They are both sub routines that just don't accept any input aren't they? They'd end up both being constants as there isn't any variables that would effect the output?

sub { something } is an anonymous subroutine....you can pass in input like:

Code:
my $var = sub { return $_[0] x 5 };

print $var->(5);

Have a guess at what that prints :)

sub FOO() { 1 }

....becomes a constant meaning you could do something like:

Code:
if (FOO == 1) {
print "FOO is 1";
}

Last edited by:

Paul: Jun 26, 2002, 3:08 AM

Edit Log: