Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

# Here is another solution

use strict;
sub sample {
my @arr = (1,2,3,4);
return \@arr; # return the array reference
}

my $aref = &sample;
print $aref->[2];

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the purpose of redo statement?

1011


What does next statement do in perl?

989


What is the tk module?

953


What is the use of -w, -t and strict in Perl?

988


What are scalars in perl?

957


Explain chomp?

927


What is the use of -t?

963


Define say() function in perl?

962


How to read file into hash array ?

1101


Explain 'grep' function.

976


How can I implement the function overloading in Perl ? I read about the operator overloading, I do not know how to implement the function overloading. Thanks in advance ?

2901


Explain strftime() function in perl?

936


What is the use of 'ne' operator?

999


Does Perl have objects? If yes, then does it force you to use objects? If no, then why?

953


When do you use perl programming?

995