how to find a substring in a string without using substr
built in functions, and print the substring found
Answers were Sorted based on User's Feedback
Answer / yashwanth
$r="YASHWANTH";
@n=split (//,$r);
print "@n\n";
@t=splice(@n,0,3);
print "@t\n";
$r=join("",@t);
print "$r\n";
~
~
Is This Answer Correct ? | 10 Yes | 2 No |
Answer / 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 |
Answer / garg
#! /user/bin/perl
$str="Yashwanth";
$n="wan";
if ($str=~ $n)
{
print $n;
}
Is This Answer Correct ? | 4 Yes | 6 No |
What is 'commit' command in perl?
How many data types are there in perl?
What is q (single q) operator in perl?
Why we use "use lib $path"?
What is qq (double q)operator in perl?
what is the main function of fork() in cgi programming?
How to read a directory in perl?
Explain grooving and shortening of arrays and splicing of arrays?
How can you create an object of a class in a package?
What is the function of virtual documents in cgi programs?
What is a chomp() function in perl?
How to deleting an existing file in perl programming?