On 12/08/11 08:03 AM, TimKapHwan wrote:
Hello all!
My first question in this group =)
Can someone explain me why this work fine:
#!/usr/bin/perl -w
sub func
{
return 10;
}
print 5 * func, "\n";
The answer is 50. Good!
But then i change func and 5:
#!/usr/bin/perl -w
sub func
{
return 10;
}
print func * 5, "\n";
The output is 10 Without multiplication by 5 and "\n".
Why this happens, plz tell.
Thank you!!
Try: print func() * 5, "\n";
The above means: print func( *5, "\n" );
where *5 is a reference to the typeglob 5. See `perldoc perlreftut` and
`perldoc perlref` for details.
--
Just my 0.00000002 million dollars worth,
Shawn
Confusion is the first step of understanding.
Programming is as much about organization and communication
as it is about coding.
The secret to great software: Fail early & often.
Eliminate software piracy: use only FLOSS.
"Make something worthwhile." -- Dear Hunter
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/