how to find a substring in a string without using substr
built in functions, and print the substring found

Answer Posted / lucky

#!/usr/bin/perl
print"enter string
";
$str=<stdin>;
print"enter substring
";
$substr=<stdin>;
if($str=~$substr){
    print"valid
";
}
else
{
print"invalid
";
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How interpreter is used in perl?

472


What $! In perl?

512


How to read from a pipeline with Perl

533


what is Chop & Chomp function does?

584


Why should I use the -w argument with my Perl programs?

543






Explain chomp?

502


What does a die() function do in perl?

532


How do I sort a hash by the hash value?

546


How can I implement the function overloading in Perl ? I read about the operator overloading, I do not know how to implement the function overloading. Thanks in advance ?

2486


What are the logical operators used for small scale operations? Explain them briefly.

524


What does the’$_’ symbol mean?

562


How will you create a file in perl?

511


How to convert arrays into a string in perl?

501


List all the features of perl programming?

496


Show the use of sockets for the server and client side of a conversation?

463