Try pattern matching for the following:
1) 10.111.23.11
2) /root/abc/cde/fgg/ac.xml --> Get file name without
extention.
3) /root/abc/ac.xml/fgg/ac.xml --> Get file name without
extention.
4) What does "DIE" meant in PERL?
5) chomp
6) "This is saturday" --> Print the weekday number.
7) 11-2-2009 --> Print the name of the month.
8) Reverse the string without using func in C.
Answer Posted / kiruthikau
Try the following code for getting weekday number.
[code]
use strict;
use warnings;
my %days=("Sunday"=>1,
"Monday"=>2,
"Tuesday"=>3,
"Wednesday"=>4,
"Thursday"=>5,
"Friday"=>6,
"Saturday"=>7,);
my $str="This is Saturday";
my @day=split(' ',$str);
print "\tWeekday Number of $day[-1] is:",$days{$day[-1]};
[/code]
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
Explain chop?
What is the difference between die and exit in perl?
Where do we require ‘chomp’ and what does it mean?
What happens in dereferencing?
What exactly is grooving and shortening of the array?
What is the purpose of “_file_ literal” and “_line_ literal” in perl?
Which statement has an initialization, condition check and increment expressions in its body? Write a syntax to use that statement.
Differentiate use and require?
Assuming both a local($var) and a my($var) exist, what's the difference between ${var} and ${"var"}?
What does undef function in perl?
What are the various uses of perl?
Explain the difference between "my" and "local" variable scope declarations. ?
Explain socket programming in perl?
How can the user execute a long command repeatedly without typing it again and again?
Explain the difference between declarations of 'my' and 'local' variable scope in perl?