|
INTERVIEW QUESTIONS
PROGRAMMING LANGUAGES
PERL
DETAILS
Question: Difference between for & foreach,exec & system?
Answer: - Technically, there's no difference between for and foreach other than some style issues.
One is an alias of another. You can do things like this
foreach (my $i = 0; $i < 3; ++$i)
{ # normally this is foreach print $i, "n";}
for my $i (0 .. 2)
{ # normally this is for print $i, "n";}
- exec runs the given process, switches to its name and never returns while system forks off the given process, waits for it to complete and then returns.
|
|
|
Category |
Perl Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 8393 users |
Added on |
7/19/2011 |
Views |
70525 |
Rate it! |
|
|
Question:
Difference between for & foreach,exec & system?
Answer:
- Technically, there's no difference between for and foreach other than some style issues.
One is an alias of another. You can do things like this
foreach (my $i = 0; $i < 3; ++$i)
{ # normally this is foreach print $i, "n";}
for my $i (0 .. 2)
{ # normally this is for print $i, "n";}
- exec runs the given process, switches to its name and never returns while system forks off the given process, waits for it to complete and then returns. Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|