|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Return a hash table from a sub routine
hello, i am new to scripting and would like to know how to return a hash table from a sub routine. i tried the following, Code:
my %hash_function = ();
hash_function = &return_hash();
sub return_hash
{
my %hash = ();
///populate the hash
return %hash;
}but it dosent seem to work. Anything wrong in this?? |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
return the reference Code:
$ cat b.pl
#!/usr/bin/perl
use strict;
use warnings;
sub get_hashes();
# Get two variables back
my ($one) = get_hashes();
print "Hash Keys : ";
print "$_ " foreach keys %$one;
print "\n";
sub get_hashes() {
my %hash1 = (
"1a" => "b",
"1b" => "d"
);
return (\%hash1);
}
$ perl b.pl
Hash Keys : 1b 1a |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Hash Table like implementation in unix | anindyabecs | UNIX for Dummies Questions & Answers | 8 | 05-25-2011 03:44 PM |
| Hash table | andrew.paul | Programming | 1 | 01-07-2011 09:33 AM |
| nested hash table | arthi | UNIX for Dummies Questions & Answers | 0 | 06-27-2008 01:56 AM |
| Creating a Hash Table | callmetheskull | Programming | 4 | 12-23-2007 02:17 PM |
| hash table implementations in C Language | vlrk | Programming | 11 | 07-15-2007 09:33 AM |
|
|