Challenge: Check Substring
Check if a specific string exists in a given string in this challenge.
We'll cover the following
Problem statement
In this challenge, you have to write code that checks if a string contains a specific string. Your code should return 1
if it does else return -1
.
Sample input
The quick brown fox jumps over the lazy dog.
Check whether the said string contains the string jumps
.
Sample output
1
Hint: Use the built-in functions you learned about in the previous lesson.
Important Note: Your code needs to pass all three test cases in order to be considered correct.
Coding challenge
sub stringCheck{# try to access strings using @_[0] and @_[1]# You have to check if the string $str2 exists in string $str1# write your code herereturn 0;}