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

What is the difference between exec and system?

1154


What is confess function in perl?

997


How do I debug a perl program?

1028


How to print escaping characters inside a string in perl?

953


How to open and read data files with Perl

1090


Explain perl one-liner?

998


Why do we use "use strict" in perl?

1043


Show the use of sockets for the server and client side of a conversation?

933


Difference between the variables in which chomp function work ?

1116


If EXPR is an arbitrary expression, what is the difference between $Foo::{EXPR} and *{"Foo::".EXPR}?

1084


How to access parameters passed to a subroutine in perl?

1008


Explain join function in perl?

997


In Perl, there are some arguments that are used frequently. What are that arguments and what do they mean?

942


How to change a directory in perl?

980


How to know whether a key exists or not in perl?

1020