Yahoo Interview Question for Production Engineers






Comment hidden because of low score. Click to expand.
1
of 1 vote

scalar variable $variableName
array variable @variableName
hash variable %variable_name

using -e option to see if a file exists
if( -e $fileName)
{
}

- durgesh October 07, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

An example of three kinds of variables

/home/gkhurana> perl
#Scalar
print "\nPrinting scalar\n";

$a = "10";
$b = "HI how are you ";
print $a;
print "\n";
print $b;
print "\n";


#Array
print "\nPrinting array values";
@a=(1,2,3,4);
@b=("do","you","know","me");
@c=('do','you');
foreach(@a,@b,@c)
{
print "$_\n";
}


#hash
%a = ( 1 =>'one' , 2=>"two");

print "\nPrinting Hash\n";
while (($key, $value)=each %a)
{
print "keys = $key value = $value \n";
}

^D

#Output below
Printing scalar
10
HI how are you

Printing array values1
2
3
4
do
you
know
me
do
you

Printing Hash
keys = 1 value = one
keys = 2 value = two
/home/gkhurana>

- Gaurav Khurana March 04, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-2
of 2 vote

Basic Variables in Perl:
1.Scalar Variables -->Scalar variables are simple variables containing only one element--a string, a number, or a reference.
2.Array Variables--> Arrays contain a list of scalar data (single elements).Denoted by @
3.Hashes -->are complex lists with both a key and a value part for each element of the list.

To see if a file exists: First open a file ..if it doesnt open display error

open MYFILE , "filename" || "die $!";

- Anonymous August 26, 2011 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More