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 do I replace every TAB character in a file with a comma?

740


What is cpan in perl?

716


What are the advantages of programming in perl?

714


What are stdin, stdout and stderr?

684


How to prevent file truncation in perl?

693


What are the various flags/arguments that can be used while executing a perl program?

633


Explain the internal working of cgi

684


What are the different ways to run cgi?

679


what are the three groups involved in information sharing?

654


What is the difference between use and require in perl programming?

683


Perl regular expressions are greedy" what does this mean?

666


What is 'commit' command in perl?

813


How to read a single line from a file in perl?

726


How do you turn on the perl warnings?

677


How will you create a file in perl?

700