> Thank you! It seems in Perl, that not only are there a 101 ways of
> doing any one thing, but that it ha usually already been done before
> by some one else and made into a module!
Not exactly. Down the road it turns out that if you can imagine sex
there's module for this. Like, looking for a bug in my code for two
month, then finding out that bug isn't in my code. It's not in module.
It's in dependency. And it's not a bug, it's a feature.
> Some questions on your code example.
>
> 1) looking at your code and the perldoc for version, is the "->" part
> of the subroutines name or does the "->" have some other meaning?
Yes, it does.
my $aa = { foo => 'bar' };
print $aa->{foo};
Here '->' dereferences a plain reference (what you keep calling the
p-word, what it's not). And... (see below)
> 2) If common programming language, does
>
> version->parse( v1.2.99 ) < version->parse( v1.2.100 )
> and print "Horay!"
>
> expand to
>
> IF ( version->parse( v1.2.99 ) ) is less that
> ( version->parse( v1.2.100 ) )
> THEN
> print "Horay!"
> END
Not exactly. It's more like
IF is_less_than(
version->parse( v1.2.99 ), version->parse( v1.22.100 ) )
THEN
print "Hooray!\n"
END
Except '<' is derived from '<=>', what is overriden by version module to
act on version objects. What is returned by 'parse' method. What is
usual subroutine, except it's in 'version' namespace and it expects
first parameter to be namespace identifier (it's scalar and it should be
some inheritance (no inheritance is one case of inheritance) otherwise
control-flow couldn't reach that subroutine (or something is seriously
broken)) or it's an object ihnerited from 'version', and then come
parameters. And now it's not the subroutine anymore, but the method.
All that made into existance because 'parse' (what's not the method,
it's a constructor) returns reference (not p-word) blessed into
'version' class (or some inherited one). To get unconfused please
consume
perldoc perlboot
and friends (those are in 'SEE ALSO' section at the bottom).
> 3) will "print" always be expected to return a TRUE so that it can be
> used in an AND statement?
In essence -- yes. If passing bytes away would fail deep inside OS
(after syscall has returned) there's no way for perl to know about it,
but if your buffers don't sync you have a bigger problem. Printing over
closed (or un-opened) filehandle is a fatal run-time error. If OS finds
out that file descriptor is closed from other side then it's a sygnal.
In these latter cases control-flow can't possibly reach out-side
'print'.
And -- no, you must not use that co-insidence "in an AND statement".
You'll be beaten to death for doing that. And there's no "AND
statement". Please, use quotes. If quotes aren't enough you can always
retreat to POD syntax, it's understood by anyone.
Is it a quiz?
*CUT*