Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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.

Answers were Sorted based on User's Feedback



Try pattern matching for the following: 1) 10.111.23.11 2) /root/abc/cde/fgg/ac.xml --> Ge..

Answer / 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

Try pattern matching for the following: 1) 10.111.23.11 2) /root/abc/cde/fgg/ac.xml --> Ge..

Answer / guest

my $str="This is testing of string reverse";
print scalar reverse $s

chomp is used to remove the trailing new line.
If we give chomp list then it will remove the trailing new
line in all the elements of the list.

die function is used for handling the errors in Perl.
It terminates the program immediately after printing the
message passed to the die function.
die("testing of die");
It will print the message "testing of die" on screen and
terminates the program.

Pattern Matching
----------------
[code]

my $str="10.111.23.11";
my $file="/root/abc/cde/fgg/ac.xml";
my $file1="/root/abc/ac.xml/fgg/ac.xml";
if($str=~/[0-9]{2}\.[0-9]{3}\.[0-9]{2}\.[0-9]{2}/)
{
print "Pattern $& get matched\n";
}
if($file1=~s/\/(.*)\/(.*)\.(.*)/$2/)
{
print "File Name is $file1\n";
}
print strftime("%B",0,0,0,11,2-1,2009);

[/code]

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More CGI Perl Interview Questions

write a perl script to find whether a given line of text is starting and ending with same word or not ???

2 Answers   CSS,


what is Polymorphism in Perl?

0 Answers  


What is the use of -n and -p options?

0 Answers  


What does file test operators do in perl?

0 Answers  


How do I sort a hash by the hash key?

0 Answers  


What is perl unshift array function?

0 Answers  


Explain split function in perl?

0 Answers  


Explain what is the scalar data and scalar variables in Perl?

0 Answers  


What are the advantages and disadvantages of perl language?

0 Answers  


What does the command "use strict" do and why should you use it?

2 Answers   Symphony, TCS,


How interpreter is used in perl?

0 Answers  


What does localtime() do in perl?

0 Answers  


Categories