-
Can you give us an example of a subroutine in Perl? I'm studying for a Java exam and I'd like to know more. Here's a quotation from a handbook.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Let's consider what the handbook says, and we need both Perl 1 and Perl 5 interpreters to find out how it works. No call-by-reference in Perl 1A pass-by-reference example wouldn't work in Perl 1, and here is a good try.
This Perl 1 program prints 12 which is different from what we expect. Call-by-reference in Perl 5Call-by-reference is the default Perl 5 mechanism, just like the handbook states.
It prints 21 just like expected. Something similar in Perl 1Here's a traditional although sophisticated Hello World program.
Its output is "hello, world" printed in a single line. |
Beta Was this translation helpful? Give feedback.
Let's consider what the handbook says, and we need both Perl 1 and Perl 5 interpreters to find out how it works.
No call-by-reference in Perl 1
A pass-by-reference example wouldn't work in Perl 1, and here is a good try.
This Perl 1 program prints 12 which is different from what we expect.
Call-by-reference in Perl 5
Call-by-reference is the default Perl 5 mechanism, just like the handbook states.
It prints 21 just like expected.
Somethin…