Perl Programming Question:
Download Job Interview Questions and Answers PDF
How do I do < fill-in-the-blank > for each element in an array?
Answer:
#!/usr/bin/perl -w
@homeRunHitters = ('McGwire', 'Sosa', 'Maris', 'Ruth');
foreach (@homeRunHitters) {
print "$_ hit a lot of home runs in one yearn";
}
@homeRunHitters = ('McGwire', 'Sosa', 'Maris', 'Ruth');
foreach (@homeRunHitters) {
print "$_ hit a lot of home runs in one yearn";
}
Download Perl Programming Interview Questions And Answers
PDF
Previous Question | Next Question |
If EXPR is an arbitrary expression, what is the difference between $Foo::{EXPR} and *{"Foo::".EXPR}? | How do I replace every <TAB> character in a file with a comma? |