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 closure in PERL?

1009


Which functions in perl allows you to include a module file. State their differences.

932


What is a perl references?

904


Define dynamic scoping.

870


What is automatic error handling in perl?

1031


“Perl regular expressions match the longest string possible”. What is the name of this match?

931


What is the different between array and hash in perl programming?

910


How to prevent file truncation in perl?

993


How many types of operators are used in the Perl?

1023


Differences between die and exit.

987


What does -> symbol indicates in Perl?

965


How do find the length of an array?

1109


How to turn on Perl warnings? Why is that important?

1050


What is perl? What is the basic command to print a string in perl?

863


What is the use of -n and -p options?

1029