Consider the following example
#! /bin/perl
use strict;
sub sample
{
my @arr=(1,2,3,4);
return @arr;
}
my ($a,$b,$c,$d) = &sample;
print "$a\n$b\n$c\n$d\n";
In the above code, How can I get the $c without using the
arguments such as $a,$b.
I don't want to use any array to get the return values.
Answer Posted / guest
Try with the following program.
[code]
sub sample
{
my @arr=(1,2,3,4);
return @arr;
}
my $c=(&sample)[2];
print $c;
Variable 'c' will contain the value '3'.
Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
Difference between the variables in which chomp function work ?
Can inheritance be used in perl?
Explain the meaning of perl one-liner?
What is the purpose of redo statement?
What value is returned by a lone `return;’ statement?
When do you use perl programming?
Differentiate between c++ and perl.
You want to print the contents of an entire array. How would you do that?
What is it meants by '$_'?
What is confess function in perl?
What do you mean by context of a subroutine?
How interpreter is used in perl?
What does 'do' statement do in perl?
What are the advantages of perl programming?
Explain about the applications of perl?