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.?
Submitted by: Administratormy $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 matchedn";
}
if($file1=~s//(.*)/(.*).(.*)/$2/)
{
print "File Name is $file1n";
}
print strftime("%B",0,0,0,11,2-1,2009);
[/code]
Submitted by: Administrator
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 matchedn";
}
if($file1=~s//(.*)/(.*).(.*)/$2/)
{
print "File Name is $file1n";
}
print strftime("%B",0,0,0,11,2-1,2009);
[/code]
Submitted by: Administrator
Read Online CGI Perl Job Interview Questions And Answers
Top CGI Perl Questions
☺ | Difference between Perl and Mod_perl? |
☺ | Write a script to display mirror image of a entered value and also check whether Palindrome? |
☺ | Write an expression or Perl script to identify the entered IP address is valid or not? |
☺ | Write a script to generate n prime no.s? |
☺ | How to find a substring in a string without using substr built in functions, and print the substring found? |
Top Coding/Programming Categories
☺ | Python Interview Questions. |
☺ | OOP Interview Questions. |
☺ | Software engineering Interview Questions. |
☺ | PHP Interview Questions. |
☺ | VBA (Visual Basic for Applications) Interview Questions. |