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

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


Please Help Members By Posting Answers For Below Questions

How can you replace the characters from a string and save the number of replacements?

880


What are scalars in perl?

941


What are stdin, stdout and stderr?

1088


How to deleting an existing file in perl programming?

891


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

1003


what is Perl one liner?

887


what is the function that is used to identify how many characters are there in a string?

951


Why aren't Perl's patterns regular expressions?

1146


How the interpreter is used in Perl?

939


How to do comment in perl?

939


How to open and read data files with Perl

1030


Explain perl one-liner?

945


Write a program to decode the data in the form using cgi programming

1031


List the files in current directory sorted by size ?

967


What is the difference between single (') and double (") quote in a string in perl?

980