Log in



Tags » ‘perl’

What should I learn Perl or Python or Shell programming?

October 27th, 2010 by

Question by Maninder: What should I learn Perl or Python or Shell programming?
I am a B.Tech with Red Hat Certification. My question is to get a good job in North India which programming language should I do along with Linux??

Best answer:

Answer by jdpoc
Definately Python. It will have the logest ‘legs’.

:: http://whitespacelife.blogspot.com/

Add your own answer in the comments!

How do you print the values of a hash in PERL by using a key?

October 27th, 2010 by

Question by Licursi: How do you print the values of a hash in PERL by using a key?
Can someone give me an example please. I have a hash table indexed by a key and I want to print it out but I need the syntax of how to do so.

Thanks

Best answer:

Answer by Bobby
#First declare a hash
my %my_hash;

#Fill it with some stuff
$my_hash{‘key 1′} = ‘Some Data’;
$my_hash{100} = ‘More Data’;

#Now print out some values
print “Here is a single value $my_hash{100}\n”
print “Here is another $my_hash{‘key 1′}\n”

#Now print out all values/keys

foreach my $key (keys(%my_hash)) {
print “The key is $key the value is $my_hash{$key}}\n”;
}

#Important things to know about PERL. prefixing a $ to a variable means treat the data like a scalar value. A prefix of % means treat the data like a hash and a @ means treat it like an array.

Give your answer to this question below!


Powered by Yahoo! Answers