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 Polymorphism in Perl?

902


what is Perl one liner?

857


What package you use to create a windows services?

830


List all the features of perl programming?

849


How to close a directory in perl?

870


Which guidelines by Perl modules must be followed?

962


What are the arguments and what do they mean in perl programming?

952


Define print() function in perl?

864


Explain the use of 'my' keyword in perl?

958


what are the steps involved in reading a cgi script on the server?

872


There are two types of eval statements i.e. Eval expr and eval block. Explain them.

941


How to read multi lines from a file in perl?

869


Enlist the advantages of using c over perl?

861


how to get back up from private character editor which is saved in the format of .udf

2241


How will you access an element of a perl array?

887